KernelDensityEstimation

clock_inference_engine. KernelDensityEstimation

Helper class for the main ClockInference class. Initializes and maintains the kernel density estimation of the user's click-time distribution.

Constructor

new KernelDensityEstimation(time_rotate, past_data)

Source:
Properties:
Name Type Description
index_li Array.<number>

Indexing array of [0,1,...,80] (config.num_divs_click is set at 80 as default in the config file).

x_li Array.<number>

Array defining the locations of the histogram bins around the clock. It is the index_li mapped into discrete seconds between [−T/2, T/2] where T is the rotation period. For example, if config.num_divs_click = 80 and T = 2, then x_li = [-1, ..., 0.975] (list of length 80).

dens_li Array.<number>

Array containing the current histogram, represented as a list of length 80 where each value is the 'height' for that bin.

Z number

The sum of the dens_li, used for normalization.

y_li Array.<number>

Array of timestamps for the most recent click times fed into the KDE.

y_ksigma Array.<number>

Array of the optimal bandwidths used up until so far; y_ksigma[i] is the optimal bandwidth used for kde at the i-th recent press.

damp number

The dampening factor used to weight more recent click times more heavily (default = 0.96).

Parameters:
Name Type Description
time_rotate number

The rotation period in seconds of the clocks.

past_data Object | null

Object containing previous data from the KDE from the prior session, if no past data then null.

Properties
Name Type Description
click_dist Array.<number>

The saved dens_li from the prior session.

Z number

The saved Z from the prior session.

ksigma number

The saved ksigma from the prior session.

ksigma0 number

The saved ksigma0 from the prior session.

Methods

ave_sigma_sq(eff_num_points, yLenEff) → {number}

Description:
  • Helper function for calculating the optimal bandwidth.

Source:
Parameters:
Name Type Description
eff_num_points
yLenEff
Returns:
Type
number

calc_ksigma(eff_num_points, yLenEff) → {number}

Description:
  • Returns the optimal bandwidth for kernel density estimation. When overlapping normal distributions centered around each sample, the optimal bandwidth w is given by w = 1.06σN^(−1/5), where N is the number of samples and σ is the standard deviation of the samples.

Source:
Parameters:
Name Type Description
eff_num_points
yLenEff
Returns:
Type
number

increment_dens(yin, ksigma)

Description:
  • When a new yin (relative click-time) comes in, include that new point in Kernel density estimation.

Source:
Parameters:
Name Type Description
yin number

The new relative click-time in seconds.

ksigma number

The new calculated optimal bandwidth.

initialize_dens()

Description:
  • Initializes the KDE with the past data, if available, or uses an initial normal distribution.

Source: