First pass at file renaming
This commit is contained in:
parent
5a5a3e1ddc
commit
98779c127b
|
@ -6,12 +6,12 @@ let makeTest = (~only=false, str, item1, item2) =>
|
||||||
? Only.test(str, () => expect(item1) -> toEqual(item2))
|
? Only.test(str, () => expect(item1) -> toEqual(item2))
|
||||||
: test(str, () => expect(item1) -> toEqual(item2))
|
: test(str, () => expect(item1) -> toEqual(item2))
|
||||||
|
|
||||||
describe("DistTypes", () =>
|
describe("PointSetTypes", () =>
|
||||||
describe("Domain", () => {
|
describe("Domain", () => {
|
||||||
let makeComplete = (yPoint, expectation) =>
|
let makeComplete = (yPoint, expectation) =>
|
||||||
makeTest(
|
makeTest(
|
||||||
"With input: " ++ Js.Float.toString(yPoint),
|
"With input: " ++ Js.Float.toString(yPoint),
|
||||||
DistTypes.Domain.yPointToSubYPoint(Complete, yPoint),
|
PointSetTypes.Domain.yPointToSubYPoint(Complete, yPoint),
|
||||||
expectation,
|
expectation,
|
||||||
)
|
)
|
||||||
let makeSingle = (direction: [#left | #right], excludingProbabilityMass, yPoint, expectation) =>
|
let makeSingle = (direction: [#left | #right], excludingProbabilityMass, yPoint, expectation) =>
|
||||||
|
@ -19,7 +19,7 @@ describe("DistTypes", () =>
|
||||||
"Excluding: " ++
|
"Excluding: " ++
|
||||||
(Js.Float.toString(excludingProbabilityMass) ++
|
(Js.Float.toString(excludingProbabilityMass) ++
|
||||||
(" and yPoint: " ++ Js.Float.toString(yPoint))),
|
(" and yPoint: " ++ Js.Float.toString(yPoint))),
|
||||||
DistTypes.Domain.yPointToSubYPoint(
|
PointSetTypes.Domain.yPointToSubYPoint(
|
||||||
direction == #left
|
direction == #left
|
||||||
? LeftLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass})
|
? LeftLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass})
|
||||||
: RightLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass}),
|
: RightLimited({xPoint: 3.0, excludingProbabilityMass: excludingProbabilityMass}),
|
||||||
|
@ -28,7 +28,7 @@ describe("DistTypes", () =>
|
||||||
expectation,
|
expectation,
|
||||||
)
|
)
|
||||||
let makeDouble = (domain, yPoint, expectation) =>
|
let makeDouble = (domain, yPoint, expectation) =>
|
||||||
makeTest("Excluding: limits", DistTypes.Domain.yPointToSubYPoint(domain, yPoint), expectation)
|
makeTest("Excluding: limits", PointSetTypes.Domain.yPointToSubYPoint(domain, yPoint), expectation)
|
||||||
|
|
||||||
describe("With Complete Domain", () => {
|
describe("With Complete Domain", () => {
|
||||||
makeComplete(0.0, Some(0.0))
|
makeComplete(0.0, Some(0.0))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
open Jest
|
open Jest
|
||||||
open Expect
|
open Expect
|
||||||
|
|
||||||
let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]}
|
let shape: PointSetTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]}
|
||||||
|
|
||||||
// let makeTest = (~only=false, str, item1, item2) =>
|
// let makeTest = (~only=false, str, item1, item2) =>
|
||||||
// only
|
// only
|
||||||
|
@ -131,7 +131,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]}
|
||||||
|
|
||||||
// describe("Discrete", () => {
|
// describe("Discrete", () => {
|
||||||
// open Discrete;
|
// open Discrete;
|
||||||
// let shape: DistTypes.xyShape = {
|
// let shape: PointSetTypes.xyShape = {
|
||||||
// xs: [|1., 4., 8.|],
|
// xs: [|1., 4., 8.|],
|
||||||
// ys: [|0.3, 0.5, 0.2|],
|
// ys: [|0.3, 0.5, 0.2|],
|
||||||
// };
|
// };
|
||||||
|
@ -209,7 +209,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]}
|
||||||
|
|
||||||
// describe("Mixed", () => {
|
// describe("Mixed", () => {
|
||||||
// open Distributions.Mixed;
|
// open Distributions.Mixed;
|
||||||
// let discreteShape: DistTypes.xyShape = {
|
// let discreteShape: PointSetTypes.xyShape = {
|
||||||
// xs: [|1., 4., 8.|],
|
// xs: [|1., 4., 8.|],
|
||||||
// ys: [|0.3, 0.5, 0.2|],
|
// ys: [|0.3, 0.5, 0.2|],
|
||||||
// };
|
// };
|
||||||
|
@ -309,7 +309,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]}
|
||||||
|
|
||||||
// describe("Distplus", () => {
|
// describe("Distplus", () => {
|
||||||
// open DistPlus;
|
// open DistPlus;
|
||||||
// let discreteShape: DistTypes.xyShape = {
|
// let discreteShape: PointSetTypes.xyShape = {
|
||||||
// xs: [|1., 4., 8.|],
|
// xs: [|1., 4., 8.|],
|
||||||
// ys: [|0.3, 0.5, 0.2|],
|
// ys: [|0.3, 0.5, 0.2|],
|
||||||
// };
|
// };
|
||||||
|
@ -382,7 +382,7 @@ let shape: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [8., 9., 2.]}
|
||||||
// let variance = stdev ** 2.0;
|
// let variance = stdev ** 2.0;
|
||||||
// let numSamples = 10000;
|
// let numSamples = 10000;
|
||||||
// open Distributions.Shape;
|
// open Distributions.Shape;
|
||||||
// let normal: SymbolicTypes.symbolicDist = `Normal({mean, stdev});
|
// let normal: SymbolicDistTypes.symbolicDist = `Normal({mean, stdev});
|
||||||
// let normalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(normal));
|
// let normalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(normal));
|
||||||
// let lognormal = SymbolicDist.Lognormal.fromMeanAndStdev(mean, stdev);
|
// let lognormal = SymbolicDist.Lognormal.fromMeanAndStdev(mean, stdev);
|
||||||
// let lognormalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(lognormal));
|
// let lognormalShape = ExpressionTree.toShape(numSamples, `SymbolicDist(lognormal));
|
||||||
|
|
|
@ -28,7 +28,7 @@ let evalParams: ExpressionTypes.ExpressionTree.evaluationParams = {
|
||||||
evaluateNode: ExpressionTreeEvaluator.toLeaf,
|
evaluateNode: ExpressionTreeEvaluator.toLeaf,
|
||||||
};
|
};
|
||||||
|
|
||||||
let shape1: DistTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]};
|
let shape1: PointSetTypes.xyShape = {xs: [|1., 4., 8.|], ys: [|0.2, 0.4, 0.8|]};
|
||||||
|
|
||||||
describe("XYShapes", () => {
|
describe("XYShapes", () => {
|
||||||
describe("logScorePoint", () => {
|
describe("logScorePoint", () => {
|
||||||
|
|
|
@ -6,14 +6,14 @@ let makeTest = (~only=false, str, item1, item2) =>
|
||||||
? Only.test(str, () => expect(item1) -> toEqual(item2))
|
? Only.test(str, () => expect(item1) -> toEqual(item2))
|
||||||
: test(str, () => expect(item1) -> toEqual(item2))
|
: test(str, () => expect(item1) -> toEqual(item2))
|
||||||
|
|
||||||
let shape1: DistTypes.xyShape = {xs: [1., 4., 8.], ys: [0.2, 0.4, 0.8]}
|
let shape1: PointSetTypes.xyShape = {xs: [1., 4., 8.], ys: [0.2, 0.4, 0.8]}
|
||||||
|
|
||||||
let shape2: DistTypes.xyShape = {
|
let shape2: PointSetTypes.xyShape = {
|
||||||
xs: [1., 5., 10.],
|
xs: [1., 5., 10.],
|
||||||
ys: [0.2, 0.5, 0.8],
|
ys: [0.2, 0.5, 0.8],
|
||||||
}
|
}
|
||||||
|
|
||||||
let shape3: DistTypes.xyShape = {
|
let shape3: PointSetTypes.xyShape = {
|
||||||
xs: [1., 20., 50.],
|
xs: [1., 20., 50.],
|
||||||
ys: [0.2, 0.5, 0.8],
|
ys: [0.2, 0.5, 0.8],
|
||||||
}
|
}
|
||||||
|
|
16
packages/squiggle-lang/dist/index.js
vendored
16
packages/squiggle-lang/dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
packages/squiggle-lang/dist/report.html
vendored
2
packages/squiggle-lang/dist/report.html
vendored
File diff suppressed because one or more lines are too long
|
@ -1,5 +0,0 @@
|
||||||
type t = ExpressionTypes.Program.program
|
|
||||||
|
|
||||||
let last = (r: t) => E.A.last(r) |> E.O.toResult("No rendered lines")
|
|
||||||
// let run = (p:program) => p |> E.A.last |> E.O.fmap(r =>
|
|
||||||
// )
|
|
|
@ -1,3 +1,3 @@
|
||||||
const ProgramEvaluator = require('../distPlus/ProgramEvaluator.gen.js');
|
const ProgramEvaluator = require('../rescript/ProgramEvaluator.gen.js');
|
||||||
|
|
||||||
exports.runMePlease = ProgramEvaluator.runAll
|
exports.runMePlease = ProgramEvaluator.runAll
|
|
@ -60,7 +60,7 @@ module Internals = {
|
||||||
|
|
||||||
type outputs = {
|
type outputs = {
|
||||||
graph: ExpressionTypes.ExpressionTree.node,
|
graph: ExpressionTypes.ExpressionTree.node,
|
||||||
shape: DistTypes.shape,
|
shape: PointSetTypes.shape,
|
||||||
}
|
}
|
||||||
let makeOutputs = (graph, shape): outputs => {graph: graph, shape: shape}
|
let makeOutputs = (graph, shape): outputs => {graph: graph, shape: shape}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ module Internals = {
|
||||||
let inputsToLeaf = (inputs: Inputs.inputs) =>
|
let inputsToLeaf = (inputs: Inputs.inputs) =>
|
||||||
MathJsParser.fromString(inputs.squiggleString) |> E.R.bind(_, g => runProgram(inputs, g))
|
MathJsParser.fromString(inputs.squiggleString) |> E.R.bind(_, g => runProgram(inputs, g))
|
||||||
|
|
||||||
let outputToDistPlus = (inputs: Inputs.inputs, shape: DistTypes.shape) =>
|
let outputToDistPlus = (inputs: Inputs.inputs, shape: PointSetTypes.shape) =>
|
||||||
DistPlus.make(~shape, ~squiggleString=Some(inputs.squiggleString), ())
|
DistPlus.make(~shape, ~squiggleString=Some(inputs.squiggleString), ())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
open ExpressionTypes.ExpressionTree
|
open ExpressionTypes.ExpressionTree
|
||||||
|
// This file exists to manage a dependency cycle. It would be good to refactor later.
|
||||||
|
|
||||||
let rec toString: node => string = x =>
|
let rec toString: node => string = x =>
|
||||||
switch x {
|
switch x {
|
|
@ -18,8 +18,8 @@ type distToFloatOperation = [
|
||||||
module ExpressionTree = {
|
module ExpressionTree = {
|
||||||
type rec hash = array<(string, node)>
|
type rec hash = array<(string, node)>
|
||||||
and node = [
|
and node = [
|
||||||
| #SymbolicDist(SymbolicTypes.symbolicDist)
|
| #SymbolicDist(SymbolicDistTypes.symbolicDist)
|
||||||
| #RenderedDist(DistTypes.shape)
|
| #RenderedDist(PointSetTypes.shape)
|
||||||
| #Symbol(string)
|
| #Symbol(string)
|
||||||
| #Hash(hash)
|
| #Hash(hash)
|
||||||
| #Array(array<node>)
|
| #Array(array<node>)
|
||||||
|
@ -148,7 +148,7 @@ module ExpressionTree = {
|
||||||
| _ => None
|
| _ => None
|
||||||
}
|
}
|
||||||
|
|
||||||
let _toFloat = (t: DistTypes.shape) =>
|
let _toFloat = (t: PointSetTypes.shape) =>
|
||||||
switch t {
|
switch t {
|
||||||
| Discrete({xyShape: {xs: [x], ys: [1.0]}}) => Some(#SymbolicDist(#Float(x)))
|
| Discrete({xyShape: {xs: [x], ys: [1.0]}}) => Some(#SymbolicDist(#Float(x)))
|
||||||
| _ => None
|
| _ => None
|
|
@ -36,8 +36,8 @@ module Function = {
|
||||||
|
|
||||||
module Primative = {
|
module Primative = {
|
||||||
type t = [
|
type t = [
|
||||||
| #SymbolicDist(SymbolicTypes.symbolicDist)
|
| #SymbolicDist(SymbolicDistTypes.symbolicDist)
|
||||||
| #RenderedDist(DistTypes.shape)
|
| #RenderedDist(PointSetTypes.shape)
|
||||||
| #Function(array<string>, node)
|
| #Function(array<string>, node)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ module Primative = {
|
||||||
|
|
||||||
module SamplingDistribution = {
|
module SamplingDistribution = {
|
||||||
type t = [
|
type t = [
|
||||||
| #SymbolicDist(SymbolicTypes.symbolicDist)
|
| #SymbolicDist(SymbolicDistTypes.symbolicDist)
|
||||||
| #RenderedDist(DistTypes.shape)
|
| #RenderedDist(PointSetTypes.shape)
|
||||||
]
|
]
|
||||||
|
|
||||||
let isSamplingDistribution: node => bool = x =>
|
let isSamplingDistribution: node => bool = x =>
|
|
@ -2,8 +2,8 @@ type node = ExpressionTypes.ExpressionTree.node
|
||||||
let getFloat = ExpressionTypes.ExpressionTree.getFloat
|
let getFloat = ExpressionTypes.ExpressionTree.getFloat
|
||||||
|
|
||||||
type samplingDist = [
|
type samplingDist = [
|
||||||
| #SymbolicDist(SymbolicTypes.symbolicDist)
|
| #SymbolicDist(SymbolicDistTypes.symbolicDist)
|
||||||
| #RenderedDist(DistTypes.shape)
|
| #RenderedDist(PointSetTypes.shape)
|
||||||
]
|
]
|
||||||
|
|
||||||
type rec hashType = array<(string, _type)>
|
type rec hashType = array<(string, _type)>
|
||||||
|
@ -18,7 +18,7 @@ and _type = [
|
||||||
type rec hashTypedValue = array<(string, typedValue)>
|
type rec hashTypedValue = array<(string, typedValue)>
|
||||||
and typedValue = [
|
and typedValue = [
|
||||||
| #Float(float)
|
| #Float(float)
|
||||||
| #RenderedDist(DistTypes.shape)
|
| #RenderedDist(PointSetTypes.shape)
|
||||||
| #SamplingDist(samplingDist)
|
| #SamplingDist(samplingDist)
|
||||||
| #Array(array<typedValue>)
|
| #Array(array<typedValue>)
|
||||||
| #Hash(hashTypedValue)
|
| #Hash(hashTypedValue)
|
|
@ -97,9 +97,9 @@ let toDiscretePointMassesFromTriangulars = (
|
||||||
|
|
||||||
let combineShapesContinuousContinuous = (
|
let combineShapesContinuousContinuous = (
|
||||||
op: ExpressionTypes.algebraicOperation,
|
op: ExpressionTypes.algebraicOperation,
|
||||||
s1: DistTypes.xyShape,
|
s1: PointSetTypes.xyShape,
|
||||||
s2: DistTypes.xyShape,
|
s2: PointSetTypes.xyShape,
|
||||||
): DistTypes.xyShape => {
|
): PointSetTypes.xyShape => {
|
||||||
let t1n = s1 |> XYShape.T.length
|
let t1n = s1 |> XYShape.T.length
|
||||||
let t2n = s2 |> XYShape.T.length
|
let t2n = s2 |> XYShape.T.length
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ let combineShapesContinuousContinuous = (
|
||||||
{xs: outputXs, ys: outputYs}
|
{xs: outputXs, ys: outputYs}
|
||||||
}
|
}
|
||||||
|
|
||||||
let toDiscretePointMassesFromDiscrete = (s: DistTypes.xyShape): pointMassesWithMoments => {
|
let toDiscretePointMassesFromDiscrete = (s: PointSetTypes.xyShape): pointMassesWithMoments => {
|
||||||
let {xs, ys}: XYShape.T.t = s
|
let {xs, ys}: XYShape.T.t = s
|
||||||
let n = E.A.length(xs)
|
let n = E.A.length(xs)
|
||||||
|
|
||||||
|
@ -201,9 +201,9 @@ let toDiscretePointMassesFromDiscrete = (s: DistTypes.xyShape): pointMassesWithM
|
||||||
|
|
||||||
let combineShapesContinuousDiscrete = (
|
let combineShapesContinuousDiscrete = (
|
||||||
op: ExpressionTypes.algebraicOperation,
|
op: ExpressionTypes.algebraicOperation,
|
||||||
continuousShape: DistTypes.xyShape,
|
continuousShape: PointSetTypes.xyShape,
|
||||||
discreteShape: DistTypes.xyShape,
|
discreteShape: PointSetTypes.xyShape,
|
||||||
): DistTypes.xyShape => {
|
): PointSetTypes.xyShape => {
|
||||||
let t1n = continuousShape |> XYShape.T.length
|
let t1n = continuousShape |> XYShape.T.length
|
||||||
let t2n = discreteShape |> XYShape.T.length
|
let t2n = discreteShape |> XYShape.T.length
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
open Distributions
|
open Distributions
|
||||||
|
|
||||||
type t = DistTypes.continuousShape
|
type t = PointSetTypes.continuousShape
|
||||||
let getShape = (t: t) => t.xyShape
|
let getShape = (t: t) => t.xyShape
|
||||||
let interpolation = (t: t) => t.interpolation
|
let interpolation = (t: t) => t.interpolation
|
||||||
let make = (~interpolation=#Linear, ~integralSumCache=None, ~integralCache=None, xyShape): t => {
|
let make = (~interpolation=#Linear, ~integralSumCache=None, ~integralCache=None, xyShape): t => {
|
||||||
|
@ -17,10 +17,10 @@ let shapeMap = (fn, {xyShape, interpolation, integralSumCache, integralCache}: t
|
||||||
}
|
}
|
||||||
let lastY = (t: t) => t |> getShape |> XYShape.T.lastY
|
let lastY = (t: t) => t |> getShape |> XYShape.T.lastY
|
||||||
let oShapeMap = (fn, {xyShape, interpolation, integralSumCache, integralCache}: t): option<
|
let oShapeMap = (fn, {xyShape, interpolation, integralSumCache, integralCache}: t): option<
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
> => fn(xyShape) |> E.O.fmap(make(~interpolation, ~integralSumCache, ~integralCache))
|
> => fn(xyShape) |> E.O.fmap(make(~interpolation, ~integralSumCache, ~integralCache))
|
||||||
|
|
||||||
let emptyIntegral: DistTypes.continuousShape = {
|
let emptyIntegral: PointSetTypes.continuousShape = {
|
||||||
xyShape: {
|
xyShape: {
|
||||||
xs: [neg_infinity],
|
xs: [neg_infinity],
|
||||||
ys: [0.0],
|
ys: [0.0],
|
||||||
|
@ -29,7 +29,7 @@ let emptyIntegral: DistTypes.continuousShape = {
|
||||||
integralSumCache: Some(0.0),
|
integralSumCache: Some(0.0),
|
||||||
integralCache: None,
|
integralCache: None,
|
||||||
}
|
}
|
||||||
let empty: DistTypes.continuousShape = {
|
let empty: PointSetTypes.continuousShape = {
|
||||||
xyShape: XYShape.T.empty,
|
xyShape: XYShape.T.empty,
|
||||||
interpolation: #Linear,
|
interpolation: #Linear,
|
||||||
integralSumCache: Some(0.0),
|
integralSumCache: Some(0.0),
|
||||||
|
@ -47,11 +47,11 @@ let stepwiseToLinear = (t: t): t =>
|
||||||
let combinePointwise = (
|
let combinePointwise = (
|
||||||
~integralSumCachesFn=(_, _) => None,
|
~integralSumCachesFn=(_, _) => None,
|
||||||
~integralCachesFn: (t, t) => option<t>=(_, _) => None,
|
~integralCachesFn: (t, t) => option<t>=(_, _) => None,
|
||||||
~distributionType: DistTypes.distributionType=#PDF,
|
~distributionType: PointSetTypes.distributionType=#PDF,
|
||||||
fn: (float, float) => float,
|
fn: (float, float) => float,
|
||||||
t1: DistTypes.continuousShape,
|
t1: PointSetTypes.continuousShape,
|
||||||
t2: DistTypes.continuousShape,
|
t2: PointSetTypes.continuousShape,
|
||||||
): DistTypes.continuousShape => {
|
): PointSetTypes.continuousShape => {
|
||||||
// If we're adding the distributions, and we know the total of each, then we
|
// If we're adding the distributions, and we know the total of each, then we
|
||||||
// can just sum them up. Otherwise, all bets are off.
|
// can just sum them up. Otherwise, all bets are off.
|
||||||
let combinedIntegralSum = Common.combineIntegralSums(
|
let combinedIntegralSum = Common.combineIntegralSums(
|
||||||
|
@ -130,19 +130,19 @@ let rec scaleBy = (~scale=1.0, t: t): t => {
|
||||||
}
|
}
|
||||||
|
|
||||||
module T = Dist({
|
module T = Dist({
|
||||||
type t = DistTypes.continuousShape
|
type t = PointSetTypes.continuousShape
|
||||||
type integral = DistTypes.continuousShape
|
type integral = PointSetTypes.continuousShape
|
||||||
let minX = shapeFn(XYShape.T.minX)
|
let minX = shapeFn(XYShape.T.minX)
|
||||||
let maxX = shapeFn(XYShape.T.maxX)
|
let maxX = shapeFn(XYShape.T.maxX)
|
||||||
let mapY = mapY
|
let mapY = mapY
|
||||||
let updateIntegralCache = updateIntegralCache
|
let updateIntegralCache = updateIntegralCache
|
||||||
let toDiscreteProbabilityMassFraction = _ => 0.0
|
let toDiscreteProbabilityMassFraction = _ => 0.0
|
||||||
let toShape = (t: t): DistTypes.shape => Continuous(t)
|
let toShape = (t: t): PointSetTypes.shape => Continuous(t)
|
||||||
let xToY = (f, {interpolation, xyShape}: t) =>
|
let xToY = (f, {interpolation, xyShape}: t) =>
|
||||||
switch interpolation {
|
switch interpolation {
|
||||||
| #Stepwise => xyShape |> XYShape.XtoY.stepwiseIncremental(f) |> E.O.default(0.0)
|
| #Stepwise => xyShape |> XYShape.XtoY.stepwiseIncremental(f) |> E.O.default(0.0)
|
||||||
| #Linear => xyShape |> XYShape.XtoY.linear(f)
|
| #Linear => xyShape |> XYShape.XtoY.linear(f)
|
||||||
} |> DistTypes.MixedPoint.makeContinuous
|
} |> PointSetTypes.MixedPoint.makeContinuous
|
||||||
|
|
||||||
let truncate = (leftCutoff: option<float>, rightCutoff: option<float>, t: t) => {
|
let truncate = (leftCutoff: option<float>, rightCutoff: option<float>, t: t) => {
|
||||||
let lc = E.O.default(neg_infinity, leftCutoff)
|
let lc = E.O.default(neg_infinity, leftCutoff)
|
||||||
|
@ -213,7 +213,7 @@ module T = Dist({
|
||||||
let combineAlgebraicallyWithDiscrete = (
|
let combineAlgebraicallyWithDiscrete = (
|
||||||
op: ExpressionTypes.algebraicOperation,
|
op: ExpressionTypes.algebraicOperation,
|
||||||
t1: t,
|
t1: t,
|
||||||
t2: DistTypes.discreteShape,
|
t2: PointSetTypes.discreteShape,
|
||||||
) => {
|
) => {
|
||||||
let t1s = t1 |> getShape
|
let t1s = t1 |> getShape
|
||||||
let t2s = t2.xyShape // TODO would like to use Discrete.getShape here, but current file structure doesn't allow for that
|
let t2s = t2.xyShape // TODO would like to use Discrete.getShape here, but current file structure doesn't allow for that
|
|
@ -1,6 +1,6 @@
|
||||||
open Distributions
|
open Distributions
|
||||||
|
|
||||||
type t = DistTypes.discreteShape
|
type t = PointSetTypes.discreteShape
|
||||||
|
|
||||||
let make = (~integralSumCache=None, ~integralCache=None, xyShape): t => {
|
let make = (~integralSumCache=None, ~integralCache=None, xyShape): t => {
|
||||||
xyShape: xyShape,
|
xyShape: xyShape,
|
||||||
|
@ -16,13 +16,13 @@ let getShape = (t: t) => t.xyShape
|
||||||
let oShapeMap = (fn, {xyShape, integralSumCache, integralCache}: t): option<t> =>
|
let oShapeMap = (fn, {xyShape, integralSumCache, integralCache}: t): option<t> =>
|
||||||
fn(xyShape) |> E.O.fmap(make(~integralSumCache, ~integralCache))
|
fn(xyShape) |> E.O.fmap(make(~integralSumCache, ~integralCache))
|
||||||
|
|
||||||
let emptyIntegral: DistTypes.continuousShape = {
|
let emptyIntegral: PointSetTypes.continuousShape = {
|
||||||
xyShape: {xs: [neg_infinity], ys: [0.0]},
|
xyShape: {xs: [neg_infinity], ys: [0.0]},
|
||||||
interpolation: #Stepwise,
|
interpolation: #Stepwise,
|
||||||
integralSumCache: Some(0.0),
|
integralSumCache: Some(0.0),
|
||||||
integralCache: None,
|
integralCache: None,
|
||||||
}
|
}
|
||||||
let empty: DistTypes.discreteShape = {
|
let empty: PointSetTypes.discreteShape = {
|
||||||
xyShape: XYShape.T.empty,
|
xyShape: XYShape.T.empty,
|
||||||
integralSumCache: Some(0.0),
|
integralSumCache: Some(0.0),
|
||||||
integralCache: Some(emptyIntegral),
|
integralCache: Some(emptyIntegral),
|
||||||
|
@ -35,13 +35,13 @@ let lastY = (t: t) => t |> getShape |> XYShape.T.lastY
|
||||||
let combinePointwise = (
|
let combinePointwise = (
|
||||||
~integralSumCachesFn=(_, _) => None,
|
~integralSumCachesFn=(_, _) => None,
|
||||||
~integralCachesFn: (
|
~integralCachesFn: (
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
) => option<DistTypes.continuousShape>=(_, _) => None,
|
) => option<PointSetTypes.continuousShape>=(_, _) => None,
|
||||||
fn,
|
fn,
|
||||||
t1: DistTypes.discreteShape,
|
t1: PointSetTypes.discreteShape,
|
||||||
t2: DistTypes.discreteShape,
|
t2: PointSetTypes.discreteShape,
|
||||||
): DistTypes.discreteShape => {
|
): PointSetTypes.discreteShape => {
|
||||||
let combinedIntegralSum = Common.combineIntegralSums(
|
let combinedIntegralSum = Common.combineIntegralSums(
|
||||||
integralSumCachesFn,
|
integralSumCachesFn,
|
||||||
t1.integralSumCache,
|
t1.integralSumCache,
|
||||||
|
@ -67,7 +67,7 @@ let reduce = (
|
||||||
~integralCachesFn=(_, _) => None,
|
~integralCachesFn=(_, _) => None,
|
||||||
fn,
|
fn,
|
||||||
discreteShapes,
|
discreteShapes,
|
||||||
): DistTypes.discreteShape =>
|
): PointSetTypes.discreteShape =>
|
||||||
discreteShapes |> E.A.fold_left(
|
discreteShapes |> E.A.fold_left(
|
||||||
combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn),
|
combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn),
|
||||||
empty,
|
empty,
|
||||||
|
@ -134,8 +134,8 @@ let scaleBy = (~scale=1.0, t: t): t => {
|
||||||
}
|
}
|
||||||
|
|
||||||
module T = Dist({
|
module T = Dist({
|
||||||
type t = DistTypes.discreteShape
|
type t = PointSetTypes.discreteShape
|
||||||
type integral = DistTypes.continuousShape
|
type integral = PointSetTypes.continuousShape
|
||||||
let integral = t =>
|
let integral = t =>
|
||||||
switch (getShape(t) |> XYShape.T.isEmpty, t.integralCache) {
|
switch (getShape(t) |> XYShape.T.isEmpty, t.integralCache) {
|
||||||
| (true, _) => emptyIntegral
|
| (true, _) => emptyIntegral
|
||||||
|
@ -157,7 +157,7 @@ module T = Dist({
|
||||||
let toDiscreteProbabilityMassFraction = _ => 1.0
|
let toDiscreteProbabilityMassFraction = _ => 1.0
|
||||||
let mapY = mapY
|
let mapY = mapY
|
||||||
let updateIntegralCache = updateIntegralCache
|
let updateIntegralCache = updateIntegralCache
|
||||||
let toShape = (t: t): DistTypes.shape => Discrete(t)
|
let toShape = (t: t): PointSetTypes.shape => Discrete(t)
|
||||||
let toContinuous = _ => None
|
let toContinuous = _ => None
|
||||||
let toDiscrete = t => Some(t)
|
let toDiscrete = t => Some(t)
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ module T = Dist({
|
||||||
|> getShape
|
|> getShape
|
||||||
|> XYShape.XtoY.stepwiseIfAtX(f)
|
|> XYShape.XtoY.stepwiseIfAtX(f)
|
||||||
|> E.O.default(0.0)
|
|> E.O.default(0.0)
|
||||||
|> DistTypes.MixedPoint.makeDiscrete
|
|> PointSetTypes.MixedPoint.makeDiscrete
|
||||||
|
|
||||||
let integralXtoY = (f, t) => t |> integral |> Continuous.getShape |> XYShape.XtoY.linear(f)
|
let integralXtoY = (f, t) => t |> integral |> Continuous.getShape |> XYShape.XtoY.linear(f)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
open DistTypes;
|
open PointSetTypes;
|
||||||
|
|
||||||
type t = DistTypes.distPlus;
|
type t = PointSetTypes.distPlus;
|
||||||
|
|
||||||
let shapeIntegral = shape => Shape.T.Integral.get(shape);
|
let shapeIntegral = shape => Shape.T.Integral.get(shape);
|
||||||
let make =
|
let make =
|
||||||
|
@ -49,8 +49,8 @@ let shapeFn = (fn, {shape}: t) => fn(shape);
|
||||||
|
|
||||||
module T =
|
module T =
|
||||||
Distributions.Dist({
|
Distributions.Dist({
|
||||||
type t = DistTypes.distPlus;
|
type t = PointSetTypes.distPlus;
|
||||||
type integral = DistTypes.distPlus;
|
type integral = PointSetTypes.distPlus;
|
||||||
let toShape = toShape;
|
let toShape = toShape;
|
||||||
let toContinuous = shapeFn(Shape.T.toContinuous);
|
let toContinuous = shapeFn(Shape.T.toContinuous);
|
||||||
let toDiscrete = shapeFn(Shape.T.toDiscrete);
|
let toDiscrete = shapeFn(Shape.T.toDiscrete);
|
||||||
|
@ -84,7 +84,7 @@ module T =
|
||||||
let integral = (t: t) =>
|
let integral = (t: t) =>
|
||||||
updateShape(Continuous(t.integralCache), t);
|
updateShape(Continuous(t.integralCache), t);
|
||||||
|
|
||||||
let updateIntegralCache = (integralCache: option<DistTypes.continuousShape>, t) =>
|
let updateIntegralCache = (integralCache: option<PointSetTypes.continuousShape>, t) =>
|
||||||
update(~integralCache=E.O.default(t.integralCache, integralCache), t);
|
update(~integralCache=E.O.default(t.integralCache, integralCache), t);
|
||||||
|
|
||||||
let downsample = (i, t): t =>
|
let downsample = (i, t): t =>
|
|
@ -5,20 +5,20 @@ module type dist = {
|
||||||
let maxX: t => float
|
let maxX: t => float
|
||||||
let mapY: (
|
let mapY: (
|
||||||
~integralSumCacheFn: float => option<float>=?,
|
~integralSumCacheFn: float => option<float>=?,
|
||||||
~integralCacheFn: DistTypes.continuousShape => option<DistTypes.continuousShape>=?,
|
~integralCacheFn: PointSetTypes.continuousShape => option<PointSetTypes.continuousShape>=?,
|
||||||
~fn: float => float,
|
~fn: float => float,
|
||||||
t,
|
t,
|
||||||
) => t
|
) => t
|
||||||
let xToY: (float, t) => DistTypes.mixedPoint
|
let xToY: (float, t) => PointSetTypes.mixedPoint
|
||||||
let toShape: t => DistTypes.shape
|
let toShape: t => PointSetTypes.shape
|
||||||
let toContinuous: t => option<DistTypes.continuousShape>
|
let toContinuous: t => option<PointSetTypes.continuousShape>
|
||||||
let toDiscrete: t => option<DistTypes.discreteShape>
|
let toDiscrete: t => option<PointSetTypes.discreteShape>
|
||||||
let normalize: t => t
|
let normalize: t => t
|
||||||
let toDiscreteProbabilityMassFraction: t => float
|
let toDiscreteProbabilityMassFraction: t => float
|
||||||
let downsample: (int, t) => t
|
let downsample: (int, t) => t
|
||||||
let truncate: (option<float>, option<float>, t) => t
|
let truncate: (option<float>, option<float>, t) => t
|
||||||
|
|
||||||
let updateIntegralCache: (option<DistTypes.continuousShape>, t) => t
|
let updateIntegralCache: (option<PointSetTypes.continuousShape>, t) => t
|
||||||
|
|
||||||
let integral: t => integral
|
let integral: t => integral
|
||||||
let integralEndY: t => float
|
let integralEndY: t => float
|
||||||
|
@ -74,11 +74,11 @@ module Common = {
|
||||||
|
|
||||||
let combineIntegrals = (
|
let combineIntegrals = (
|
||||||
combineFn: (
|
combineFn: (
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
) => option<DistTypes.continuousShape>,
|
) => option<PointSetTypes.continuousShape>,
|
||||||
t1IntegralCache: option<DistTypes.continuousShape>,
|
t1IntegralCache: option<PointSetTypes.continuousShape>,
|
||||||
t2IntegralCache: option<DistTypes.continuousShape>,
|
t2IntegralCache: option<PointSetTypes.continuousShape>,
|
||||||
) =>
|
) =>
|
||||||
switch (t1IntegralCache, t2IntegralCache) {
|
switch (t1IntegralCache, t2IntegralCache) {
|
||||||
| (None, _)
|
| (None, _)
|
|
@ -1,6 +1,6 @@
|
||||||
open Distributions
|
open Distributions
|
||||||
|
|
||||||
type t = DistTypes.mixedShape
|
type t = PointSetTypes.mixedShape
|
||||||
let make = (~integralSumCache=None, ~integralCache=None, ~continuous, ~discrete): t => {
|
let make = (~integralSumCache=None, ~integralCache=None, ~continuous, ~discrete): t => {
|
||||||
continuous: continuous,
|
continuous: continuous,
|
||||||
discrete: discrete,
|
discrete: discrete,
|
||||||
|
@ -37,13 +37,13 @@ let updateIntegralCache = (integralCache, t: t): t => {
|
||||||
}
|
}
|
||||||
|
|
||||||
module T = Dist({
|
module T = Dist({
|
||||||
type t = DistTypes.mixedShape
|
type t = PointSetTypes.mixedShape
|
||||||
type integral = DistTypes.continuousShape
|
type integral = PointSetTypes.continuousShape
|
||||||
let minX = ({continuous, discrete}: t) =>
|
let minX = ({continuous, discrete}: t) =>
|
||||||
min(Continuous.T.minX(continuous), Discrete.T.minX(discrete))
|
min(Continuous.T.minX(continuous), Discrete.T.minX(discrete))
|
||||||
let maxX = ({continuous, discrete}: t) =>
|
let maxX = ({continuous, discrete}: t) =>
|
||||||
max(Continuous.T.maxX(continuous), Discrete.T.maxX(discrete))
|
max(Continuous.T.maxX(continuous), Discrete.T.maxX(discrete))
|
||||||
let toShape = (t: t): DistTypes.shape => Mixed(t)
|
let toShape = (t: t): PointSetTypes.shape => Mixed(t)
|
||||||
|
|
||||||
let updateIntegralCache = updateIntegralCache
|
let updateIntegralCache = updateIntegralCache
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ module T = Dist({
|
||||||
let {continuous, discrete}: t = normalize(t)
|
let {continuous, discrete}: t = normalize(t)
|
||||||
let c = Continuous.T.xToY(x, continuous)
|
let c = Continuous.T.xToY(x, continuous)
|
||||||
let d = Discrete.T.xToY(x, discrete)
|
let d = Discrete.T.xToY(x, discrete)
|
||||||
DistTypes.MixedPoint.add(c, d) // "add" here just combines the two values into a single MixedPoint.
|
PointSetTypes.MixedPoint.add(c, d) // "add" here just combines the two values into a single MixedPoint.
|
||||||
}
|
}
|
||||||
|
|
||||||
let toDiscreteProbabilityMassFraction = ({discrete, continuous}: t) => {
|
let toDiscreteProbabilityMassFraction = ({discrete, continuous}: t) => {
|
||||||
|
@ -170,13 +170,13 @@ module T = Dist({
|
||||||
~fn,
|
~fn,
|
||||||
t: t,
|
t: t,
|
||||||
): t => {
|
): t => {
|
||||||
let yMappedDiscrete: DistTypes.discreteShape =
|
let yMappedDiscrete: PointSetTypes.discreteShape =
|
||||||
t.discrete
|
t.discrete
|
||||||
|> Discrete.T.mapY(~fn)
|
|> Discrete.T.mapY(~fn)
|
||||||
|> Discrete.updateIntegralSumCache(E.O.bind(t.discrete.integralSumCache, integralSumCacheFn))
|
|> Discrete.updateIntegralSumCache(E.O.bind(t.discrete.integralSumCache, integralSumCacheFn))
|
||||||
|> Discrete.updateIntegralCache(E.O.bind(t.discrete.integralCache, integralCacheFn))
|
|> Discrete.updateIntegralCache(E.O.bind(t.discrete.integralCache, integralCacheFn))
|
||||||
|
|
||||||
let yMappedContinuous: DistTypes.continuousShape =
|
let yMappedContinuous: PointSetTypes.continuousShape =
|
||||||
t.continuous
|
t.continuous
|
||||||
|> Continuous.T.mapY(~fn)
|
|> Continuous.T.mapY(~fn)
|
||||||
|> Continuous.updateIntegralSumCache(
|
|> Continuous.updateIntegralSumCache(
|
|
@ -9,9 +9,9 @@ type assumptions = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let buildSimple = (
|
let buildSimple = (
|
||||||
~continuous: option<DistTypes.continuousShape>,
|
~continuous: option<PointSetTypes.continuousShape>,
|
||||||
~discrete: option<DistTypes.discreteShape>,
|
~discrete: option<PointSetTypes.discreteShape>,
|
||||||
): option<DistTypes.shape> => {
|
): option<PointSetTypes.shape> => {
|
||||||
let continuous =
|
let continuous =
|
||||||
continuous |> E.O.default(Continuous.make(~integralSumCache=Some(0.0), {xs: [], ys: []}))
|
continuous |> E.O.default(Continuous.make(~integralSumCache=Some(0.0), {xs: [], ys: []}))
|
||||||
let discrete =
|
let discrete =
|
|
@ -1,6 +1,6 @@
|
||||||
open Distributions
|
open Distributions
|
||||||
|
|
||||||
type t = DistTypes.shape
|
type t = PointSetTypes.shape
|
||||||
let mapToAll = ((fn1, fn2, fn3), t: t) =>
|
let mapToAll = ((fn1, fn2, fn3), t: t) =>
|
||||||
switch t {
|
switch t {
|
||||||
| Mixed(m) => fn1(m)
|
| Mixed(m) => fn1(m)
|
||||||
|
@ -47,31 +47,31 @@ let combineAlgebraically = (op: ExpressionTypes.algebraicOperation, t1: t, t2: t
|
||||||
let combinePointwise = (
|
let combinePointwise = (
|
||||||
~integralSumCachesFn: (float, float) => option<float>=(_, _) => None,
|
~integralSumCachesFn: (float, float) => option<float>=(_, _) => None,
|
||||||
~integralCachesFn: (
|
~integralCachesFn: (
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
DistTypes.continuousShape,
|
PointSetTypes.continuousShape,
|
||||||
) => option<DistTypes.continuousShape>=(_, _) => None,
|
) => option<PointSetTypes.continuousShape>=(_, _) => None,
|
||||||
fn,
|
fn,
|
||||||
t1: t,
|
t1: t,
|
||||||
t2: t,
|
t2: t,
|
||||||
) =>
|
) =>
|
||||||
switch (t1, t2) {
|
switch (t1, t2) {
|
||||||
| (Continuous(m1), Continuous(m2)) =>
|
| (Continuous(m1), Continuous(m2)) =>
|
||||||
DistTypes.Continuous(
|
PointSetTypes.Continuous(
|
||||||
Continuous.combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn, m1, m2),
|
Continuous.combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn, m1, m2),
|
||||||
)
|
)
|
||||||
| (Discrete(m1), Discrete(m2)) =>
|
| (Discrete(m1), Discrete(m2)) =>
|
||||||
DistTypes.Discrete(
|
PointSetTypes.Discrete(
|
||||||
Discrete.combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn, m1, m2),
|
Discrete.combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn, m1, m2),
|
||||||
)
|
)
|
||||||
| (m1, m2) =>
|
| (m1, m2) =>
|
||||||
DistTypes.Mixed(
|
PointSetTypes.Mixed(
|
||||||
Mixed.combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn, toMixed(m1), toMixed(m2)),
|
Mixed.combinePointwise(~integralSumCachesFn, ~integralCachesFn, fn, toMixed(m1), toMixed(m2)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
module T = Dist({
|
module T = Dist({
|
||||||
type t = DistTypes.shape
|
type t = PointSetTypes.shape
|
||||||
type integral = DistTypes.continuousShape
|
type integral = PointSetTypes.continuousShape
|
||||||
|
|
||||||
let xToY = (f: float) => mapToAll((Mixed.T.xToY(f), Discrete.T.xToY(f), Continuous.T.xToY(f)))
|
let xToY = (f: float) => mapToAll((Mixed.T.xToY(f), Discrete.T.xToY(f), Continuous.T.xToY(f)))
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ module T = Dist({
|
||||||
})
|
})
|
||||||
|
|
||||||
let pdf = (f: float, t: t) => {
|
let pdf = (f: float, t: t) => {
|
||||||
let mixedPoint: DistTypes.mixedPoint = T.xToY(f, t)
|
let mixedPoint: PointSetTypes.mixedPoint = T.xToY(f, t)
|
||||||
mixedPoint.continuous +. mixedPoint.discrete
|
mixedPoint.continuous +. mixedPoint.discrete
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
open DistTypes
|
open PointSetTypes
|
||||||
|
|
||||||
let interpolate = (xMin: float, xMax: float, yMin: float, yMax: float, xIntended: float): float => {
|
let interpolate = (xMin: float, xMax: float, yMin: float, yMax: float, xIntended: float): float => {
|
||||||
let minProportion = (xMax -. xIntended) /. (xMax -. xMin)
|
let minProportion = (xMax -. xIntended) /. (xMax -. xMin)
|
||||||
|
@ -126,8 +126,8 @@ module XtoY = {
|
||||||
/* Returns a between-points-interpolating function that can be used with PointwiseCombination.combine.
|
/* Returns a between-points-interpolating function that can be used with PointwiseCombination.combine.
|
||||||
Interpolation can either be stepwise (using the value on the left) or linear. Extrapolation can be `UseZero or `UseOutermostPoints. */
|
Interpolation can either be stepwise (using the value on the left) or linear. Extrapolation can be `UseZero or `UseOutermostPoints. */
|
||||||
let continuousInterpolator = (
|
let continuousInterpolator = (
|
||||||
interpolation: DistTypes.interpolationStrategy,
|
interpolation: PointSetTypes.interpolationStrategy,
|
||||||
extrapolation: DistTypes.extrapolationStrategy,
|
extrapolation: PointSetTypes.extrapolationStrategy,
|
||||||
): interpolator =>
|
): interpolator =>
|
||||||
switch (interpolation, extrapolation) {
|
switch (interpolation, extrapolation) {
|
||||||
| (#Linear, #UseZero) =>
|
| (#Linear, #UseZero) =>
|
||||||
|
@ -395,7 +395,7 @@ module Analysis = {
|
||||||
let integrateContinuousShape = (
|
let integrateContinuousShape = (
|
||||||
~indefiniteIntegralStepwise=(p, h1) => h1 *. p,
|
~indefiniteIntegralStepwise=(p, h1) => h1 *. p,
|
||||||
~indefiniteIntegralLinear=(p, a, b) => a *. p +. b *. p ** 2.0 /. 2.0,
|
~indefiniteIntegralLinear=(p, a, b) => a *. p +. b *. p ** 2.0 /. 2.0,
|
||||||
t: DistTypes.continuousShape,
|
t: PointSetTypes.continuousShape,
|
||||||
): float => {
|
): float => {
|
||||||
let xs = t.xyShape.xs
|
let xs = t.xyShape.xs
|
||||||
let ys = t.xyShape.ys
|
let ys = t.xyShape.ys
|
||||||
|
@ -424,7 +424,7 @@ module Analysis = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let getMeanOfSquaresContinuousShape = (t: DistTypes.continuousShape) => {
|
let getMeanOfSquaresContinuousShape = (t: PointSetTypes.continuousShape) => {
|
||||||
let indefiniteIntegralLinear = (p, a, b) => a *. p ** 3.0 /. 3.0 +. b *. p ** 4.0 /. 4.0
|
let indefiniteIntegralLinear = (p, a, b) => a *. p ** 3.0 /. 3.0 +. b *. p ** 4.0 /. 4.0
|
||||||
let indefiniteIntegralStepwise = (p, h1) => h1 *. p ** 3.0 /. 3.0
|
let indefiniteIntegralStepwise = (p, h1) => h1 *. p ** 3.0 /. 3.0
|
||||||
integrateContinuousShape(~indefiniteIntegralStepwise, ~indefiniteIntegralLinear, t)
|
integrateContinuousShape(~indefiniteIntegralStepwise, ~indefiniteIntegralLinear, t)
|
|
@ -11,7 +11,7 @@ module Internals = {
|
||||||
|
|
||||||
type outputs = {
|
type outputs = {
|
||||||
continuousParseParams: option<samplingStats>,
|
continuousParseParams: option<samplingStats>,
|
||||||
shape: option<DistTypes.shape>,
|
shape: option<PointSetTypes.shape>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Internals = {
|
||||||
ys: array<float>,
|
ys: array<float>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let jsToDist = (d: distJs): DistTypes.xyShape => {
|
let jsToDist = (d: distJs): PointSetTypes.xyShape => {
|
||||||
xs: xsGet(d),
|
xs: xsGet(d),
|
||||||
ys: ysGet(d),
|
ys: ysGet(d),
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ let toShape = (
|
||||||
Array.fast_sort(compare, samples)
|
Array.fast_sort(compare, samples)
|
||||||
let (continuousPart, discretePart) = E.A.Sorted.Floats.split(samples)
|
let (continuousPart, discretePart) = E.A.Sorted.Floats.split(samples)
|
||||||
let length = samples |> E.A.length |> float_of_int
|
let length = samples |> E.A.length |> float_of_int
|
||||||
let discrete: DistTypes.discreteShape =
|
let discrete: PointSetTypes.discreteShape =
|
||||||
discretePart
|
discretePart
|
||||||
|> E.FloatFloatMap.fmap(r => r /. length)
|
|> E.FloatFloatMap.fmap(r => r /. length)
|
||||||
|> E.FloatFloatMap.toArray
|
|> E.FloatFloatMap.toArray
|
|
@ -1,4 +1,4 @@
|
||||||
open SymbolicTypes
|
open SymbolicDistTypes
|
||||||
|
|
||||||
module Normal = {
|
module Normal = {
|
||||||
type t = normal
|
type t = normal
|
||||||
|
@ -317,7 +317,7 @@ module T = {
|
||||||
| _ => #NoSolution
|
| _ => #NoSolution
|
||||||
}
|
}
|
||||||
|
|
||||||
let toShape = (sampleCount, d: symbolicDist): DistTypes.shape =>
|
let toShape = (sampleCount, d: symbolicDist): PointSetTypes.shape =>
|
||||||
switch d {
|
switch d {
|
||||||
| #Float(v) => Discrete(Discrete.make(~integralSumCache=Some(1.0), {xs: [v], ys: [1.0]}))
|
| #Float(v) => Discrete(Discrete.make(~integralSumCache=Some(1.0), {xs: [v], ys: [1.0]}))
|
||||||
| _ =>
|
| _ =>
|
Loading…
Reference in New Issue
Block a user