ranvar.buckets

ranvar.buckets, function

def nosort process ranvar.buckets(weight: number, low: number, high: number): ranvar

Builds a ranvar by aggregating weighted buckets. Each bucket spans the inclusive segment [low, high].

Example

table T = with
  [| as W, as A, as B, as G |]
  [| 0.4, 0, 1, "a" |]
  [| 0.6, 2, 3, "a" |]
  [| 1.0, 0, 2, "b" |]

table G[gdim] = by T.G

show table "Bucket means" with
  gdim
  mean(ranvar.buckets(T.W, T.A, T.B)) as "Mean"
  group by gdim

This outputs the following table:

gdim Mean
a 1.7
b 1

Remarks

Within each group, weights are expected to be non-negative. If their sum is zero, the result is dirac(0). Buckets must not overlap.

See also

User Contributed Notes
0 notes + add a note