The OpenD Programming Language

statDensity2D

Calculate kernel density for given x and y data

statDensity2D
(
AES
)
()

Parameters

aesRange AES

Data that the histogram will be based on

Return Value

Type: auto

Range of ranges that holds polygons for the kernel

Examples

import std.algorithm : map;
import std.array : array;
import std.random : uniform;
import std.range : iota, walkLength;

import ggplotd.aes : Aes;
auto xs = iota(0,500,1).map!((x) => uniform(0.0,5)+uniform(0.0,5))
    .array;
auto ys = iota(0,500,1).map!((y) => uniform(1.0,1.5)+uniform(1.0,1.5))
    .array;
auto aes = Aes!(typeof(xs), "x", typeof(ys), "y")( xs, ys);

auto sD = statDensity2D( aes );
assertGreaterThan( sD.walkLength, 1150 );
assertLessThan( sD.walkLength, 1450 );
assertEqual( sD.front.walkLength, 3 );

// One value
xs = [1];
ys = [2];
aes = Aes!(typeof(xs), "x", typeof(ys), "y")( xs, ys);

sD = statDensity2D( aes );
assertGreaterThan(sD.walkLength, 0);

Meta