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

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

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

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

利用特征函数(Characteristic Function)Wiki-Characteristic Function,我们知道 X ∼ N ( μ , σ 2 ) X\sim N(\mu, \sigma^2) X∼N(μ,σ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μt−2σ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μt−2σ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位置编码中,对服从高斯分布正弦函数的数学期望计算:

python 复制代码
# 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))
相关推荐
Elastic 中国社区官方博客1 天前
Elasticsearch:使用 Agent Builder 的 A2A 实现 - 开发者的圣诞颂歌
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
chools1 天前
【AI超级智能体】快速搞懂工具调用Tool Calling 和 MCP协议
java·人工智能·学习·ai
郝学胜-神的一滴1 天前
深度学习必学:PyTorch 神经网络参数初始化全攻略(原理 + 代码 + 选择指南)
人工智能·pytorch·python·深度学习·神经网络·机器学习
leobertlan1 天前
好玩系列:用20元实现快乐保存器
android·人工智能·算法
笨笨饿1 天前
#58_万能函数的构造方法:ReLU函数
数据结构·人工智能·stm32·单片机·硬件工程·学习方法
jr-create(•̀⌄•́)1 天前
从零开始:手动实现神经网络识别手写数字(完整代码讲解)
人工智能·深度学习·神经网络
冬奇Lab1 天前
一天一个开源项目(第78篇):MiroFish - 用群体智能引擎预测未来
人工智能·开源·资讯
冬奇Lab1 天前
你的 Skill 真的好用吗?来自OpenAI的 Eval 系统化验证 Agent 技能方法论
人工智能·openai
数智工坊1 天前
Transformer 全套逻辑:公式推导 + 原理解剖 + 逐行精读 - 划时代封神之作!
人工智能·深度学习·transformer
GreenTea1 天前
AI 时代,工程师的不可替代性在哪里
前端·人工智能·后端