mixture
mixture, function
def nosort process mixture(r: ranvar): ranvar
def nosort process mixture(r: ranvar, w: number): ranvar
def pure mixture(r1: ranvar, p1: number, r2: ranvar): ranvar
def pure mixture(r1: ranvar, p1: number, r2: ranvar, p2: number, r3: ranvar): ranvar
def pure mixture(r1: ranvar, p1: number, r2: ranvar, p2: number,
r3: ranvar, p3: number, r4: ranvar): ranvar
Returns a mixture of ranvars, either as an aggregator or as a weighted pure function.
r: ranvars to mix in a group.w: non-negative weight for each ranvar in a group.p1,p2,p3: weights for the pure overloads.
Examples
table T = with
[| as Group, as Mean |]
[| "A", 1 |]
[| "A", 3 |]
[| "B", 2 |]
T.R = poisson(T.Mean)
table G[g] = by T.Group
G.Mix = mixture(T.R)
show table "Mixture" with
g as "Group"
mean(G.Mix) as "Mean"
This produces the following table:
| Group | Mean |
|---|---|
| A | 1.999662 |
| B | 1.999924 |
r1 = poisson(1)
r2 = poisson(3)
show table "Weighted" with
mean(mixture(r1, 0.25, r2)) as "Mean"
This produces the following table:
| Mean |
|---|
| 2.499748 |
Remarks
Weights must be non-negative. Empty groups return dirac(0).