Parameter estimation

Download Report

Transcript Parameter estimation

Introduction to Pattern Recognition for human ICT
Parameter estimation
2014. 10. 17
Hyunki Hong
Contents
•
Introduction
•
Parameter estimation
•
Maximum likelihood
•
Bayesian estimation
• In most situations, the true distributions are unknown and
must be estimated from data.
– Two approaches are commonplace.
1. Parameter Estimation
2. Non-parametric Density Estimation
• Parameter estimation
– Assume a particular form for the density (e.g. Gaussian), so
only the parameters (e.g., mean and variance) need to be
estimated.
1. Maximum Likelihood
2. Bayesian Estimation
• Non-parametric density estimation
– Assume NO knowledge about the density
1. Kernel Density Estimation
2. Nearest Neighbor Rule
ML vs. Bayesian parameter
estimation
• Maximum Likelihood
– The parameters are assumed to be FIXED but unknown.
– The ML solution seeks the solution that “best” explains the
dataset X :
• Bayesian estimation
– Parameters are assumed to be random variables with some
(assumed) known a priori distribution.
– Bayesian methods seeks to estimate the posterior density 𝑝(𝜃|
𝑋)
– The final density 𝑝(𝑥|𝑋) is obtained by integrating out the
parameters.
Maximum Likelihood
• Problem definition
– Assume we seek to estimate a density 𝑝(𝑥) that is known to
depends on a number of parameters 𝜃 = [𝜃1, 𝜃2, …, 𝜃𝑀]𝑇.
1. For a Gaussian pdf, 𝜃1 = 𝜇, 𝜃2 = 𝜎 and 𝑝(𝑥) = 𝑁(𝜇, 𝜎).
2. To make the dependence explicit, we write 𝑝(𝑥|𝜃).
– Assume we have dataset 𝑋 = {𝑥(1, 𝑥(2, …, 𝑥(𝑁} drawn
independently from the distribution 𝑝(𝑥|𝜃) (an i.i.d. set)
1. Then we can write
independent identically distributed
2. The ML estimate of 𝜃 is the value that maximizes the likelihood
𝑝(𝑋|𝜃).
3. This corresponds to the intuitive idea of choosing the value of
𝜃 that is most likely to give rise to the data.
• For convenience, we will work with the log likelihood
- Because the log is a monotonic function, then:
- Hence, the ML estimate of 𝜃 can be written as:
1. This simplifies the problem, since now we have to maximize a
sum of terms rather than a long product of terms.
2. An added advantage of taking logs will become very clear
when the distribution is Gaussian.
Example: Gaussian case, 𝝁 unknown
• Problem statement
– Assume a dataset 𝑋 = {𝑥(1, 𝑥(2, …, 𝑥(𝑁 } and a density of the form 𝑝
(𝑥) = 𝑁(𝜇, 𝜎) where 𝜎 is known.
– What is the ML estimate of the mean?
– The maxima of a function are defined by the zeros of its
derivative.
- So the ML estimate of the mean is the average value of the training data, a
very intuitive result!
Example: Gaussian case, both 𝝁 and 𝝈
unknown
• A more general case when neither 𝝁 nor 𝝈 is known.
– Fortunately, the problem can be solved in the same fashion.
– The derivative becomes a gradient since we have two
variables.
참고자료: 뒷장
– Solving for 𝜃1 and 𝜃2 yields
Therefore, the ML of the variance is the sample variance of the
dataset, again a very pleasing result.
– Similarly, it can be shown that the ML estimates for the multivariate
Gaussian are the sample mean vector and sample covariance matrix.
참고자료
• 가우시안 확률밀도함수에 대한 최대우도추정
– x = (x1, …, xR)이 x ~ N(μ, σ2)인 상호 독립 및 동일 확률분포 조건에서 생성
된 표본이라 가정하면, θ = (θ1, θ2) = (μ, σ) ?
• 로그 우도:
θ1, θ2 에 대해 각각 미분
• l(θ)의 그래디언트:
d
1 du
(log u ) 
dx
u dx
설정
: MLE 결과는 각각 표준과 분산
Bias and variance
• How good are these estimates?
– Two measures of “goodness” are used for statistical estimates.
– BIAS: how close is the estimate to the true value?
– VARIANCE: how much does it change for different datasets?
– The bias-variance tradeoff
: In most cases, you can only decrease one of them at the expense of
the other.
• What is the bias of the ML estimate of the mean?
- Therefore the mean is an unbiased estimate.
• What is the bias of the ML estimate of the variance?
참고자료
- Thus, the ML estimate of variance is BIASED.
This is because the ML estimate of variance uses
𝜇.
instead of
– How “bad” is this bias?
1. For 𝑁→∞ the bias becomes zero asymptotically.
2. The bias is only noticeable when we have very few samples, in
which case we should not be doing statistics in the first place!
– Notice that MATLAB uses an unbiased estimate of the
covariance.
Bayesian estimation
• In the Bayesian approach, our uncertainty about the
parameters is represented by a pdf
– Before we observe the data, the parameters are described
by a prior density 𝑝(𝜃) which is typically very broad to
reflect the fact that we know little about its true value.
– Once we obtain data, we make use of Bayes theorem to find
the posterior 𝑝(𝜃|𝑋).
: Ideally we want the data to sharpen the posterior 𝑝(𝜃|𝑋), that is,
reduce our uncertainty about parameters.
– Remember, though, that our goal is to estimate 𝑝(𝑥) or, more
exactly, 𝑝(𝑥|𝑋), the density given the evidence provided by
the dataset X.
Joint probability(결합확률): 두 사건이 동시에 일어날 확률 P(A, B)
A, B가 서로 독립이면, P(A, B) = P(A)P(B) = P(A∩B). 아니면 P(A, B) = P(A|B)P(A)
• Let us derive the expression of a Bayesian estimate.
– From the definition of conditional probability
- 𝑃(𝑥|𝜃, 𝑋) is independent of X since knowledge of 𝜃
completely specifies the (parametric) density. Therefore
and, using the theorem of total probability we can integrate
𝜃 out:
1. The only unknown in this expression is 𝑝(𝜃|𝑋); using Bayes rule
, where 𝑝(𝑋|𝜃) can be computed using the i.i.d. assumption.
2. NOTE : The last three expressions suggest a procedure to
estimate 𝑝(𝑥|𝑋). This is not to say that integration of these
expressions is easy!
• Example
– Assume a univariate density where our random variable 𝑥 is
generated from a normal distribution with known standard
deviation.
– Our goal is to find the mean 𝜇 of the distribution given some
i.i.d. data points 𝑋 = {𝑥(1, 𝑥(2, …, 𝑥(𝑁}.
– To capture our knowledge about 𝜃 = 𝜇, we assume that it
also follows a normal density with mean 𝜇0 and standard
deviation 𝜎0.
– We use Bayes rule to develop an expression for the
posterior 𝑝(𝜃|𝑋).
– To understand how Bayesian estimation changes the
posterior as more data becomes available, we will find the
maximum of 𝑝(𝜃|𝑋).
– The partial derivative with respect to 𝜃=𝜇 is
which, after some algebraic manipulation, becomes
Therefore, as N increases, the estimate of the mean 𝜇𝑁
moves from the initial prior 𝜇0 to the ML solution.
– Similarly, the standard deviation 𝜎𝑁can be found to be
Example
• Assume that the true mean of the distribution 𝑝(𝑥) is 𝜇 =
0.8 with standard deviation 𝜎 = 0.3.
– In reality we would not know the true mean.
– We generate a number of examples from this distribution.
– To capture our lack of knowledge about the mean, we
assume a normal prior 𝑝0(𝜃0), with 𝜇0 = 0.0 and 𝜎0 = 0.3.
– The figure below shows the posterior 𝑝(𝜇|𝑋).
1. As 𝑁 increases, the estimate 𝜇𝑁 approaches its true value (𝜇 =
0.8) and the spread 𝜎𝑁 (or uncertainty in the estimate).
ML vs. Bayesian estimation
• What is the relationship between these two estimates?
– By definition, 𝑝(𝑋|𝜃) peaks at the ML estimate.
– If this peak is relatively sharp and the prior is broad, then
the integral below will be dominated by the region around
the ML estimate.
Therefore, the Bayesian estimate will approximate the ML solution.
– As we have seen in the previous example, when the number
of available data increases, the posterior 𝑝(𝜃|𝑋) tends to
sharpen.
1. Thus, the Bayesian estimate of 𝑝(𝑥) will approach the ML
solution as 𝑁→∞.
2. In practice, only when we have a limited number of observations
will the two approaches yield different results.
비모수 밀도 추정법
01_비모수 밀도 추정
02_히스토그램
03_커널 밀도 추정
04_Parzen 창에 의한 커널 밀도 추정
05_스무드 커널을 이용한 커널 밀도 추정
06_k-NNR을 이용한 밀도 추정 (다음주)
01_비모수 밀도 추정
주어진 유한 개의 데이터 x1, x2, ..., xN로부터 확률밀도함수 P(x|Ck) 추정 문제
• 비모수 밀도 추정(Non-parametric Density Estimation)
– 파라미터(모수)를 사용하지 않고 표본 데이터에 대한 밀도함수 추정
– 확률밀도함수 P(x|Ck)를 추정하는 방법
• 히스토그램
• 커널밀도추정(KDE)
– Parzen창 이용한 커널밀도 추정
– 스무스 커널 이용한 밀도 추정
• K-NNR을 이용한 밀도 추정
02_히스토그램
•
데이터의 밀도를 간단한 형태로 표현
− 주어진 데이터를 일정 간격(bin)으로 나누고 각 간격에 해당되는 표본의 빈도수
를 카운트하여 데이터의 밀도를 표현한 그래프
•
•
빈도수의 총 합 = 1  확률밀도
단점
− 밀도 추정의 최종모양은 막대의 시작점(origin)과 막대-폭(bin-width)에 의존함
− 데이터 간격이 클 경우, 추정된 밀도 값의 불연속도 증가
 불연속 정도가 큰 매끄럽지 못한 밀도 값
02_히스토그램
Y = [2.1, 2.4, 2.4, 2.47, 2.7, 2.6, 2.65, 3.3, 3.39, 3.8, 3.87];
X = [0.25:0.5:5];
N=
N = hist(Y, X);
0
0
0
0
4
3
2
2
0
0
막대폭: 0.5
시작점: 각각 n.0과 n.5
02_히스토그램
막대폭: 0.5
시작점을 0.25만큼 이동
Y = [2.1, 2.4, 2.4, 2.47, 2.7, 2.6, 2.65, 3.3, 3.39, 3.8, 3.87];
X = [0.5:0.5:5];
N=
N = hist(Y, X);
0
0
0
1
6
0
2
2
0
단점:
1. 추정된 밀도는 시작점,
막대폭에 의존
2. 다변량 데이터도 시작점에
영향받음.
3. 추정된 밀도가 불연속적
0
03_커널 밀도 추정의 기본 개념
• Histogram vs. Generic KDE
– 1D Density Estimation
Histogram
KDE
03_커널 밀도 추정
• 비모수적 밀도추정 일반식
k
p ( x) 
NV
• 커널밀도추정 두 가지 방법
V : x를 둘러싼 영역 R의 체적(면적)
N : 표본의 총수
k : 영역 R내의 표본의 수
– KDE (Kernel Density Estimation)
• 체적 V를 고정시키고, 영역내의 표본 수 k를 가변하여 밀도함수 추정
• Parzen 창(window) 추정법 (또는 Parzen–Rosenblatt window)이 대표적
– VN = 1
과 같은 N의 함수로 체적 VN 을 지정하여 영역을 줄여가면서 최적밀도 추정
N
– k-NNR 추정법
• 영역 내의 표본 수 k 값을 고정된 값으로 선택하고 체적 V를 변경시켜 접근
• 어떤 표본점을 포함하는 체적이 k N  N 개의 표본을 포함하도록 체적 줄여
나가면서 최적 밀도 추정
03_커널 밀도 추정
n의 함수로 체적 Vn 지정
• 커널밀도추정의 두가지 방법
kn개의 표본 포함하도록 체적 Vn 줄임.
- KDE, K-NNR 모두 N이 커질수록 실제 확률밀도에 수렴함.
- V와 k는 N에 따라 가변적으로 결정됨.
04_Parzen 창에 의한 커널 밀도 추정
• 비모수적 밀도함수 추정 일반식: V 고정, k 가변
k
p ( x) 
NV
V : x를 둘러싼 영역 체적 범위
N : 표본의 총수
k : V내의 표본의 수
– 중심점 x가 입방체의 중심, 한 변의 길이 h인 초입방체를 영역 R,
여기에 k개의 표본을 포함한다면
체적: V  h
D
D:
차원의 수
Parzen 창(window) : 최초값이 중심이 되도록 하는 단위 초입방체(hypercube)
범위 내에 포함시킬 표본 수를 결정할 함수(kernel)

1, u j  1 2
K (u )  

0, 그외
j  1,..., D
(Uniform kernel)
 x  xn
k   K 
n 1
 h
N
범위 내의 점의 총수




04_Parzen 창에 의한 커널 밀도 추정
• Parzen–Rosenblatt 윈도우 밀도함수 추정식의 일반화
– 영역 내의 표본의 수는 중심이 x이고 길이가 h인 범위 내부에 점 Xn
이 속할 때만 “1”이고, 나머지는 “0”이 됨
– 영역 V내에 포함되는 표본의 총 수를 밀도추정 일반식에 치환하면,

1, u j 1 2
K (u )  

0, 그외
h
일반적인 커널 밀도함수 추정기
1
PKDE ( x) 
Nh D
X Xn
K 

h
n 1

N



04_Parzen 창에 의한 커널 밀도 추정
• Parzen–Rosenblatt 윈도우
– Kernel functions in common use
for KDE
04_Parzen 창에 의한 커널 밀도 추정
• 커널함수의 역할
PKDE ( x)의기대값
– 추정된 밀도 PKDE ( x) 의 기대값: 커널 함수와 실제 확률밀도의 convolution
– 커널의 폭 h는 스무딩 파라미터 역할
• 커널 함수가 넓으면 넓을수록 추정치는 더 부드러워짐
• h 0 : 커널 함수의 폭  0, 함수 값  무한대
즉, h 0 이면 커널 함수가 delta function에 수렴함.
04_Parzen 창에 의한 커널 밀도 추정
• 커널함수의 역할
04_Parzen 창에 의한 커널 밀도 추정
• 커널함수의 역할

1, u j 1 2
K (u )  

0, 그외
(Uniform kernel)
04_Parzen 창에 의한 커널 밀도 추정
• 커널함수에서 bandwidth h의 역할
1
pn ( x) 
Nh D
 X Xn 

K 

n 1
 h 
N
– 커널 함수가 다음과 같은 delta function이라고 가정하면
1 X
 n ( X )  K  
Vn  hn 
1 n
pn ( x )    n  X  X
n j 1
j

• h 가 커질수록
– delta function의 크기 감소
– 동시에 포함되는 표본 데이터 수 증가
– 넓게 퍼진 평활한 형태의 함수
• h 가 작아질수록
– delta function의 크기 증가
– Bandwith에 포함되는 표본 데이터 수 감소
– 피크모양에 가까운 형태의 밀도함수
 n (X )
04_Parzen 창에 의한 커널 밀도 추정
• 커널함수의 역할
05_스무드 커널을 이용한 커널 밀도 추정
– 연속적인 형태의 커널함수를 사용하는 경우
항상 양인 스무드 커널함수 K(x)로
파젠창 일반화해서 불연속 현상 해결
h: 스무드 파라미터 또는 대역폭
– Parzen 창을 사용할 경우 추정된 전체 밀도의 모양이
불연속적인 모양을 갖는
문제를 해결하기 위한 추정법
05_스무스 커널을 이용한 커널 밀도 추정
• 창함수 효과
05_스무스 커널을 이용한 커널 밀도 추정
• 창함수 효과
- 대역폭이 지나치게 커지면:
• 밀도함수의 과도한 평활화
» Oversmooth
• 정확한 형태 추정의 어려움
- 대역폭이 지나치게 좁아지
면:
• 전체적 추세가 아닌 개별 데
이터에 민감해짐
» Undersmooth
• 분석이나 클래스화 힘들어짐
05_스무스 커널을 이용한 커널 밀도 추정
• 언더스무드vs. 오버스무드