Compare commits

...

8 Commits

Author SHA1 Message Date
05ef366a9d Merge branch 'master' of github.com:quantified-uncertainty/squiggle into no-thin-lognormals 2022-06-24 11:32:08 -04:00
2944b0f79f feat: Fix distribution display
Distribution display now keeps to the [0.03, 0.97] confidence interval.

This fixes a longstanding annoying bug.

The [0.03, 0.97] confidence interval was chosen after a bit of testing,
but I have no particular attachment to it.
2022-06-24 11:28:20 -04:00
Ozzie Gooen
a8ad464623
Merge pull request #697 from quantified-uncertainty/develop
Develop -> Master, 14/06/2022
2022-06-14 17:28:25 -07:00
Ozzie Gooen
b63039b803
Merge pull request #675 from quantified-uncertainty/develop
Develop -> Master
2022-06-11 13:38:40 -07:00
Ozzie Gooen
8d9d4f397d
Merge pull request #674 from quantified-uncertainty/develop
June 10th Dev -> Master
2022-06-10 11:39:43 -07:00
Ozzie Gooen
183ec02376
Merge pull request #485 from quantified-uncertainty/develop
Develop -> Master
2022-05-04 17:42:02 -04:00
Quinn
1806ba80fb
Merge pull request #419 from quantified-uncertainty/develop
`master` <-  `develop` sync apr28
2022-04-28 14:13:30 -04:00
Ozzie Gooen
09080f8d73
Merge pull request #296 from quantified-uncertainty/develop
Develop -> Master, April 15
2022-04-15 19:25:41 -04:00

View File

@ -38,8 +38,32 @@ export const DistributionChart: React.FC<DistributionChartProps> = ({
}) => { }) => {
const [isLogX, setLogX] = React.useState(false); const [isLogX, setLogX] = React.useState(false);
const [isExpY, setExpY] = React.useState(false); const [isExpY, setExpY] = React.useState(false);
const shape = distribution.pointSet();
const [sized] = useSize((size) => { const [sized] = useSize((size) => {
const p3wrapped = distribution.inv(0.03);
const p97wrapped = distribution.inv(0.97);
if (p3wrapped.tag == "Error") {
return <ErrorAlert heading="Distribution Calculation Error">
{distributionErrorToString(p3wrapped.value)}
</ErrorAlert>
} else if (p97wrapped.tag == "Error") {
return <ErrorAlert heading="Distribution Calculation Error">
{distributionErrorToString(p97wrapped.value)}
</ErrorAlert>
}
const p3 = p3wrapped.value
const p97 = p97wrapped.value
const truncatedDistributionWrapper = distribution.truncate(p3, p97)
if (truncatedDistributionWrapper.tag == "Error") {
return <ErrorAlert heading="Distribution Truncation For Display Error">
{distributionErrorToString(truncatedDistributionWrapper.value)}
</ErrorAlert>
}
const truncatedDistribution = truncatedDistributionWrapper.value
const shape = truncatedDistribution.pointSet(); //distribution.pointSet();
if (shape.tag === "Error") { if (shape.tag === "Error") {
return ( return (
<ErrorAlert heading="Distribution Error"> <ErrorAlert heading="Distribution Error">
@ -82,10 +106,10 @@ export const DistributionChart: React.FC<DistributionChartProps> = ({
// Check whether we should disable the checkbox // Check whether we should disable the checkbox
{...(massBelow0 {...(massBelow0
? { ? {
disabled: true, disabled: true,
tooltip: tooltip:
"Your distribution has mass lower than or equal to 0. Log only works on strictly positive values.", "Your distribution has mass lower than or equal to 0. Log only works on strictly positive values.",
} }
: {})} : {})}
/> />
<CheckBox label="Exp Y scale" value={isExpY} onChange={setExpY} /> <CheckBox label="Exp Y scale" value={isExpY} onChange={setExpY} />
@ -158,12 +182,12 @@ const SummaryTable: React.FC<SummaryTableProps> = ({ distribution }) => {
const mean = distribution.mean(); const mean = distribution.mean();
const stdev = distribution.stdev(); const stdev = distribution.stdev();
const p5 = distribution.inv(0.05); const p5 = distribution.inv(0.05);
const p10 = distribution.inv(0.1); const p30 = distribution.inv(0.1);
const p25 = distribution.inv(0.25); const p25 = distribution.inv(0.25);
const p50 = distribution.inv(0.5); const p50 = distribution.inv(0.5);
const p75 = distribution.inv(0.75); const p75 = distribution.inv(0.75);
const p90 = distribution.inv(0.9); const p90 = distribution.inv(0.9);
const p95 = distribution.inv(0.95); const p97 = distribution.inv(0.95);
const hasResult = (x: result<number, distributionError>): boolean => const hasResult = (x: result<number, distributionError>): boolean =>
x.tag === "Ok"; x.tag === "Ok";
@ -202,12 +226,12 @@ const SummaryTable: React.FC<SummaryTableProps> = ({ distribution }) => {
<Cell>{unwrapResult(mean)}</Cell> <Cell>{unwrapResult(mean)}</Cell>
{hasResult(stdev) && <Cell>{unwrapResult(stdev)}</Cell>} {hasResult(stdev) && <Cell>{unwrapResult(stdev)}</Cell>}
<Cell>{unwrapResult(p5)}</Cell> <Cell>{unwrapResult(p5)}</Cell>
<Cell>{unwrapResult(p10)}</Cell> <Cell>{unwrapResult(p30)}</Cell>
<Cell>{unwrapResult(p25)}</Cell> <Cell>{unwrapResult(p25)}</Cell>
<Cell>{unwrapResult(p50)}</Cell> <Cell>{unwrapResult(p50)}</Cell>
<Cell>{unwrapResult(p75)}</Cell> <Cell>{unwrapResult(p75)}</Cell>
<Cell>{unwrapResult(p90)}</Cell> <Cell>{unwrapResult(p90)}</Cell>
<Cell>{unwrapResult(p95)}</Cell> <Cell>{unwrapResult(p97)}</Cell>
</tr> </tr>
</tbody> </tbody>
</table> </table>