Remove normalizedToDiscrete and normalizedToContinuous

This commit is contained in:
Sebastian Kosch 2020-07-16 20:39:28 -07:00
parent 3e17b0a463
commit 5fb5d2639f
8 changed files with 7 additions and 52 deletions

View File

@ -190,6 +190,10 @@ let percentiles = distPlus => {
let adjustBoth = discreteProbabilityMassFraction => {
let yMaxDiscreteDomainFactor = discreteProbabilityMassFraction;
let yMaxContinuousDomainFactor = 1.0 -. discreteProbabilityMassFraction;
// use the bigger proportion, such that whichever is the bigger proportion, the yMax is 1.
let yMax = (yMaxDiscreteDomainFactor > 0.5 ? yMaxDiscreteDomainFactor : yMaxContinuousDomainFactor);
(
yMax /. yMaxDiscreteDomainFactor,
@ -231,8 +235,10 @@ module DistPlusChart = {
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
let discreteProbabilityMassFraction =
distPlus |> DistPlus.T.toDiscreteProbabilityMassFraction;
let (yMaxDiscreteDomainFactor, yMaxContinuousDomainFactor) =
adjustBoth(discreteProbabilityMassFraction);
<DistributionPlot
xScale={config.xLog ? "log" : "linear"}
yScale={config.yLog ? "log" : "linear"}

View File

@ -427,7 +427,7 @@ export class DistPlotD3 {
addLollipopsChart(common) {
const data = this.getDataPoints('discrete');
const yMin = 0.; //d3.min(this.attrs.data.discrete.ys);
const yMin = 0.;
const yMax = d3.max(this.attrs.data.discrete.ys);
// X axis.

View File

@ -223,9 +223,6 @@ module T =
|> updateIntegralSumCache(Some(1.0));
};
let normalizedToContinuous = t => Some(t |> normalize);
let normalizedToDiscrete = _ => None;
let mean = (t: t) => {
let indefiniteIntegralStepwise = (p, h1) => h1 *. p ** 2.0 /. 2.0;
let indefiniteIntegralLinear = (p, a, b) =>

View File

@ -173,9 +173,6 @@ module T =
|> updateIntegralSumCache(Some(1.0));
};
let normalizedToContinuous = _ => None;
let normalizedToDiscrete = t => Some(t); // TODO: this should be normalized!
let downsample = (i, t: t): t => {
// It's not clear how to downsample a set of discrete points in a meaningful way.
// The best we can do is to clip off the smallest values.

View File

@ -69,30 +69,6 @@ module T =
t |> updateShape(truncatedShape);
};
// TODO: is this still needed?
let normalizedToContinuous = (t: t) => {
t
|> toShape
|> Shape.T.normalizedToContinuous
|> E.O.fmap(
Continuous.T.mapY(
domainIncludedProbabilityMassAdjustment(t),
),
);
};
// TODO: is this still needed?
let normalizedToDiscrete = (t: t) => {
t
|> toShape
|> Shape.T.normalizedToDiscrete
|> E.O.fmap(
Discrete.T.mapY(
domainIncludedProbabilityMassAdjustment(t),
),
);
};
let xToY = (f, t: t) =>
t
|> toShape

View File

@ -10,8 +10,6 @@ module type dist = {
let toContinuous: t => option(DistTypes.continuousShape);
let toDiscrete: t => option(DistTypes.discreteShape);
let normalize: t => t;
let normalizedToContinuous: t => option(DistTypes.continuousShape);
let normalizedToDiscrete: t => option(DistTypes.discreteShape);
let toDiscreteProbabilityMassFraction: t => float;
let downsample: (int, t) => t;
let truncate: (option(float), option(float), t) => t;
@ -43,8 +41,6 @@ module Dist = (T: dist) => {
let toDiscrete = T.toDiscrete;
let normalize = T.normalize;
let truncate = T.truncate;
let normalizedToContinuous = T.normalizedToContinuous;
let normalizedToDiscrete = T.normalizedToDiscrete;
let mean = T.mean;
let variance = T.variance;

View File

@ -135,11 +135,6 @@ module T =
{...t, discrete: downsampledDiscrete, continuous: downsampledContinuous};
};
let normalizedToContinuous = (t: t) => Some(normalize(t).continuous);
let normalizedToDiscrete = ({discrete} as t: t) =>
Some(normalize(t).discrete);
let integral = (t: t) => {
switch (t.integralCache) {
| Some(cache) => cache

View File

@ -148,18 +148,6 @@ module T =
Continuous.T.toDiscreteProbabilityMassFraction,
));
let normalizedToDiscrete =
mapToAll((
Mixed.T.normalizedToDiscrete,
Discrete.T.normalizedToDiscrete,
Continuous.T.normalizedToDiscrete,
));
let normalizedToContinuous =
mapToAll((
Mixed.T.normalizedToContinuous,
Discrete.T.normalizedToContinuous,
Continuous.T.normalizedToContinuous,
));
let minX = mapToAll((Mixed.T.minX, Discrete.T.minX, Continuous.T.minX));
let integral =
mapToAll((