Mixture weights and mixed-strength coverage ​
This page defines two functions of @agent-nexus/driftbench-stats. The conventions of statistics capabilities hold: the RangeError rules and the accuracy.
Status: built.
mixtureWeights ​
ts
mixtureWeights(
components: number[][],
counts: number[],
options?: { tolerance?: number; maxIterations?: number },
): { weights: number[]; iterations: number; logLikelihood: number }- Definition.
componentsholds m probability vectors over the same c categories (entries in [0, 1], each row summing to 1 within 1e-12).countsholds c counts. The weights are the m non-negative mixture weights, summing to 1, that maximise the multinomial log-likelihoodsum_i counts_i log(sum_j w_j components_j_i). They are found by expectation-maximisation from equal weights, until no weight moves more thantolerance(default 1e-12) ormaxIterations(default 100000) is reached. When the observed shares are a mix of linearly independent components, the result is that mix. A category with count 0 that no component reaches takes no part. - Returns.
weights, the number ofiterations, and thelogLikelihoodat the returned weights. - Throws. A
RangeErrorthat starts withmixtureWeightsand names the argument, for: no component; a component of another length thancounts; an entry outside [0, 1]; a row not summing to 1; a count that is not a non-negative integer; counts that are all 0; a positive count in a category no component can produce. - File.
packages/stats/src/mixture.ts.
mixedStrengthCoverage ​
ts
mixedStrengthCoverage(
rows: number[][],
groups: { axes: number[]; strength: number }[],
levels: number[],
): { groups: { covered: number; required: number; coverage: number }[]; covered: number; required: number; coverage: number }- Definition.
levels[a]is the number of values of axis a; a row gives one value index per axis, from 0. For a group, the required tuples are every choice ofstrengthdistinct axes of the group with every combination of their values. A tuple is covered when some row holds those values on those axes.coverageis covered over required. The totals add the groups: a tuple asked by two groups counts in each. - Returns. The count per group and the totals.
- Throws. A
RangeErrorthat starts withmixedStrengthCoverageand names the argument (rows,groupsorlevels), for: no group; a row of another length thanlevels; a value that is not an integer in [0, levels[a] - 1]; a level count that is not a positive integer; an axis out of range, fractional or repeated in a group; a strength below 1 or above the group's axis count. - File.
packages/stats/src/mixed-strength.ts.