Minor name changes
This commit is contained in:
		
							parent
							
								
									8421892d1d
								
							
						
					
					
						commit
						194dcbd937
					
				| 
						 | 
					@ -31,15 +31,16 @@ let yPointCont = (y: yPoint) =>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module type dist = {
 | 
					module type dist = {
 | 
				
			||||||
  type t;
 | 
					  type t;
 | 
				
			||||||
  type integral;
 | 
					 | 
				
			||||||
  let minX: t => option(float);
 | 
					  let minX: t => option(float);
 | 
				
			||||||
  let maxX: t => option(float);
 | 
					  let maxX: t => option(float);
 | 
				
			||||||
  let pointwiseFmap: (float => float, t) => t;
 | 
					  let pointwiseFmap: (float => float, t) => t;
 | 
				
			||||||
  let xToY: (float, t) => yPoint;
 | 
					  let xToY: (float, t) => yPoint;
 | 
				
			||||||
  let xToIntegralY: (~cache: option(integral), float, t) => float;
 | 
					 | 
				
			||||||
  let shape: t => DistributionTypes.shape;
 | 
					  let shape: t => DistributionTypes.shape;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  type integral;
 | 
				
			||||||
  let integral: (~cache: option(integral), t) => integral;
 | 
					  let integral: (~cache: option(integral), t) => integral;
 | 
				
			||||||
  let integralSum: (~cache: option(integral), t) => float;
 | 
					  let integralSum: (~cache: option(integral), t) => float;
 | 
				
			||||||
 | 
					  let integralXtoY: (~cache: option(integral), float, t) => float;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module Dist = (T: dist) => {
 | 
					module Dist = (T: dist) => {
 | 
				
			||||||
| 
						 | 
					@ -48,11 +49,15 @@ module Dist = (T: dist) => {
 | 
				
			||||||
  let minX = T.minX;
 | 
					  let minX = T.minX;
 | 
				
			||||||
  let maxX = T.maxX;
 | 
					  let maxX = T.maxX;
 | 
				
			||||||
  let pointwiseFmap = T.pointwiseFmap;
 | 
					  let pointwiseFmap = T.pointwiseFmap;
 | 
				
			||||||
  let xToIntegralY = T.xToIntegralY;
 | 
					 | 
				
			||||||
  let xToY = T.xToY;
 | 
					  let xToY = T.xToY;
 | 
				
			||||||
  let shape = T.shape;
 | 
					  let shape = T.shape;
 | 
				
			||||||
  let integral = T.integral;
 | 
					
 | 
				
			||||||
  let integralSum = T.integralSum;
 | 
					  module Integral = {
 | 
				
			||||||
 | 
					    type t = T.integral;
 | 
				
			||||||
 | 
					    let get = T.integral;
 | 
				
			||||||
 | 
					    let xToY = T.integralXtoY;
 | 
				
			||||||
 | 
					    let sum = T.integralSum;
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module Continuous =
 | 
					module Continuous =
 | 
				
			||||||
| 
						 | 
					@ -70,7 +75,7 @@ module Continuous =
 | 
				
			||||||
    let shape = (t: t): DistributionTypes.shape => Continuous(t);
 | 
					    let shape = (t: t): DistributionTypes.shape => Continuous(t);
 | 
				
			||||||
    let xToY = (f, t) =>
 | 
					    let xToY = (f, t) =>
 | 
				
			||||||
      CdfLibrary.Distribution.findY(f, t) |> (e => Continuous(e));
 | 
					      CdfLibrary.Distribution.findY(f, t) |> (e => Continuous(e));
 | 
				
			||||||
    let xToIntegralY = (~cache, f, t) =>
 | 
					    let integralXtoY = (~cache, f, t) =>
 | 
				
			||||||
      t |> integral(~cache) |> CdfLibrary.Distribution.findY(f);
 | 
					      t |> integral(~cache) |> CdfLibrary.Distribution.findY(f);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +83,8 @@ module Discrete =
 | 
				
			||||||
  Dist({
 | 
					  Dist({
 | 
				
			||||||
    type t = DistributionTypes.discreteShape;
 | 
					    type t = DistributionTypes.discreteShape;
 | 
				
			||||||
    type integral = DistributionTypes.continuousShape;
 | 
					    type integral = DistributionTypes.continuousShape;
 | 
				
			||||||
    let integral = (~cache, t) => t |> Shape.Discrete.integrate;
 | 
					    let integral = (~cache, t) =>
 | 
				
			||||||
 | 
					      cache |> E.O.default(t |> Shape.Discrete.integrate);
 | 
				
			||||||
    let integralSum = (~cache, t) => t |> Shape.XYShape.ySum;
 | 
					    let integralSum = (~cache, t) => t |> Shape.XYShape.ySum;
 | 
				
			||||||
    let minX = Shape.XYShape.minX;
 | 
					    let minX = Shape.XYShape.minX;
 | 
				
			||||||
    let maxX = Shape.XYShape.maxX;
 | 
					    let maxX = Shape.XYShape.maxX;
 | 
				
			||||||
| 
						 | 
					@ -86,7 +92,7 @@ module Discrete =
 | 
				
			||||||
    let shape = (t: t): DistributionTypes.shape => Discrete(t);
 | 
					    let shape = (t: t): DistributionTypes.shape => Discrete(t);
 | 
				
			||||||
    let xToY = (f, t) =>
 | 
					    let xToY = (f, t) =>
 | 
				
			||||||
      CdfLibrary.Distribution.findY(f, t) |> (e => Discrete(e));
 | 
					      CdfLibrary.Distribution.findY(f, t) |> (e => Discrete(e));
 | 
				
			||||||
    let xToIntegralY = (~cache, f, t) =>
 | 
					    let integralXtoY = (~cache, f, t) =>
 | 
				
			||||||
      t |> Shape.XYShape.accumulateYs |> CdfLibrary.Distribution.findY(f);
 | 
					      t |> Shape.XYShape.accumulateYs |> CdfLibrary.Distribution.findY(f);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,21 +148,21 @@ module Mixed =
 | 
				
			||||||
      switch (cache) {
 | 
					      switch (cache) {
 | 
				
			||||||
      | Some(cache) => 3.0
 | 
					      | Some(cache) => 3.0
 | 
				
			||||||
      | None =>
 | 
					      | None =>
 | 
				
			||||||
        Discrete.integralSum(~cache=None, discrete)
 | 
					        Discrete.Integral.sum(~cache=None, discrete)
 | 
				
			||||||
        *. discreteProbabilityMassFraction
 | 
					        *. discreteProbabilityMassFraction
 | 
				
			||||||
        +. Continuous.integralSum(~cache=None, continuous)
 | 
					        +. Continuous.Integral.sum(~cache=None, continuous)
 | 
				
			||||||
        *. (1.0 -. discreteProbabilityMassFraction)
 | 
					        *. (1.0 -. discreteProbabilityMassFraction)
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let xToIntegralY =
 | 
					    let integralXtoY =
 | 
				
			||||||
        (
 | 
					        (
 | 
				
			||||||
          ~cache,
 | 
					          ~cache,
 | 
				
			||||||
          f,
 | 
					          f,
 | 
				
			||||||
          {discrete, continuous, discreteProbabilityMassFraction}: t,
 | 
					          {discrete, continuous, discreteProbabilityMassFraction}: t,
 | 
				
			||||||
        ) => {
 | 
					        ) => {
 | 
				
			||||||
      let cont = Continuous.xToIntegralY(~cache, f, continuous);
 | 
					      let cont = Continuous.Integral.xToY(~cache, f, continuous);
 | 
				
			||||||
      let discrete = Discrete.xToIntegralY(~cache, f, discrete);
 | 
					      let discrete = Discrete.Integral.xToY(~cache, f, discrete);
 | 
				
			||||||
      discrete
 | 
					      discrete
 | 
				
			||||||
      *. discreteProbabilityMassFraction
 | 
					      *. discreteProbabilityMassFraction
 | 
				
			||||||
      +. cont
 | 
					      +. cont
 | 
				
			||||||
| 
						 | 
					@ -189,27 +195,27 @@ module Shape =
 | 
				
			||||||
      Shape.T.mapToAll(
 | 
					      Shape.T.mapToAll(
 | 
				
			||||||
        t,
 | 
					        t,
 | 
				
			||||||
        (
 | 
					        (
 | 
				
			||||||
          Mixed.integral(~cache),
 | 
					          Mixed.Integral.get(~cache),
 | 
				
			||||||
          Discrete.integral(~cache),
 | 
					          Discrete.Integral.get(~cache),
 | 
				
			||||||
          Continuous.integral(~cache),
 | 
					          Continuous.Integral.get(~cache),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    let integralSum = (~cache, t: t) =>
 | 
					    let integralSum = (~cache, t: t) =>
 | 
				
			||||||
      Shape.T.mapToAll(
 | 
					      Shape.T.mapToAll(
 | 
				
			||||||
        t,
 | 
					        t,
 | 
				
			||||||
        (
 | 
					        (
 | 
				
			||||||
          Mixed.integralSum(~cache),
 | 
					          Mixed.Integral.sum(~cache),
 | 
				
			||||||
          Discrete.integralSum(~cache),
 | 
					          Discrete.Integral.sum(~cache),
 | 
				
			||||||
          Continuous.integralSum(~cache),
 | 
					          Continuous.Integral.sum(~cache),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    let xToIntegralY = (~cache, f, t) => {
 | 
					    let integralXtoY = (~cache, f, t) => {
 | 
				
			||||||
      Shape.T.mapToAll(
 | 
					      Shape.T.mapToAll(
 | 
				
			||||||
        t,
 | 
					        t,
 | 
				
			||||||
        (
 | 
					        (
 | 
				
			||||||
          Mixed.xToIntegralY(~cache, f),
 | 
					          Mixed.Integral.xToY(~cache, f),
 | 
				
			||||||
          Discrete.xToIntegralY(~cache, f),
 | 
					          Discrete.Integral.xToY(~cache, f),
 | 
				
			||||||
          Continuous.xToIntegralY(~cache, f),
 | 
					          Continuous.Integral.xToY(~cache, f),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
| 
						 | 
					@ -241,8 +247,8 @@ module WithMetadata =
 | 
				
			||||||
    let integral = (~cache, t: t) =>
 | 
					    let integral = (~cache, t: t) =>
 | 
				
			||||||
      fromShape(Continuous(t.integralCache), t);
 | 
					      fromShape(Continuous(t.integralCache), t);
 | 
				
			||||||
    let integralSum = (~cache, t: t) =>
 | 
					    let integralSum = (~cache, t: t) =>
 | 
				
			||||||
      t |> shape |> Shape.integralSum(~cache=Some(t.integralCache));
 | 
					      t |> shape |> Shape.Integral.sum(~cache=Some(t.integralCache));
 | 
				
			||||||
    let xToIntegralY = (~cache, f, t) => {
 | 
					    let integralXtoY = (~cache, f, t) => {
 | 
				
			||||||
      3.0;
 | 
					      3.0;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user