OpenBI Docs Buy

DENSITY OpenBI

A distribution's density curve as a table: a Gaussian kernel, as R's density.

Group: Statistics. OpenBI’s own: DAX has no function of this name.

Syntax

DENSITY ( <table>, <value> [, <points>] [, <bandwidth>] )
ParameterTypeDescription
tableTableThe rows whose values make the curve.
valueExpression
evaluated for each row
The number worked out for each row.
pointsWhole number
optional
How many points of the curve to return, 2 to 100,000; 512 when left out.
bandwidthNumber
optional
The width of each value's bell, in the value's units. Left out or 0, it is chosen from the values.

Returns

Table. A row a point: Value and Density, evenly spaced from three bandwidths below the smallest value to three above the largest.

Remarks

  • Each value adds a small normal bell centred on itself, as wide as the bandwidth; the curve is the mean of the bells, so its area is 1.
  • The bandwidth chosen by default is R's bw.nrd0: 0.9 × the smaller of the standard deviation and IQR / 1.34, × n^(−1/5).
  • The densities are the exact sums of the bells. R's density() works on a binned grid, so its figures can differ a little in the later digits.
  • A larger bandwidth makes a smoother curve; a smaller one follows the values more closely. Blank results are left out.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

Seven points of the curve of delivery times

The late delivery at 45 minutes makes a second, smaller bump.

EVALUATE
VAR Times =
    DATATABLE (
        "Minutes", INTEGER,
        { { 12 }, { 14 }, { 15 }, { 15 }, { 16 }, { 18 }, { 19 }, { 21 }, { 22 }, { 45 } }
    )
RETURN
    DENSITY ( Times, [Minutes], 7 )
ValueDensity
5.007674204827710.000203923977017766
12.83844946988510.0622893752507435
20.66922473494260.0579962865514964
28.50.000451943384753828
36.33077526505741.69556701000497e-05
44.16155053011490.0160438872625909
51.99232579517230.000190144819124327

A bandwidth of your own

EVALUATE
VAR Times =
    DATATABLE (
        "Minutes", INTEGER,
        { { 12 }, { 14 }, { 15 }, { 15 }, { 16 }, { 18 }, { 19 }, { 21 }, { 22 }, { 45 } }
    )
RETURN
    DENSITY ( Times, [Minutes], 5, 2 )
ValueDensity
60.000229956959125922
17.250.0803822489367055
28.50.000119354375574755
39.750.000636209079841572
510.0002215924205969

Crates per place, in nine points

EVALUATE
DENSITY ( Places, Places[Crates], 9 )
ValueDensity
-5.786353653902970.000143608850927434
-2.089765240427230.00718806578648315
1.606823173048510.00946821650397828
5.303411586524260.0196265570626128
90.0850985711995334
12.69658841347570.0906419793599923
16.39317682695150.0487974948330588
20.08976524042720.00914679595881913
23.7863536539030.000147819267907715

HISTOGRAM, BOXPLOT, NORM.DIST, STDEVX.S.

Last updated · OpenBI Studio 0.3.74