Python I';我使用PyMc收到一条我不知道的错误消息';我不明白

Python I';我使用PyMc收到一条我不知道的错误消息';我不明白,python,pymc,Python,Pymc,以下是我的设置和错误消息: 创建假数据 构建模型: 下面是错误: --------------------------------------------------------------------------- 错误回溯(最近一次呼叫上次) 在() 1对于t及时: 2数据=屏蔽数据[time-1] ---->3 y[t-1]=β('y%s'%str(t-1),值=掩蔽数据[t-1],α=σ,β=φ模型,观测值=真) /usr/lib/pymodules/python2.7/pymc/dis

以下是我的设置和错误消息:

创建假数据 构建模型: 下面是错误:
---------------------------------------------------------------------------
错误回溯(最近一次呼叫上次)
在()
1对于t及时:
2数据=屏蔽数据[time-1]
---->3 y[t-1]=β('y%s'%str(t-1),值=掩蔽数据[t-1],α=σ,β=φ模型,观测值=真)
/usr/lib/pymodules/python2.7/pymc/distributions.pyc在_________(self,*args,**kwds)中
268 random=调试_包装(随机)
269其他:
-->270随机。初始(self,logp=logp,random=random,logp\u partial\u gradients=logp\u partial\u gradients,dtype=dtype,**arg\u dict\u out)
271
272新的\u类。\u名称\u=名称
/usr/lib/pymodules/python2.7/pymc/PyMCObjects.pyc in_uuuuuinit_uuuu(self、logp、doc、name、parent、random、trace、value、dtype、rseed、observed、cache_depth、plot、verbose、isdata、check_logp、logp_partial_gradient)
703数据类型=数据类型,
704绘图=绘图,
-->705详细=详细)
706
707#self._logp.force_compute()
/usr/lib/pymodules/python2.7/pymc/Node.pyc在uuuu init_uuu中(self、doc、name、parent、cache_深度、trace、dtype、plot、verbose)
199 self.extended_children=set()
200
-->201节点。\uuuu init\uuuuuu(self,doc,name,parent,cache\u depth,verbose=verbose)
202
203如果self.dtype为无:
/usr/lib/pymodules/python2.7/pymc/Node.pyc in_u__________________(self、doc、name、parent、cache_depth、verbose)
117
118#初始化
-->119 self.parents=父母
120
121 def_获得父母(自我):
/usr/lib/pymodules/python2.7/pymc/Node.pyc in_set_parents(self,new_parents)
138
139#获取新的惰性函数
-->140 self.gen_lazy_函数()
141
142 parents=property(_get_parents,_set_parents,doc=“Self's parents:Self声明中引用的变量”)
/gen_lazy_函数(self)中的usr/lib/pymodules/python2.7/pymc/PyMCObjects.pyc
743 ultimate_args=self.extended_parents|set([self]),
744缓存深度=自。\缓存深度)
-->745自我记录力计算()
746
747
pymc.LazyFunction.LazyFunction.force_compute中的LazyFunction.pyx(pymc/LazyFunction.c:2411)()
/包装器中的usr/lib/pymodules/python2.7/pymc/distributions.pyc(**kwds)
2770 def包装(**kwds):
2771值=kwds.pop('value')
->2772返回f(值,**科威特第纳尔)
2773
2774如果参数为无:
/类beta_(x,alpha,beta)中的usr/lib/pymodules/python2.7/pymc/distributions.pyc
708#除零概率外:
709#返回-np.Inf
-->710返回飞片beta_-like(x,alpha,beta)
711
712 beta_grad_like={'value':flib.beta_grad_x,
错误:(nb==1 | | nb==len(x))对于隐藏的nb:beta_like:nb=99失败

这可能是Stack Overflow社区最好的答案。请不要告诉我们我们需要快速帮助你。这是令人讨厌的。你要求陌生人自愿免费帮助你。此外,说你需要快速不会影响别人何时能提供答案。
  a=0.5
  b=-0.01
  s=1

ydata=np.empty((100, 100))

n, m =np.shape(ydata)
for t in range(1, n+1):
    phi_prob=s*((t**(-b))/a-1)
    process=Beta('process_%s' % str(t-1), value=0.5, alpha=s, beta=phi_prob)
    for i in range(m):
        ydata[t-1][i]=process.random()
#giving it some missing values, as that is part of the real problem I try to solve

for i, j in zip([choice(range(n)) for i in range(4*n)], [choice(range(m)) for j in range(4*m)]):
    ydata[i][j]=None

y_df=pd.DataFrame(ydata)
ydata=y_df.fillna(98) #making sure that it's all numeric, or else I get an error that I do understand
masked_data = np.ma.masked_equal(np.array(ydata), value=98)
alpha=Beta("alpha", 1, 1)
time=np.arange(1, len(masked_data)+1)

@pymc.stochastic(observed=False)
def beta(value=-0.01):
    if (value >=0 or value <-0.5):
        return -np.inf #the constraint that beta must be between -0.5 and 0: note that log(0)=-inf 
    return -1.5 * np.log(1 + value ** 2)

@pymc.stochastic(observed=False)
def sigma(value=1):
    return -np.log(abs(value))

# Define phi as a deterministic function of alpha, beta and time
@pymc.deterministic
def phi_model(t=np.arange(1, 100), alpha=alpha, beta=beta, sigma=sigma):
    return sigma*((t**(-beta))/alpha-1)

y=np.empty(len(time), dtype=object) #numpy.empty(N, dtype=object)
for t in time:
    data=masked_data[time-1]
    y[t-1] = Beta('y %s' % str(t-1), value=masked_data[t-1], alpha=sigma, beta=phi_model, observed=True)
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-412-a64e9ce685cf> in <module>()
      1 for t in time:
      2     data=masked_data[time-1]
----> 3     y[t-1] = Beta('y %s' % str(t-1), value=masked_data[t-1], alpha=sigma, beta=phi_model, observed=True)

/usr/lib/pymodules/python2.7/pymc/distributions.pyc in __init__(self, *args, **kwds)
    268                 random = debug_wrapper(random)
    269             else:
--> 270                 Stochastic.__init__(self, logp=logp, random=random, logp_partial_gradients = logp_partial_gradients, dtype=dtype, **arg_dict_out)
    271 
    272     new_class.__name__ = name

/usr/lib/pymodules/python2.7/pymc/PyMCObjects.pyc in __init__(self, logp, doc, name, parents, random, trace, value, dtype, rseed, observed, cache_depth, plot, verbose, isdata, check_logp, logp_partial_gradients)
    703                         dtype=dtype,
    704                         plot=plot,
--> 705                         verbose=verbose)
    706 
    707         # self._logp.force_compute()

/usr/lib/pymodules/python2.7/pymc/Node.pyc in __init__(self, doc, name, parents, cache_depth, trace, dtype, plot, verbose)
    199         self.extended_children = set()
    200 
--> 201         Node.__init__(self, doc, name, parents, cache_depth, verbose=verbose)
    202 
    203         if self.dtype is None:

/usr/lib/pymodules/python2.7/pymc/Node.pyc in __init__(self, doc, name, parents, cache_depth, verbose)
    117 
    118         # Initialize
--> 119         self.parents = parents
    120 
    121     def _get_parents(self):

/usr/lib/pymodules/python2.7/pymc/Node.pyc in _set_parents(self, new_parents)
    138 
    139         # Get new lazy function
--> 140         self.gen_lazy_function()
    141 
    142     parents = property(_get_parents, _set_parents, doc="Self's parents: the variables referred to in self's declaration.")

/usr/lib/pymodules/python2.7/pymc/PyMCObjects.pyc in gen_lazy_function(self)
    743                                     ultimate_args = self.extended_parents | set([self]),
    744                                     cache_depth = self._cache_depth)
--> 745         self._logp.force_compute()
    746 
    747 

LazyFunction.pyx in pymc.LazyFunction.LazyFunction.force_compute (pymc/LazyFunction.c:2411)()

/usr/lib/pymodules/python2.7/pymc/distributions.pyc in wrapper(**kwds)
   2770     def wrapper(**kwds):
   2771         value = kwds.pop('value')
-> 2772         return f(value, **kwds)
   2773 
   2774     if arguments is None:

/usr/lib/pymodules/python2.7/pymc/distributions.pyc in beta_like(x, alpha, beta)
    708     # except ZeroProbability:
    709     #     return -np.Inf
--> 710     return flib.beta_like(x, alpha, beta)
    711 
    712 beta_grad_like = {'value' : flib.beta_grad_x,

error: (nb==1 || nb==len(x)) failed for hidden nb: beta_like:nb=99