Merge remote-tracking branch 'origin/master' into improvements/1097
This commit is contained in:
commit
936710cea8
|
@ -1,99 +1,5 @@
|
|||
let adjustBoth = discreteProbabilityMass => {
|
||||
let yMaxDiscreteDomainFactor = discreteProbabilityMass;
|
||||
let yMaxContinuousDomainFactor = 1.0 -. discreteProbabilityMass;
|
||||
let yMax =
|
||||
yMaxDiscreteDomainFactor > yMaxContinuousDomainFactor
|
||||
? yMaxDiscreteDomainFactor : yMaxContinuousDomainFactor;
|
||||
(
|
||||
1.0 /. (yMaxDiscreteDomainFactor /. yMax),
|
||||
1.0 /. (yMaxContinuousDomainFactor /. yMax),
|
||||
);
|
||||
};
|
||||
|
||||
module DistPlusChart = {
|
||||
[@react.component]
|
||||
let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
|
||||
open Distributions.DistPlus;
|
||||
let discrete = distPlus |> T.toScaledDiscrete;
|
||||
let continuous =
|
||||
distPlus
|
||||
|> T.toScaledContinuous
|
||||
|> E.O.fmap(Distributions.Continuous.getShape);
|
||||
let range = T.xTotalRange(distPlus);
|
||||
let minX =
|
||||
switch (T.minX(distPlus), range) {
|
||||
| (Some(min), Some(range)) => Some(min -. range *. 0.001)
|
||||
| _ => None
|
||||
};
|
||||
|
||||
let maxX = T.maxX(distPlus);
|
||||
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
||||
let toDiscreteProbabilityMass =
|
||||
distPlus |> Distributions.DistPlus.T.toDiscreteProbabilityMass;
|
||||
let (yMaxDiscreteDomainFactor, yMaxContinuousDomainFactor) =
|
||||
adjustBoth(toDiscreteProbabilityMass);
|
||||
<DistributionPlot
|
||||
minX
|
||||
maxX
|
||||
yMaxDiscreteDomainFactor
|
||||
yMaxContinuousDomainFactor
|
||||
height=120
|
||||
?discrete
|
||||
?continuous
|
||||
color={`hex("5f6b7e")}
|
||||
onHover
|
||||
timeScale
|
||||
/>;
|
||||
};
|
||||
};
|
||||
|
||||
module IntegralChart = {
|
||||
[@react.component]
|
||||
let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
|
||||
open Distributions.DistPlus;
|
||||
let integral =
|
||||
Distributions.DistPlus.T.toShape(distPlus)
|
||||
|> Distributions.Shape.T.Integral.get(~cache=None);
|
||||
let continuous =
|
||||
integral
|
||||
|> Distributions.Continuous.toLinear
|
||||
|> E.O.fmap(Distributions.Continuous.getShape);
|
||||
let range = T.xTotalRange(distPlus);
|
||||
let minX =
|
||||
switch (T.minX(distPlus), range) {
|
||||
| (Some(min), Some(range)) => Some(min -. range *. 0.001)
|
||||
| _ => None
|
||||
};
|
||||
let maxX = integral |> Distributions.Continuous.T.maxX;
|
||||
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
||||
<DistributionPlot
|
||||
minX
|
||||
maxX
|
||||
height=80
|
||||
?continuous
|
||||
color={`hex("5f6b7e")}
|
||||
timeScale
|
||||
onHover
|
||||
/>;
|
||||
};
|
||||
};
|
||||
|
||||
[@react.component]
|
||||
let make = (~distPlus: DistTypes.distPlus) => {
|
||||
let (x, setX) = React.useState(() => 0.);
|
||||
let chart =
|
||||
React.useMemo1(
|
||||
() => {<DistPlusChart distPlus onHover={r => {setX(_ => r)}} />},
|
||||
[|distPlus|],
|
||||
);
|
||||
let chart2 =
|
||||
React.useMemo1(
|
||||
() => {<IntegralChart distPlus onHover={r => {setX(_ => r)}} />},
|
||||
[|distPlus|],
|
||||
);
|
||||
let table = (distPlus, x) => {
|
||||
<div>
|
||||
chart
|
||||
chart2
|
||||
<table className="table-auto text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -204,7 +110,102 @@ let make = (~distPlus: DistTypes.distPlus) => {
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div />
|
||||
</div>;
|
||||
};
|
||||
|
||||
let adjustBoth = discreteProbabilityMass => {
|
||||
let yMaxDiscreteDomainFactor = discreteProbabilityMass;
|
||||
let yMaxContinuousDomainFactor = 1.0 -. discreteProbabilityMass;
|
||||
let yMax =
|
||||
yMaxDiscreteDomainFactor > yMaxContinuousDomainFactor
|
||||
? yMaxDiscreteDomainFactor : yMaxContinuousDomainFactor;
|
||||
(
|
||||
1.0 /. (yMaxDiscreteDomainFactor /. yMax),
|
||||
1.0 /. (yMaxContinuousDomainFactor /. yMax),
|
||||
);
|
||||
};
|
||||
|
||||
module DistPlusChart = {
|
||||
[@react.component]
|
||||
let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
|
||||
open Distributions.DistPlus;
|
||||
let discrete = distPlus |> T.toScaledDiscrete;
|
||||
let continuous =
|
||||
distPlus
|
||||
|> T.toScaledContinuous
|
||||
|> E.O.fmap(Distributions.Continuous.getShape);
|
||||
let range = T.xTotalRange(distPlus);
|
||||
let minX =
|
||||
switch (T.minX(distPlus), range) {
|
||||
| (Some(min), Some(range)) => Some(min -. range *. 0.001)
|
||||
| _ => None
|
||||
};
|
||||
|
||||
let maxX = T.maxX(distPlus);
|
||||
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
||||
let toDiscreteProbabilityMass =
|
||||
distPlus |> Distributions.DistPlus.T.toDiscreteProbabilityMass;
|
||||
let (yMaxDiscreteDomainFactor, yMaxContinuousDomainFactor) =
|
||||
adjustBoth(toDiscreteProbabilityMass);
|
||||
<DistributionPlot
|
||||
minX
|
||||
maxX
|
||||
yMaxDiscreteDomainFactor
|
||||
yMaxContinuousDomainFactor
|
||||
height=120
|
||||
?discrete
|
||||
?continuous
|
||||
color={`hex("5f6b7e")}
|
||||
onHover
|
||||
timeScale
|
||||
/>;
|
||||
};
|
||||
};
|
||||
|
||||
module IntegralChart = {
|
||||
[@react.component]
|
||||
let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
|
||||
open Distributions.DistPlus;
|
||||
let integral =
|
||||
Distributions.DistPlus.T.toShape(distPlus)
|
||||
|> Distributions.Shape.T.Integral.get(~cache=None);
|
||||
let continuous =
|
||||
integral
|
||||
|> Distributions.Continuous.toLinear
|
||||
|> E.O.fmap(Distributions.Continuous.getShape);
|
||||
let range = T.xTotalRange(distPlus);
|
||||
let minX =
|
||||
switch (T.minX(distPlus), range) {
|
||||
| (Some(min), Some(range)) => Some(min -. range *. 0.001)
|
||||
| _ => None
|
||||
};
|
||||
let maxX = integral |> Distributions.Continuous.T.maxX;
|
||||
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
||||
<DistributionPlot
|
||||
minX
|
||||
maxX
|
||||
height=80
|
||||
?continuous
|
||||
color={`hex("5f6b7e")}
|
||||
timeScale
|
||||
onHover
|
||||
/>;
|
||||
};
|
||||
};
|
||||
|
||||
[@react.component]
|
||||
let make = (~distPlus: DistTypes.distPlus) => {
|
||||
let (x, setX) = React.useState(() => 0.);
|
||||
let chart =
|
||||
React.useMemo1(
|
||||
() => {<DistPlusChart distPlus onHover={r => {setX(_ => r)}} />},
|
||||
[|distPlus|],
|
||||
);
|
||||
let chart2 =
|
||||
React.useMemo1(
|
||||
() => {<IntegralChart distPlus onHover={r => {setX(_ => r)}} />},
|
||||
[|distPlus|],
|
||||
);
|
||||
<div> chart chart2 {table(distPlus, x)} </div>;
|
||||
// chart
|
||||
};
|
|
@ -156,6 +156,9 @@ let _transverseShape = (fn, p: t) => {
|
|||
|> fromArray;
|
||||
};
|
||||
|
||||
let filter = (fn, t: t) =>
|
||||
t |> zip |> E.A.filter(fn) |> Belt.Array.unzip |> fromArray;
|
||||
|
||||
let accumulateYs = _transverseShape((aCurrent, aLast) => aCurrent +. aLast);
|
||||
let subtractYs = _transverseShape((aCurrent, aLast) => aCurrent -. aLast);
|
||||
|
||||
|
|
|
@ -29,7 +29,21 @@ let propValue = (t: Prop.Value.t) => {
|
|||
| Some(distribution) =>
|
||||
<div>
|
||||
<DistPlusPlot distPlus=distribution />
|
||||
{r.guesstimatorString |> ReasonReact.string}
|
||||
<input
|
||||
readOnly=true
|
||||
className="shadow appearance-none border w-1/3 rounded py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||
value={r.guesstimatorString}
|
||||
/>
|
||||
<select
|
||||
defaultValue="years"
|
||||
readOnly=true
|
||||
className="appearance-none w-32 bg-white border border-gray-400 hover:border-gray-500 px-4 py-2 pr-8 rounded shadow leading-tight focus:outline-none focus:shadow-outline">
|
||||
<option> {"years" |> ReasonReact.string} </option>
|
||||
</select>
|
||||
<div
|
||||
className="w-1/3 border w-1/2 rounded py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline bg-white">
|
||||
{"30 to infinity, 80% mass" |> ReasonReact.string}
|
||||
</div>
|
||||
</div>
|
||||
| None => "Something went wrong" |> ReasonReact.string
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user