2022-01-29 22:43:08 +00:00
|
|
|
module type dist = {
|
|
|
|
type t
|
|
|
|
type integral
|
|
|
|
let minX: t => float
|
|
|
|
let maxX: t => float
|
|
|
|
let mapY: (
|
|
|
|
~integralSumCacheFn: float => option<float>=?,
|
2022-02-15 20:47:33 +00:00
|
|
|
~integralCacheFn: PointSetTypes.continuousShape => option<PointSetTypes.continuousShape>=?,
|
2022-01-29 22:43:08 +00:00
|
|
|
~fn: float => float,
|
|
|
|
t,
|
|
|
|
) => t
|
2022-04-22 20:27:17 +00:00
|
|
|
let mapYResult: (
|
|
|
|
~integralSumCacheFn: float => option<float>=?,
|
|
|
|
~integralCacheFn: PointSetTypes.continuousShape => option<PointSetTypes.continuousShape>=?,
|
|
|
|
~fn: float => result<float, 'e>,
|
|
|
|
t,
|
|
|
|
) => result<t, 'e>
|
2022-02-15 20:47:33 +00:00
|
|
|
let xToY: (float, t) => PointSetTypes.mixedPoint
|
2022-02-15 22:43:31 +00:00
|
|
|
let toPointSetDist: t => PointSetTypes.pointSetDist
|
2022-02-15 20:47:33 +00:00
|
|
|
let toContinuous: t => option<PointSetTypes.continuousShape>
|
|
|
|
let toDiscrete: t => option<PointSetTypes.discreteShape>
|
2022-01-29 22:43:08 +00:00
|
|
|
let normalize: t => t
|
|
|
|
let toDiscreteProbabilityMassFraction: t => float
|
|
|
|
let downsample: (int, t) => t
|
|
|
|
let truncate: (option<float>, option<float>, t) => t
|
|
|
|
|
2022-02-15 20:47:33 +00:00
|
|
|
let updateIntegralCache: (option<PointSetTypes.continuousShape>, t) => t
|
2022-01-29 22:43:08 +00:00
|
|
|
|
|
|
|
let integral: t => integral
|
|
|
|
let integralEndY: t => float
|
|
|
|
let integralXtoY: (float, t) => float
|
|
|
|
let integralYtoX: (float, t) => float
|
|
|
|
|
|
|
|
let mean: t => float
|
|
|
|
let variance: t => float
|
2022-05-04 17:02:58 +00:00
|
|
|
let klDivergence: (t, t) => result<float, Operation.Error.t>
|
2022-01-29 22:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module Dist = (T: dist) => {
|
|
|
|
type t = T.t
|
|
|
|
type integral = T.integral
|
|
|
|
let minX = T.minX
|
|
|
|
let maxX = T.maxX
|
|
|
|
let integral = T.integral
|
|
|
|
let xTotalRange = (t: t) => maxX(t) -. minX(t)
|
|
|
|
let mapY = T.mapY
|
2022-04-22 20:27:17 +00:00
|
|
|
let mapYResult = T.mapYResult
|
2022-01-29 22:43:08 +00:00
|
|
|
let xToY = T.xToY
|
|
|
|
let downsample = T.downsample
|
2022-02-15 22:43:31 +00:00
|
|
|
let toPointSetDist = T.toPointSetDist
|
2022-01-29 22:43:08 +00:00
|
|
|
let toDiscreteProbabilityMassFraction = T.toDiscreteProbabilityMassFraction
|
|
|
|
let toContinuous = T.toContinuous
|
|
|
|
let toDiscrete = T.toDiscrete
|
|
|
|
let normalize = T.normalize
|
|
|
|
let truncate = T.truncate
|
|
|
|
let mean = T.mean
|
|
|
|
let variance = T.variance
|
2022-04-15 17:58:00 +00:00
|
|
|
let integralEndY = T.integralEndY
|
2022-05-04 17:02:58 +00:00
|
|
|
let klDivergence = T.klDivergence
|
2022-01-29 22:43:08 +00:00
|
|
|
|
|
|
|
let updateIntegralCache = T.updateIntegralCache
|
|
|
|
|
|
|
|
module Integral = {
|
|
|
|
type t = T.integral
|
|
|
|
let get = T.integral
|
|
|
|
let xToY = T.integralXtoY
|
|
|
|
let yToX = T.integralYtoX
|
|
|
|
let sum = T.integralEndY
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module Common = {
|
|
|
|
let combineIntegralSums = (
|
|
|
|
combineFn: (float, float) => option<float>,
|
|
|
|
t1IntegralSumCache: option<float>,
|
|
|
|
t2IntegralSumCache: option<float>,
|
|
|
|
) =>
|
|
|
|
switch (t1IntegralSumCache, t2IntegralSumCache) {
|
|
|
|
| (None, _)
|
|
|
|
| (_, None) =>
|
|
|
|
None
|
|
|
|
| (Some(s1), Some(s2)) => combineFn(s1, s2)
|
|
|
|
}
|
|
|
|
|
|
|
|
let combineIntegrals = (
|
|
|
|
combineFn: (
|
2022-02-15 20:47:33 +00:00
|
|
|
PointSetTypes.continuousShape,
|
|
|
|
PointSetTypes.continuousShape,
|
|
|
|
) => option<PointSetTypes.continuousShape>,
|
|
|
|
t1IntegralCache: option<PointSetTypes.continuousShape>,
|
|
|
|
t2IntegralCache: option<PointSetTypes.continuousShape>,
|
2022-01-29 22:43:08 +00:00
|
|
|
) =>
|
|
|
|
switch (t1IntegralCache, t2IntegralCache) {
|
|
|
|
| (None, _)
|
|
|
|
| (_, None) =>
|
|
|
|
None
|
|
|
|
| (Some(s1), Some(s2)) => combineFn(s1, s2)
|
|
|
|
}
|
|
|
|
}
|