Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move stan_stats to external mcmc-stats package #258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@octokit/rest": "^21.0.0",
"@vercel/analytics": "^1.3.1",
"jszip": "^3.10.1",
"mcmc-stats": "^0.0.1",
"monaco-editor": "^0.52.2",
"plotly.js-cartesian-dist": "^2.35.2",
"pyodide": "^0.27.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import {
SecondaryColoredTableHead,
} from "@SpComponents/StyledTables";
import {
compute_effective_sample_size,
compute_split_potential_scale_reduction,
} from "@SpUtil/stan_stats/stan_stats";
import {
computeMean,
computePercentile,
computeStdDev,
} from "@SpUtil/stan_stats/summaryStats";
effective_sample_size,
split_potential_scale_reduction,
percentile,
mean,
std_deviation,
} from "mcmc-stats";

import { FunctionComponent, useMemo } from "react";

const columns = [
Expand Down Expand Up @@ -94,20 +93,20 @@ const SummaryPanel: FunctionComponent<SummaryProps> = ({
const pDrawsSorted = [...pDraws].sort((a, b) => a - b);
const ess = computeEss(pDraws, drawChainIds);
const rhat = computeRhat(pDraws, drawChainIds);
const stdDev = computeStdDev(pDraws);
const stdDev = std_deviation(pDraws);
const values = columns.map((column) => {
if (column.key === "mean") {
return computeMean(pDraws);
return mean(pDraws);
} else if (column.key === "mcse") {
return stdDev / Math.sqrt(ess);
} else if (column.key === "stdDev") {
return stdDev;
} else if (column.key === "5%") {
return computePercentile(pDrawsSorted, 0.05);
return percentile(pDrawsSorted, 0.05);
} else if (column.key === "50%") {
return computePercentile(pDrawsSorted, 0.5);
return percentile(pDrawsSorted, 0.5);
} else if (column.key === "95%") {
return computePercentile(pDrawsSorted, 0.95);
return percentile(pDrawsSorted, 0.95);
} else if (column.key === "nEff") {
return ess;
} else if (column.key === "nEff/s") {
Expand Down Expand Up @@ -177,13 +176,13 @@ const drawsByChain = (draws: number[], chainIds: number[]): number[][] => {

const computeEss = (x: number[], chainIds: number[]) => {
const draws = drawsByChain(x, chainIds);
const ess = compute_effective_sample_size(draws);
const ess = effective_sample_size(draws);
return ess;
};

const computeRhat = (x: number[], chainIds: number[]) => {
const draws = drawsByChain(x, chainIds);
const rhat = compute_split_potential_scale_reduction(draws);
const rhat = split_potential_scale_reduction(draws);
return rhat;
};

Expand Down
225 changes: 0 additions & 225 deletions gui/src/app/util/stan_stats/fft.ts

This file was deleted.

Loading