这三者的联系非常紧密
最小二乘估计(LLS)
首先假设直线为
y
=
a
x
+
b
y=ax+b
y=ax+b我们的目标函数就可以设为
χ
2
=
Σ
i
n
(
y
i
−
y
(
x
i
)
)
2
\chi^2=\Sigma_i^n(y_i-y(x_i))^2
χ2=Σin(yi−y(xi))2最小二乘估计比较简单易懂,只需把数据代入这个公式,然后求导等于零,就可以算出a和b的值。
**改进的最小二乘估计方法(MLS):**引入数据的权重来改进估计,提高估计的可信度,具体的方法时在上式中加入权重系数
w
i
=
1
/
σ
i
2
w_i=1/\sigma_i^2
wi=1/σi2则原来的公式变为:
χ
2
=
Σ
i
n
w
i
(
y
i
−
y
(
x
i
)
)
2
\chi^2=\Sigma_i^nw_i(y_i-y(x_i))^2
χ2=Σinwi(yi−y(xi))2
最大似然估计(MLE)
最大似然的原理是:
L
(
p
a
r
a
m
e
t
e
r
∣
d
a
t
a
)
=
p
(
d
a
t
a
∣
p
a
r
a
m
e
t
e
r
)
L(parameter|data)=p(data|parameter)
L(parameter∣data)=p(data∣parameter)
也就是概率大小是根据参数来确定的,反过来,参数的大小也可以由概率来推断,为了表示区别,对参数的估计被称为似然估计。
Maximum Likelihood Estimation seeks the solution that “best” explains the observed data set.
θ
M
L
=
a
r
g
m
a
x
θ
P
(
X
∣
θ
)
\theta^{ML}=argmax_\theta P(X|\theta)
θML=argmaxθP(X∣θ)
=
a
r
g
m
a
x
θ
l
o
g
P
(
X
∣
θ
)
=argmax_\theta logP(X|\theta)
=argmaxθlogP(X∣θ)
举一个例子:
Example: Coin flipping
- Suppose we have been given data from a series of m coin flips, and we are not sure if the coin is fair or not.
- We might assume that the data were generated by a sequence of independent draws from a Bernoulli distribution, parameterized by θ \theta θ, which is the probability of flipping Heads.
- But what’s the value of θ \theta θ?That is, which Bernoulli distribution generated these data?
- We could estimate θ \theta θ as the proportion of the flips that are Heads. We will see shortly that this is a principled Bayesian approach. Let y i = 1 y_i=1 yi=1if flip i i i was Heads, and y i = 0 y_i=0 yi=0 otherwise. Let m H = Σ i = 1 m y i m_H=\Sigma_{i=1}^my_i mH=Σi=1myi be the number of heads in m m m tosses. Then the likelihood model is p ( y ∣ θ ) = θ m H ( 1 − θ ) m − m H p(y|\theta)=\theta ^{m_H}(1-\theta)^{m-m_H} p(y∣θ)=θmH(1−θ)m−mH
这里补充一点大数定律和中心极限定律的知识:
大数定律:在随机事件的大量重复出现中,往往呈现几乎必然的规律。在试验不变的条件下,重复试验多次,随机事件的概率近似于它出现的频率。这是概率论的重要基石。
中心极限定律:在一定条件下,大量独立随机变量的平均数是以正态分布为极限的。
最大似然估计与最小二乘估计的联系:如果模型假设为
y
=
α
+
β
x
+
ϵ
y=\alpha+\beta x+\epsilon
y=α+βx+ϵ其中
ϵ
服
从
N
(
0
,
σ
2
)
\epsilon服从N(0, \sigma^2)
ϵ服从N(0,σ2),则
y
i
服
从
N
(
α
+
β
x
i
,
σ
2
)
y_i服从N(\alpha+\beta x_i, \sigma^2)
yi服从N(α+βxi,σ2),则可以得到最大似然估计:
L
=
(
2
π
σ
2
)
−
n
/
2
e
x
p
[
−
1
2
σ
2
Σ
i
=
1
n
(
y
i
−
α
−
β
i
x
)
2
]
L=(2\pi\sigma^2)^{-n/2}exp[\frac{-1}{2\sigma^2}\Sigma_{i=1}^n(y_i-\alpha-\beta _ix)^2]
L=(2πσ2)−n/2exp[2σ2−1Σi=1n(yi−α−βix)2]
求解可得:
α
=
y
ˉ
−
β
x
ˉ
\alpha =\bar y - \beta\bar x
α=yˉ−βxˉ
β
=
Σ
y
i
(
x
i
−
x
ˉ
)
Σ
(
x
i
−
x
ˉ
)
2
\beta=\frac{\Sigma y_i(x_i-\bar x)}{\Sigma (x_i-\bar x)^2}
β=Σ(xi−xˉ)2Σyi(xi−xˉ)
推到这里你会惊奇的发现,这里的结果和不加权的最小二乘估计的结果是一样的,神奇不。