Added delta function to produce delta distributions
This commit is contained in:
parent
ed5b7e63f2
commit
18af09ab04
|
@ -219,6 +219,12 @@ module Uniform = {
|
||||||
module Float = {
|
module Float = {
|
||||||
type t = float
|
type t = float
|
||||||
let make = t => #Float(t)
|
let make = t => #Float(t)
|
||||||
|
let makeSafe = t =>
|
||||||
|
if E.Float.isFinite(t) {
|
||||||
|
Ok(#Float(t))
|
||||||
|
} else {
|
||||||
|
Error("Float must be finite")
|
||||||
|
}
|
||||||
let pdf = (x, t: t) => x == t ? 1.0 : 0.0
|
let pdf = (x, t: t) => x == t ? 1.0 : 0.0
|
||||||
let cdf = (x, t: t) => x >= t ? 1.0 : 0.0
|
let cdf = (x, t: t) => x >= t ? 1.0 : 0.0
|
||||||
let inv = (p, t: t) => p < t ? 0.0 : 1.0
|
let inv = (p, t: t) => p < t ? 0.0 : 1.0
|
||||||
|
|
|
@ -179,10 +179,12 @@ let dispatchToGenericOutput = (call: ExpressionValue.functionCall): option<
|
||||||
> => {
|
> => {
|
||||||
let (fnName, args) = call
|
let (fnName, args) = call
|
||||||
switch (fnName, args) {
|
switch (fnName, args) {
|
||||||
| ("exponential" as fnName, [EvNumber(f1)]) =>
|
| ("exponential" as fnName, [EvNumber(f)]) =>
|
||||||
SymbolicConstructors.oneFloat(fnName)
|
SymbolicConstructors.oneFloat(fnName)
|
||||||
->E.R.bind(r => r(f1))
|
->E.R.bind(r => r(f))
|
||||||
->SymbolicConstructors.symbolicResultToOutput
|
->SymbolicConstructors.symbolicResultToOutput
|
||||||
|
| ("delta", [EvNumber(f)]) =>
|
||||||
|
SymbolicDist.Float.makeSafe(f)->SymbolicConstructors.symbolicResultToOutput
|
||||||
| (
|
| (
|
||||||
("normal" | "uniform" | "beta" | "lognormal" | "cauchy" | "to") as fnName,
|
("normal" | "uniform" | "beta" | "lognormal" | "cauchy" | "to") as fnName,
|
||||||
[EvNumber(f1), EvNumber(f2)],
|
[EvNumber(f1), EvNumber(f2)],
|
||||||
|
|
|
@ -198,6 +198,7 @@ module Float = {
|
||||||
let with3DigitsPrecision = Js.Float.toPrecisionWithPrecision(_, ~digits=3)
|
let with3DigitsPrecision = Js.Float.toPrecisionWithPrecision(_, ~digits=3)
|
||||||
let toFixed = Js.Float.toFixed
|
let toFixed = Js.Float.toFixed
|
||||||
let toString = Js.Float.toString
|
let toString = Js.Float.toString
|
||||||
|
let isFinite = Js.Float.isFinite
|
||||||
}
|
}
|
||||||
|
|
||||||
module I = {
|
module I = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user