Merged recommendedLenght to samplingParams
This commit is contained in:
parent
79d91bc69a
commit
67828cf789
|
@ -149,9 +149,9 @@ module DemoDist = {
|
||||||
sampleCount: Some(options.sampleCount),
|
sampleCount: Some(options.sampleCount),
|
||||||
outputXYPoints: Some(options.outputXYPoints),
|
outputXYPoints: Some(options.outputXYPoints),
|
||||||
kernelWidth: options.kernelWidth,
|
kernelWidth: options.kernelWidth,
|
||||||
|
shapeLength: Some(options.downsampleTo |> E.O.default(1000))
|
||||||
},
|
},
|
||||||
~distPlusIngredients,
|
~distPlusIngredients,
|
||||||
~recommendedLength=options.downsampleTo |> E.O.default(1000),
|
|
||||||
~inputVariables=
|
~inputVariables=
|
||||||
[|("p", `SymbolicDist(`Float(1.0)))|]
|
[|("p", `SymbolicDist(`Float(1.0)))|]
|
||||||
->Belt.Map.String.fromArray,
|
->Belt.Map.String.fromArray,
|
||||||
|
|
|
@ -392,8 +392,7 @@ module Draw = {
|
||||||
let normal: SymbolicTypes.symbolicDist = `Normal({mean, stdev});
|
let normal: SymbolicTypes.symbolicDist = `Normal({mean, stdev});
|
||||||
let normalShape =
|
let normalShape =
|
||||||
ExpressionTree.toShape(
|
ExpressionTree.toShape(
|
||||||
numSamples,
|
{sampleCount: 10000, outputXYPoints: 10000, kernelWidth: None, shapeLength:numSamples},
|
||||||
{sampleCount: 10000, outputXYPoints: 10000, kernelWidth: None},
|
|
||||||
`SymbolicDist(normal),
|
`SymbolicDist(normal),
|
||||||
) |> E.R.toExn;
|
) |> E.R.toExn;
|
||||||
let xyShape: Types.xyShape =
|
let xyShape: Types.xyShape =
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
open ExpressionTypes.ExpressionTree;
|
open ExpressionTypes.ExpressionTree;
|
||||||
|
|
||||||
let toLeaf = (intendedShapeLength: int, samplingInputs, node: node) => {
|
let toLeaf = (samplingInputs, node: node) => {
|
||||||
node
|
node
|
||||||
|> ExpressionTreeEvaluator.toLeaf({
|
|> ExpressionTreeEvaluator.toLeaf({
|
||||||
samplingInputs,
|
samplingInputs,
|
||||||
intendedShapeLength,
|
|
||||||
evaluateNode: ExpressionTreeEvaluator.toLeaf,
|
evaluateNode: ExpressionTreeEvaluator.toLeaf,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let toShape = (intendedShapeLength: int, samplingInputs, node: node) => {
|
let toShape = (samplingInputs, node: node) => {
|
||||||
let renderResult =
|
let renderResult =
|
||||||
`Render(`Normalize(node))
|
`Render(`Normalize(node))
|
||||||
|> toLeaf(intendedShapeLength, samplingInputs);
|
|> toLeaf(samplingInputs);
|
||||||
|
|
||||||
switch (renderResult) {
|
switch (renderResult) {
|
||||||
| Ok(`RenderedDist(shape)) => Ok(shape)
|
| Ok(`RenderedDist(shape)) => Ok(shape)
|
||||||
|
|
|
@ -279,7 +279,7 @@ module Render = {
|
||||||
| `SymbolicDist(d) =>
|
| `SymbolicDist(d) =>
|
||||||
Ok(
|
Ok(
|
||||||
`RenderedDist(
|
`RenderedDist(
|
||||||
SymbolicDist.T.toShape(evaluationParams.intendedShapeLength, d),
|
SymbolicDist.T.toShape(1234, d),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
| `RenderedDist(_) as t => Ok(t) // already a rendered shape, we're done here
|
| `RenderedDist(_) as t => Ok(t) // already a rendered shape, we're done here
|
||||||
|
|
|
@ -28,11 +28,11 @@ module ExpressionTree = {
|
||||||
sampleCount: int,
|
sampleCount: int,
|
||||||
outputXYPoints: int,
|
outputXYPoints: int,
|
||||||
kernelWidth: option(float),
|
kernelWidth: option(float),
|
||||||
|
shapeLength: int
|
||||||
};
|
};
|
||||||
|
|
||||||
type evaluationParams = {
|
type evaluationParams = {
|
||||||
samplingInputs,
|
samplingInputs,
|
||||||
intendedShapeLength: int,
|
|
||||||
evaluateNode: (evaluationParams, node) => Belt.Result.t(node, string),
|
evaluateNode: (evaluationParams, node) => Belt.Result.t(node, string),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
// TODO: This setup is more confusing than it should be, there's more work to do in cleanup here.
|
// TODO: This setup is more confusing than it should be, there's more work to do in cleanup here.
|
||||||
module Inputs = {
|
module Inputs = {
|
||||||
|
module SamplingInputs = {
|
||||||
|
type t = {
|
||||||
|
sampleCount: option(int),
|
||||||
|
outputXYPoints: option(int),
|
||||||
|
kernelWidth: option(float),
|
||||||
|
shapeLength: option(int),
|
||||||
|
};
|
||||||
|
};
|
||||||
let defaultRecommendedLength = 10000;
|
let defaultRecommendedLength = 10000;
|
||||||
let defaultShouldDownsample = true;
|
let defaultShouldDownsample = true;
|
||||||
|
|
||||||
|
@ -25,20 +33,19 @@ module Inputs = {
|
||||||
};
|
};
|
||||||
type inputs = {
|
type inputs = {
|
||||||
distPlusIngredients: ingredients,
|
distPlusIngredients: ingredients,
|
||||||
samplingInputs: RenderTypes.ShapeRenderer.Sampling.inputs,
|
samplingInputs: SamplingInputs.t,
|
||||||
recommendedLength: int,
|
|
||||||
inputVariables: Belt.Map.String.t(ExpressionTypes.ExpressionTree.node),
|
inputVariables: Belt.Map.String.t(ExpressionTypes.ExpressionTree.node),
|
||||||
};
|
};
|
||||||
let empty: RenderTypes.ShapeRenderer.Sampling.inputs = {
|
let empty: SamplingInputs.t = {
|
||||||
sampleCount: None,
|
sampleCount: None,
|
||||||
outputXYPoints: None,
|
outputXYPoints: None,
|
||||||
kernelWidth: None,
|
kernelWidth: None,
|
||||||
|
shapeLength: None
|
||||||
};
|
};
|
||||||
|
|
||||||
let make =
|
let make =
|
||||||
(
|
(
|
||||||
~samplingInputs=empty,
|
~samplingInputs=empty,
|
||||||
~recommendedLength=defaultRecommendedLength,
|
|
||||||
~distPlusIngredients,
|
~distPlusIngredients,
|
||||||
~inputVariables=[||]->Belt.Map.String.fromArray,
|
~inputVariables=[||]->Belt.Map.String.fromArray,
|
||||||
(),
|
(),
|
||||||
|
@ -46,15 +53,13 @@ module Inputs = {
|
||||||
: inputs => {
|
: inputs => {
|
||||||
distPlusIngredients,
|
distPlusIngredients,
|
||||||
samplingInputs,
|
samplingInputs,
|
||||||
recommendedLength,
|
|
||||||
inputVariables,
|
inputVariables,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
module Internals = {
|
module Internals = {
|
||||||
type inputs = {
|
type inputs = {
|
||||||
samplingInputs: RenderTypes.ShapeRenderer.Sampling.inputs,
|
samplingInputs: Inputs.SamplingInputs.t,
|
||||||
symbolicInputs: RenderTypes.ShapeRenderer.Symbolic.inputs,
|
|
||||||
guesstimatorString: string,
|
guesstimatorString: string,
|
||||||
inputVariables: Belt.Map.String.t(ExpressionTypes.ExpressionTree.node),
|
inputVariables: Belt.Map.String.t(ExpressionTypes.ExpressionTree.node),
|
||||||
};
|
};
|
||||||
|
@ -64,9 +69,6 @@ module Internals = {
|
||||||
samplingInputs: inputs.samplingInputs,
|
samplingInputs: inputs.samplingInputs,
|
||||||
guesstimatorString: inputs.distPlusIngredients.guesstimatorString,
|
guesstimatorString: inputs.distPlusIngredients.guesstimatorString,
|
||||||
inputVariables: inputs.inputVariables,
|
inputVariables: inputs.inputVariables,
|
||||||
symbolicInputs: {
|
|
||||||
length: inputs.recommendedLength,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,13 +82,13 @@ module Internals = {
|
||||||
MathJsParser.fromString(inputs.guesstimatorString, inputs.inputVariables)
|
MathJsParser.fromString(inputs.guesstimatorString, inputs.inputVariables)
|
||||||
|> E.R.bind(_, g =>
|
|> E.R.bind(_, g =>
|
||||||
ExpressionTree.toShape(
|
ExpressionTree.toShape(
|
||||||
inputs.symbolicInputs.length,
|
|
||||||
{
|
{
|
||||||
sampleCount:
|
sampleCount:
|
||||||
inputs.samplingInputs.sampleCount |> E.O.default(10000),
|
inputs.samplingInputs.sampleCount |> E.O.default(10000),
|
||||||
outputXYPoints:
|
outputXYPoints:
|
||||||
inputs.samplingInputs.outputXYPoints |> E.O.default(10000),
|
inputs.samplingInputs.outputXYPoints |> E.O.default(10000),
|
||||||
kernelWidth: inputs.samplingInputs.kernelWidth,
|
kernelWidth: inputs.samplingInputs.kernelWidth,
|
||||||
|
shapeLength: inputs.samplingInputs.shapeLength |> E.O.default(10000)
|
||||||
},
|
},
|
||||||
g,
|
g,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
module ShapeRenderer = {
|
|
||||||
module Sampling = {
|
|
||||||
type inputs = {
|
|
||||||
sampleCount: option(int),
|
|
||||||
outputXYPoints: option(int),
|
|
||||||
kernelWidth: option(float),
|
|
||||||
};
|
|
||||||
|
|
||||||
let defaults = {
|
|
||||||
sampleCount: Some(10000),
|
|
||||||
outputXYPoints: Some(1000),
|
|
||||||
kernelWidth: None
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module Symbolic = {
|
|
||||||
type inputs = {length: int};
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -21,7 +21,6 @@ let propValue = (t: Prop.Value.t) => {
|
||||||
let newDistribution =
|
let newDistribution =
|
||||||
DistPlusRenderer.Inputs.make(
|
DistPlusRenderer.Inputs.make(
|
||||||
~distPlusIngredients=r,
|
~distPlusIngredients=r,
|
||||||
~recommendedLength=10000,
|
|
||||||
(),
|
(),
|
||||||
)
|
)
|
||||||
|> DistPlusRenderer.run;
|
|> DistPlusRenderer.run;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user