Esempio n. 1
0
def make_mixture(meta_pmf, name='mix'):
    mix = Pmf(name=name)
    for pmf, p1 in meta_pmf.iter_items():
        for x, p2 in pmf.iter_items():
            mix.incr(x, p1 * p2)
    mix.normalize()
    return mix
Esempio n. 2
0
 def conditional(self, i, j, val, name=''):
     pmf = Pmf(name=name)
     for vs, prob in self.iter_items():
         if vs[j] != val:
             continue
         pmf.incr(vs[i], prob)
     pmf.normalize()
     return pmf
Esempio n. 3
0
def coef_variation(suite):
    pmf = Pmf()
    for (mu, sigma), p in suite.iter_items():
        pmf.incr(sigma/mu, p)
    return pmf
Esempio n. 4
0
 def marginal(self, i, name=''):
     pmf = Pmf(name=name)
     for vs, prob in self.iter_items():
         pmf.incr(vs[i], prob)
     return pmf
Esempio n. 5
0
def make_pmf_from_list(values, name=''):
    pmf = Pmf(name=name)
    for value in values:
        pmf.incr(value)
    pmf.normalize()
    return pmf
Esempio n. 6
0
 def reverse_scale(self, pmf):
     reverse = Pmf()
     for value, prob in pmf.iter_items():
         raw = self.reverse(value)
         reverse.incr(raw, prob)
     return reverse