示例#1
0
def dpmLazy():
  crp = stocPy.crp(1.72)
  sds = {}
  ms = {}
  for i in range(len(obs)):
    c = crp(i)
    if c not in ms:
      sds[c] = math.sqrt(10 * stocPy.stocPrim("invgamma", (1, 0, 10), part=4))
      ms[c] = stocPy.stocPrim("normal", (0, sds[c]), part=4)
    stocPy.normal(ms[c], sds[c], obs[i])
  obsLens.append(len(ms))
示例#2
0
def dpmEager():
  crp = stocPy.crp(1.72, 10)
  sds = {}
  ms = {}
  cs = {}
  for ps in range(len(crp)):
    sds[ps] = math.sqrt(10 * stocPy.stocPrim("invgamma", (1, 0, 10), part=2))
    ms[ps] = stocPy.stocPrim("normal", (0, sds[ps]), part=2)
    for p in crp[ps]:
     cs[p] = ps

  for i in range(len(obs)):
    stocPy.normal(ms[cs[i]], sds[cs[i]], obs[i])
  obsLens.append(len(ms))