Merge pull request #527 from quantified-uncertainty/sampleN
Added sampleN to interface
This commit is contained in:
commit
9d5a70e16a
|
@ -33,7 +33,6 @@
|
||||||
"Rescript"
|
"Rescript"
|
||||||
],
|
],
|
||||||
"author": "Quantified Uncertainty Research Institute",
|
"author": "Quantified Uncertainty Research Institute",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"rescript": "^9.1.4",
|
"rescript": "^9.1.4",
|
||||||
"jstat": "^1.9.5",
|
"jstat": "^1.9.5",
|
||||||
|
|
|
@ -18,6 +18,7 @@ type outputType =
|
||||||
| Dist(genericDist)
|
| Dist(genericDist)
|
||||||
| Float(float)
|
| Float(float)
|
||||||
| String(string)
|
| String(string)
|
||||||
|
| FloatArray(array<float>)
|
||||||
| Bool(bool)
|
| Bool(bool)
|
||||||
| GenDistError(error)
|
| GenDistError(error)
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ type outputType =
|
||||||
| Dist(genericDist)
|
| Dist(genericDist)
|
||||||
| Float(float)
|
| Float(float)
|
||||||
| String(string)
|
| String(string)
|
||||||
|
| FloatArray(array<float>)
|
||||||
| Bool(bool)
|
| Bool(bool)
|
||||||
| GenDistError(error)
|
| GenDistError(error)
|
||||||
|
|
||||||
|
|
|
@ -222,6 +222,8 @@ let dispatchToGenericOutput = (
|
||||||
->E.R.bind(r => r(f1, f2, f3))
|
->E.R.bind(r => r(f1, f2, f3))
|
||||||
->SymbolicConstructors.symbolicResultToOutput
|
->SymbolicConstructors.symbolicResultToOutput
|
||||||
| ("sample", [EvDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist, ~env)
|
| ("sample", [EvDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist, ~env)
|
||||||
|
| ("sampleN", [EvDistribution(dist), EvNumber(n)]) =>
|
||||||
|
Some(FloatArray(GenericDist.sampleN(dist, Belt.Int.fromFloat(n))))
|
||||||
| ("mean", [EvDistribution(dist)]) => Helpers.toFloatFn(#Mean, dist, ~env)
|
| ("mean", [EvDistribution(dist)]) => Helpers.toFloatFn(#Mean, dist, ~env)
|
||||||
| ("integralSum", [EvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env)
|
| ("integralSum", [EvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist, ~env)
|
||||||
| ("toString", [EvDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env)
|
| ("toString", [EvDistribution(dist)]) => Helpers.toStringFn(ToString, dist, ~env)
|
||||||
|
@ -336,6 +338,7 @@ let genericOutputToReducerValue = (o: DistributionOperation.outputType): result<
|
||||||
| Float(d) => Ok(EvNumber(d))
|
| Float(d) => Ok(EvNumber(d))
|
||||||
| String(d) => Ok(EvString(d))
|
| String(d) => Ok(EvString(d))
|
||||||
| Bool(d) => Ok(EvBool(d))
|
| Bool(d) => Ok(EvBool(d))
|
||||||
|
| FloatArray(d) => Ok(EvArray(d |> E.A.fmap(r => ReducerInterface_ExpressionValue.EvNumber(r))))
|
||||||
| GenDistError(err) => Error(REDistributionError(err))
|
| GenDistError(err) => Error(REDistributionError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user