File: gamma_shape.py

package info (click to toggle)
python-bayespy 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,132 kB
  • sloc: python: 22,402; makefile: 156
file content (26 lines) | stat: -rw-r--r-- 484 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


from bayespy import nodes
from bayespy.inference import VB


def run():

    a = nodes.GammaShape(name='a')
    b = nodes.Gamma(1e-5, 1e-5, name='b')

    tau = nodes.Gamma(a, b, plates=(1000,), name='tau')
    tau.observe(nodes.Gamma(10, 20, plates=(1000,)).random())

    Q = VB(tau, a, b)

    Q.update(repeat=1000)

    print("True gamma parameters:", 10.0, 20.0)
    print("Estimated parameters from 1000 samples:", a.u[0], b.u[0])


if __name__ == "__main__":

    
    run()