3
class VarianceFunction:
5
Variance function that relates the variance of a random variable
6
to its mean. Defaults to 1.
10
def __call__(self, mu):
11
return N.ones(mu.shape, N.float64)
13
constant = VarianceFunction()
20
V(mu) = fabs(mu)**power
23
def __init__(self, power=1.):
26
def __call__(self, mu):
27
return N.power(N.fabs(mu), self.power)
32
Binomial variance function
34
p = mu / n; V(mu) = p * (1 - p) * n
39
def __init__(self, n=1):
43
return N.clip(p, Binomial.tol, 1 - Binomial.tol)
45
def __call__(self, mu):
46
p = self.clean(mu / self.n)
47
return p * (1 - p) * self.n
50
mu_squared = Power(power=2)
51
mu_cubed = Power(power=3)