Add log function to Squiggle
This commit is contained in:
parent
06eb8b6a44
commit
b297c692cd
|
@ -9,4 +9,8 @@ describe("A simple result", () => {
|
|||
console.log(foo.value.hd.VAL)
|
||||
expect(1).toEqual(1);
|
||||
});
|
||||
test("log(1) = 0", () => {
|
||||
let foo = js.run("log(1)");
|
||||
expect(foo).toEqual({ tag: 'Ok', value: { hd: { NAME: 'Float', VAL: 0}, tl: 0}});
|
||||
})
|
||||
});
|
||||
|
|
|
@ -186,6 +186,17 @@ let all = [
|
|||
},
|
||||
(),
|
||||
),
|
||||
Function.T.make(
|
||||
~name="log",
|
||||
~outputType=#Float,
|
||||
~inputTypes=[#Float],
|
||||
~run=x =>
|
||||
switch x {
|
||||
| [#Float(a)] => Ok(#SymbolicDist(#Float(Js.Math.log(a))))
|
||||
| e => wrongInputsError(e)
|
||||
},
|
||||
(),
|
||||
),
|
||||
makeDistFloat("pdf", (dist, float) => floatFromDist(#Pdf(float), dist)),
|
||||
makeDistFloat("inv", (dist, float) => floatFromDist(#Inv(float), dist)),
|
||||
makeDistFloat("cdf", (dist, float) => floatFromDist(#Cdf(float), dist)),
|
||||
|
|
Loading…
Reference in New Issue
Block a user