Added stdev and variance to Distribution Operation Constructors
This commit is contained in:
parent
7d9bae96e1
commit
079553cd71
|
@ -11,6 +11,7 @@ import {
|
|||
import { result, resultMap, Ok } from "./types";
|
||||
import {
|
||||
Constructors_mean,
|
||||
Constructors_stdev,
|
||||
Constructors_sample,
|
||||
Constructors_pdf,
|
||||
Constructors_cdf,
|
||||
|
@ -69,6 +70,10 @@ export class Distribution {
|
|||
return Constructors_mean({ env: this.env }, this.t);
|
||||
}
|
||||
|
||||
stdev(): result<number, distributionError> {
|
||||
return Constructors_stdev({ env: this.env }, this.t);
|
||||
}
|
||||
|
||||
sample(): result<number, distributionError> {
|
||||
return Constructors_sample({ env: this.env }, this.t);
|
||||
}
|
||||
|
|
|
@ -265,6 +265,8 @@ module Constructors = {
|
|||
module C = DistributionTypes.Constructors.UsingDists
|
||||
open OutputLocal
|
||||
let mean = (~env, dist) => C.mean(dist)->run(~env)->toFloatR
|
||||
let stdev = (~env, dist) => C.stdev(dist)->run(~env)->toFloatR
|
||||
let variance = (~env, dist) => C.variance(dist)->run(~env)->toFloatR
|
||||
let sample = (~env, dist) => C.sample(dist)->run(~env)->toFloatR
|
||||
let cdf = (~env, dist, f) => C.cdf(dist, f)->run(~env)->toFloatR
|
||||
let inv = (~env, dist, f) => C.inv(dist, f)->run(~env)->toFloatR
|
||||
|
|
|
@ -49,6 +49,10 @@ module Constructors: {
|
|||
@genType
|
||||
let mean: (~env: env, genericDist) => result<float, error>
|
||||
@genType
|
||||
let stdev: (~env: env, genericDist) => result<float, error>
|
||||
@genType
|
||||
let variance: (~env: env, genericDist) => result<float, error>
|
||||
@genType
|
||||
let sample: (~env: env, genericDist) => result<float, error>
|
||||
@genType
|
||||
let cdf: (~env: env, genericDist, float) => result<float, error>
|
||||
|
|
|
@ -161,6 +161,8 @@ module Constructors = {
|
|||
module UsingDists = {
|
||||
@genType
|
||||
let mean = (dist): t => FromDist(ToFloat(#Mean), dist)
|
||||
let stdev = (dist): t => FromDist(ToFloat(#Stdev), dist)
|
||||
let variance = (dist): t => FromDist(ToFloat(#Variance), dist)
|
||||
let sample = (dist): t => FromDist(ToFloat(#Sample), dist)
|
||||
let cdf = (dist, x): t => FromDist(ToFloat(#Cdf(x)), dist)
|
||||
let inv = (dist, x): t => FromDist(ToFloat(#Inv(x)), dist)
|
||||
|
|
Loading…
Reference in New Issue
Block a user