Added sampleN to interface

This commit is contained in:
Ozzie Gooen 2022-05-15 10:52:35 -04:00
parent 3cca106079
commit b2b51c8f46
3 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@ type outputType =
| Dist(genericDist)
| Float(float)
| String(string)
| FloatArray(array<float>)
| Bool(bool)
| GenDistError(error)

View File

@ -14,6 +14,7 @@ type outputType =
| Dist(genericDist)
| Float(float)
| String(string)
| FloatArray(array<float>)
| Bool(bool)
| GenDistError(error)

View File

@ -216,6 +216,9 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall, _environment)
->E.R.bind(r => r(f1, f2, f3))
->SymbolicConstructors.symbolicResultToOutput
| ("sample", [EvDistribution(dist)]) => Helpers.toFloatFn(#Sample, dist)
| ("sampleN", [EvDistribution(dist), EvNumber(n)]) => Some(
FloatArray(GenericDist.sampleN(dist, Belt.Int.fromFloat(n))),
)
| ("mean", [EvDistribution(dist)]) => Helpers.toFloatFn(#Mean, dist)
| ("integralSum", [EvDistribution(dist)]) => Helpers.toFloatFn(#IntegralSum, dist)
| ("toString", [EvDistribution(dist)]) => Helpers.toStringFn(ToString, dist)
@ -315,6 +318,7 @@ let genericOutputToReducerValue = (o: DistributionOperation.outputType): result<
| Float(d) => Ok(EvNumber(d))
| String(d) => Ok(EvString(d))
| Bool(d) => Ok(EvBool(d))
| FloatArray(d) => Ok(EvArray(d |> E.A.fmap(r =>ReducerInterface_ExpressionValue.EvNumber(r))))
| GenDistError(err) => Error(REDistributionError(err))
}