mode to determine dist mode to operate in

Value: [1.2 to 4.6]
This commit is contained in:
Quinn Dougherty 2022-04-25 20:55:16 -04:00
parent 1f27ef894c
commit 3367b82eef
3 changed files with 21 additions and 1 deletions

View File

@ -14,6 +14,7 @@ type error =
| OperationError(Operation.Error.t)
| PointSetConversionError(SampleSetDist.pointsetConversionError)
| SparklineError(PointSetTypes.sparklineError) // This type of error is for when we find a sparkline of a discrete distribution. This should probably at some point be actually implemented
| RequestedModeInvalidError
| OtherError(string)
@genType
@ -33,6 +34,7 @@ module Error = {
| OperationError(err) => Operation.Error.toString(err)
| PointSetConversionError(err) => SampleSetDist.pointsetConversionErrorToString(err)
| SparklineError(err) => PointSetTypes.sparklineErrorToString(err)
| RequestedModeInvalidError => `Requested mode invalid`
| OtherError(s) => s
}

View File

@ -5,6 +5,7 @@ type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>
type toSampleSetFn = t => result<SampleSetDist.t, error>
type scaleMultiplyFn = (t, float) => result<t, error>
type pointwiseAddFn = (t, t) => result<t, error>
type asMode = AsSymbolic | AsMontecarlo | AsConvolution
let sampleN = (t: t, n) =>
switch t {
@ -215,7 +216,7 @@ module AlgebraicCombination = {
: Convolution(convOp)
}
let run = (
let run' = (
t1: t,
~toPointSetFn: toPointSetFn,
~toSampleSetFn: toSampleSetFn,
@ -233,6 +234,21 @@ module AlgebraicCombination = {
}
}
}
let run = (
~mode: option<asMode>=?,
t1: t,
~toPointSetFn: toPointSetFn,
~toSampleSetFn: toSampleSetFn,
~arithmeticOperation,
~t2: t,
): result<t, error> => {
let algebraicResult = run'(t1, ~toPointSetFn, ~toSampleSetFn, ~arithmeticOperation, ~t2)
switch mode {
| Some(_) => algebraicResult
| None => Error(RequestedModeInvalidError)
}
}
}
let algebraicCombination = AlgebraicCombination.run

View File

@ -4,6 +4,7 @@ type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>
type toSampleSetFn = t => result<SampleSetDist.t, error>
type scaleMultiplyFn = (t, float) => result<t, error>
type pointwiseAddFn = (t, t) => result<t, error>
type asMode = AsSymbolic | AsMontecarlo | AsConvolution
let sampleN: (t, int) => array<float>
@ -42,6 +43,7 @@ let truncate: (
) => result<t, error>
let algebraicCombination: (
~mode: asMode=?,
t,
~toPointSetFn: toPointSetFn,
~toSampleSetFn: toSampleSetFn,