服从正态分布的正弦函数、余弦函数期望

服从正态分布的正弦函数期望

  • 服从正态分布的正弦函数、余弦函数期望。

服从正态分布的正弦函数、余弦函数期望。

如果X服从均值为 μ \mu μ,方差为 σ 2 \sigma^2 σ2的正态分布,计算sin(X)cos(X)的数学期望。

利用特征函数(Characteristic Function)Wiki-Characteristic Function,我们知道 X ∼ N ( μ , σ 2 ) X\sim N(\mu, \sigma^2) XN(μ,σ2)的特征函数为:
φ X ( t ) = E ( e i t X ) = e x p ( i μ t − σ 2 t 2 2 ) = e x p ( − σ 2 t 2 / 2 ) e x p ( i μ t ) \varphi_{X(t)}=E(e^{itX})=exp\left({i\mu t - \dfrac{\sigma^2t^2}{2}}\right)=exp(-\sigma^2t^2/2)exp(i\mu t) φX(t)=E(eitX)=exp(iμt2σ2t2)=exp(σ2t2/2)exp(iμt)
根据欧拉公式:
e i x = cos ⁡ ( x ) + i sin ⁡ ( x ) e^{ix} = \cos(x)+i\sin(x) eix=cos(x)+isin(x)

E ( e i t X ) = e x p ( i μ t − σ 2 t 2 2 ) = e x p ( − σ 2 t 2 / 2 ) e x p ( i μ t ) = e x p ( − σ 2 t 2 / 2 ) [ cos ⁡ ( μ t ) + i sin ⁡ ( μ t ) ] = e x p ( − σ 2 t 2 / 2 ) cos ⁡ ( μ t ) + e x p ( − σ 2 t 2 / 2 ) sin ⁡ ( μ t ) i = R e a l ( E ( e i t X ) ) + i I m ( E ( e i t X ) ) \begin{aligned} E(e^{itX})&=exp\left({i\mu t - \dfrac{\sigma^2t^2}{2}}\right) \\ &=exp(-\sigma^2t^2/2)exp(i\mu t) \\ &=exp(-\sigma^2t^2/2)\left[\cos(\mu t)+i\sin(\mu t)\right]\\ &=exp(-\sigma^2t^2/2)\cos(\mu t) +exp(-\sigma^2t^2/2)\sin(\mu t)i \\ &=Real(E(e^{itX}))+iIm(E(e^{itX})) \end{aligned} E(eitX)=exp(iμt2σ2t2)=exp(σ2t2/2)exp(iμt)=exp(σ2t2/2)[cos(μt)+isin(μt)]=exp(σ2t2/2)cos(μt)+exp(σ2t2/2)sin(μt)i=Real(E(eitX))+iIm(E(eitX))

上述数学期望变为:
E ( e i t X ) = E ( cos ⁡ ( t X ) + i sin ⁡ ( t X ) ) = E ( c o s ( t X ) ) + i E ( s i n ( t X ) ) = R e a l ( E ( e i t X ) ) + i I m ( E ( e i t X ) ) \begin{aligned} E(e^{itX})&=E\left(\cos(tX)+i\sin(tX)\right)\\ &= E(cos(tX)) + iE(sin(tX))\\ &=Real(E(e^{itX}))+iIm(E(e^{itX})) \end{aligned} E(eitX)=E(cos(tX)+isin(tX))=E(cos(tX))+iE(sin(tX))=Real(E(eitX))+iIm(E(eitX))
对比上述的实数部分和虚数部分,得到:
E ( cos ⁡ ( t X ) ) = e x p ( − σ 2 t 2 / 2 ) cos ⁡ ( μ t ) E ( sin ⁡ ( t X ) ) = e x p ( − σ 2 t 2 / 2 ) s i n ( μ t ) E(\cos(tX))=exp(-\sigma^2t^2/2)\cos(\mu t)\\ E(\sin(tX))=exp(-\sigma^2t^2/2)sin(\mu t) E(cos(tX))=exp(σ2t2/2)cos(μt)E(sin(tX))=exp(σ2t2/2)sin(μt)
最后,当t=1的时候:
E ( cos ⁡ ( X ) ) = e x p ( − σ 2 / 2 ) cos ⁡ ( μ ) E ( sin ⁡ ( X ) ) = e x p ( − σ 2 / 2 ) s i n ( μ ) E(\cos(X))=exp(-\sigma^2/2)\cos(\mu)\\ E(\sin(X))=exp(-\sigma^2/2)sin(\mu) E(cos(X))=exp(σ2/2)cos(μ)E(sin(X))=exp(σ2/2)sin(μ)

参考资料:Mean and variance of Y=cos(bX) when X has a Gaussian distribution

应用:IPE位置编码中,对服从高斯分布正弦函数的数学期望计算:

# Code Source: 
# https://github.com/liuyuan-pal/NeRO/blob/3b4d421a646097e7d59557c5ea24f4281ab38ef1/network/field.py#L369-L378
def expected_sin(mean, var):
  """Compute the mean of sin(x), x ~ N(mean, var)."""
  return torch.exp(-0.5 * var) * torch.sin(mean)  # large var -> small value.

def IPE(mean,var,min_deg,max_deg):
    scales = 2**torch.arange(min_deg, max_deg)
    shape = mean.shape[:-1] + (-1,)
    scaled_mean = torch.reshape(mean[..., None, :] * scales[:, None], shape)
    scaled_var = torch.reshape(var[..., None, :] * scales[:, None]**2, shape)
    return expected_sin(torch.concat([scaled_mean, scaled_mean + 0.5 * np.pi], dim=-1), torch.concat([scaled_var] * 2, dim=-1))

你可能感兴趣的:(数学基础知识,机器学习,人工智能,高斯分布)