将司仪与高斯先验一起使用

编程入门 行业动态 更新时间:2024-10-14 14:16:12
本文介绍了将司仪与高斯先验一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试在使用司仪之前先使用高斯,似乎无法完全弄清楚.基本上我想替换

I'm trying to use a gaussian prior using emcee and can't seem to fully figure it out. Basically I want to replace

def lnprior(theta): a, b, c = theta if 1.0 < a < 2.0 and 1.0 < b < 2.0 and 1.0 < c < 2.0: return 0.0 return -np.inf

具有将从具有mu和sigma的高斯分布中采样"a"的值.我该怎么做?这样吗?

with something that would sample 'a' from a gaussian distribution with a mu and sigma. How would I do that? Like this?

def lnprior(theta): a, b, c = theta if 1.0 < b < 2.0 and 1.0 < c < 2.0: return 0.0 if 0<a<20: mu=10 sigma=1 s=np.random.normal(mu, sigma) return s return -np.inf

那似乎不太正确吗?

推荐答案

以下方法似乎对我有用

def lnprior(theta): a, b, c = theta #flat priors on b, c if not 1.0 < b < 2.0 and 1.0 < c < 2.0: return -np.inf #gaussian prior on a mu = 10 sigma = 1 return np.log(1.0/(np.sqrt(2*np.pi)*sigma))-0.5*(a-mu)**2/sigma**2

更多推荐

将司仪与高斯先验一起使用

本文发布于:2023-11-29 20:08:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647500.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:司仪   高斯

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!