Add isNormalized to Continuous
This commit is contained in:
parent
e47deb8433
commit
350e420884
|
@ -14,9 +14,7 @@ describe("Converting from a sample set distribution", () => {
|
|||
integralSumCache: None,
|
||||
integralCache: None,
|
||||
}
|
||||
let fullShape = Continuous.updateIntegralCache(Some(Continuous.T.integral(c)), c)
|
||||
let endY = Continuous.T.integralEndY(fullShape)
|
||||
|
||||
expect(endY)->toBeCloseTo(1.)
|
||||
expect(Continuous.isNormalized(c))->toBe(true)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -269,6 +269,11 @@ module T = Dist({
|
|||
XYShape.Analysis.getVarianceDangerously(t, mean, Analysis.getMeanOfSquares)
|
||||
})
|
||||
|
||||
let isNormalized = (t: t): bool => {
|
||||
let areaUnderIntegral = t |> updateIntegralCache(Some(T.integral(t))) |> T.integralEndY
|
||||
areaUnderIntegral -. 1. < 1e-7
|
||||
}
|
||||
|
||||
let downsampleEquallyOverX = (length, t): t =>
|
||||
t |> shapeMap(XYShape.XsConversion.proportionEquallyOverX(length))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user