Module Bentov
type bin
=
{
center : float;
the center of the bin
count : int;
the number of values in the bin
}
bin
represents one of the bins in a 1D histogram. The bin is centered incenter
and its mass iscount
, half of which is on either side ofcenter
.
val bins : histogram -> bin list
bins h
returns the list of bins, sorted by the bin center, comprising histogramh
val num_bins : histogram -> int
num_bins h
returns the size of the histogramh
in terms of the number of bins; equivalent toList.length (bins h)
val max_bins : histogram -> int
max_bins h
returns the maximum number of bins of this histogram; when the number of unique values added to the histogram exceeds thismax_bins h
,h
becomes an approximation.
val total_count : histogram -> int
total_count h
returns the number of values added to histogramh
val range : histogram -> (float * float) option
range h
returns the minimum and maximum values seen in the construction of histogram h, orNone
if no values have yet been added
val create : int -> histogram
create max_bins
creates a histogram with up tomax_bins
bins
val add : float -> histogram -> histogram
add v h
adds a value tov
to histogramh
, returning the updated histogram
val addc : float -> int -> histogram -> histogram
addc v c h
adds a value tov
to histogramh
with countc
, returning the updated histogram. It is equivalent to callingadd v h
c
times.
val merge : histogram list -> int -> histogram
merge h_list max_bins
creates a new histogram from the histograms inh_list
, whose size is no bigger thanmax_bins
val sum : histogram -> float -> float
sum hist b
returns an estimate of the number of points in the interval[−infinity,b]
. For an estimate to be feasible,b
must be strictly between the left and right bin centers. Otherwise,Not_found
is raised.
val uniform : histogram -> int -> (int * float) list
uniform hist num_intervals
returns estimates of the quantiles of the distribution represented by histogramhist
. The quantiles are associated with the boundaries ofnum_interval
intervals, in ascending order. For example,uniform hist 4
returns an estimate of the interquartile range, consisting of the 25-th percentile, 50-th percentile (median) and 75-th percentile. (The minimum and maximum of the histogram are seperately available through the functionrange
.uniform
can return fewer than the desired quantiles in histograms that have extremely dense regions. RaisesEmpty
if the histogram has not beenadd
'd any data.
val mean : histogram -> float
mean hist
returns an estimate of the mean of the distribution represented byhist
. RaisesEmpty
if the histogram has not beenadd
'd any data.
val mean_stdev : histogram -> float * float
mean_stdev hist
returns estimates of the mean and standard deviation of the distribution represented bhhist
. RaisesEmpty
if the histogram has not beenadd
'd any data.