2014-01-16 67 views
0

我正在通過迴歸示例探索PyMC3。我從一條線開始,然後轉向二次方,並且效果很好。當我嘗試移動到一個正弦函數時,它的內部是隨機變量,但事情變得很糟糕。PyMC3中的正弦迴歸

這裏是我的PyMC3代碼:

import pymc as pm 
import numpy as np 

trace = None 
with pm.Model() as model: 
    alpha = pm.Normal('alpha', mu=0, sd=20) 
    beta = pm.Normal('beta', mu=0, sd=20) 
    mewmew = pm.Normal('mewmew', mu=0, sd=20) 
    sigma = pm.Uniform('sigma', lower=0, upper=20) 

    y_est = alpha + beta * numpy.sin(mewmew * x) 

    likelihood = pm.Normal('y', mu=y_est, sd=sigma, observed=y) 

    start = pm.find_MAP() 
    step = pm.NUTS(state=start) 
    trace = pm.sample(2000, step, start=start, progressbar=False) 

    pm.traceplot(trace); 

我得到這個錯誤:

--------------------------------------------------------------------------- 
AttributeError       Traceback (most recent call last) 
<ipython-input-139-60a584151c07> in <module>() 
     9  sigma = pm.Uniform('sigma', lower=0, upper=20) 
    10 
---> 11  y_est = alpha + beta * numpy.sin(mewmew * x) 
    12 
    13  likelihood = pm.Normal('y', mu=y_est, sd=sigma, observed=y) 

AttributeError: sin 

提前感謝!

回答