Minor fix for multimodals
This commit is contained in:
parent
4c33561b7c
commit
7566c59fef
|
@ -304,7 +304,7 @@ let rec toLeaf =
|
|||
let components =
|
||||
r
|
||||
|> E.A.fmap(((dist, weight)) =>
|
||||
`FunctionCall("scaleExp", [|dist, `SymbolicDist(`Float(weight))|]));
|
||||
`FunctionCall("scaleMultiply", [|dist, `SymbolicDist(`Float(weight))|]));
|
||||
let pointwiseSum =
|
||||
components
|
||||
|> Js.Array.sliceFrom(1)
|
||||
|
|
|
@ -91,14 +91,16 @@ let verticalScaling = (scaleOp, rs, scaleBy) => {
|
|||
Operation.Scale.toFn(scaleOp, main, secondary);
|
||||
let integralSumCacheFn = Operation.Scale.toIntegralSumCacheFn(scaleOp);
|
||||
let integralCacheFn = Operation.Scale.toIntegralCacheFn(scaleOp);
|
||||
Ok(`RenderedDist(
|
||||
Shape.T.mapY(
|
||||
~integralSumCacheFn=integralSumCacheFn(scaleBy),
|
||||
~integralCacheFn=integralCacheFn(scaleBy),
|
||||
~fn=fn(scaleBy),
|
||||
rs,
|
||||
Ok(
|
||||
`RenderedDist(
|
||||
Shape.T.mapY(
|
||||
~integralSumCacheFn=integralSumCacheFn(scaleBy),
|
||||
~integralCacheFn=integralCacheFn(scaleBy),
|
||||
~fn=fn(scaleBy),
|
||||
rs,
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
};
|
||||
|
||||
let functions = [|
|
||||
|
@ -152,7 +154,8 @@ let functions = [|
|
|||
~run=
|
||||
fun
|
||||
| [|`SamplingDist(`SymbolicDist(c))|] => Ok(`SymbolicDist(c))
|
||||
| [|`SamplingDist(`RenderedDist(c))|] => Ok(`RenderedDist(Shape.T.normalize(c)))
|
||||
| [|`SamplingDist(`RenderedDist(c))|] =>
|
||||
Ok(`RenderedDist(Shape.T.normalize(c)))
|
||||
| e => wrongInputsError(e),
|
||||
),
|
||||
makeRenderedDistFloat("scaleExp", (dist, float) =>
|
||||
|
|
|
@ -22,7 +22,6 @@ let fnn =
|
|||
) {
|
||||
| (_, Some(`Function(argNames, tt))) =>
|
||||
PTypes.Function.run(evaluationParams, args, (argNames, tt))
|
||||
| ("mm", _)
|
||||
| ("multimodal", _) =>
|
||||
switch (args |> E.A.to_list) {
|
||||
| [`Array(weights), ...dists] =>
|
||||
|
|
|
@ -204,7 +204,8 @@ module MathAdtToDistDst = {
|
|||
let parseArgs = () => parseArray(args);
|
||||
switch (name) {
|
||||
| "lognormal" => lognormal(args, parseArgs, nodeParser)
|
||||
| "mm" =>{
|
||||
| "multimodal"
|
||||
| "mm" =>
|
||||
let weights =
|
||||
args
|
||||
|> E.A.last
|
||||
|
@ -212,20 +213,22 @@ module MathAdtToDistDst = {
|
|||
_,
|
||||
fun
|
||||
| Array(values) => Some(parseArray(values))
|
||||
| _ => None
|
||||
| _ => None,
|
||||
);
|
||||
let possibleDists =
|
||||
E.O.isSome(weights)
|
||||
? Belt.Array.slice(args, ~offset=0, ~len=E.A.length(args) - 1)
|
||||
: args;
|
||||
let dists = parseArray(possibleDists);
|
||||
switch(weights, dists){
|
||||
| (Some(Error(r)), _) => Error(r)
|
||||
| (_, Error(r)) => Error(r)
|
||||
| (None, Ok(dists)) => Ok(`FunctionCall("multimodal", dists))
|
||||
| (Some(Ok(r)), Ok(dists)) => Ok(`FunctionCall("multimodal", E.A.append([|`Array(r)|], dists)))
|
||||
}
|
||||
}
|
||||
switch (weights, dists) {
|
||||
| (Some(Error(r)), _) => Error(r)
|
||||
| (_, Error(r)) => Error(r)
|
||||
| (None, Ok(dists)) => Ok(`FunctionCall(("multimodal", dists)))
|
||||
| (Some(Ok(r)), Ok(dists)) =>
|
||||
Ok(
|
||||
`FunctionCall(("multimodal", E.A.append([|`Array(r)|], dists))),
|
||||
)
|
||||
};
|
||||
| "add"
|
||||
| "subtract"
|
||||
| "multiply"
|
||||
|
|
Loading…
Reference in New Issue
Block a user