kandy 0.6.0 Help

statDensity

The statDensity function creates a new plotting context with new dataset which contains the "density" statistic calculated on sample of a single numeric variable x. It approximates the Probability Density Function (PDF) of this sample. "Density" statistic samples this function points It's weighted, it means the counted density depends on observation weights.

Arguments

x

Required

Iterable Column String

The x argument is used to provide the sample (or its x-part) on which the statistic is computed.

weights

Optional

Iterable Column String

The weights argument is used to provide the weights of sample elements.

n

Optional

Double

The n argument is used to specify the number of sampled points.

trim

Optional

Boolean

The n argument is used to specify the range of density calculation for grouped data: if false, each density is computed on the full range of the data, if true, each density is computed over the range of that group (only for grouped inputs).

adjust

Optional

Double

The adjust argument is used to adjust the value of bandwidth by multiplying it; changes how smooth the frequency curve is.

kernel

Optional

Kernel

The kernel argument is used to adjust the kernel used to calculate the density function.

  • Kernel.GAUSSIAN;

  • Kernel.RECTANGULAR;

  • Kernel.TRIANGULAR;

  • Kernel.BIWEIGHT;

  • Kernel.EPANECHNIKOV;

  • Kernel.OPTCOSINE.

fullScanMax

Optional

Int

The adjust argument is used to specify the maximum size of data to use density computation with "full scan". For bigger data, less accurate but more efficient density computation is applied.

bandWidth

Optional

BandWidth

The bandWidth argument is used to adjust the method (or exact value) of bandwidth:

  • BandWidth.Method.NRD;

  • BandWidth.Method.NRD0;

  • BandWidth.value(value: Double).

Statistic properties

In this context, there are the following statistical properties that can be used to create mappings, customize tooltips, etc.

Stat.x

Column<Double>

The Stat.x contains points x-coordinate.

Stat.density

Column<Double>

The Stat.density contains estimated density in points.

Stat.densityWeighted

Column<Double>

The Stat.densityWeighted contains weighted density. Without weights its values matches Stat.density values.

Stat.scaled

Column<Double>

The Stat.count contains estimated density scaled to maximin of 1.0..

Stat.scaledWeighted

Column<Double>

The Stat.countWeighted contains weighted scaled density. Without weights its values matches Stat.scaled values.

Last modified: 13 May 2024