Skip to content

Instantly share code, notes, and snippets.

@rkichenama
Last active November 20, 2020 14:22
Show Gist options
  • Select an option

  • Save rkichenama/a2c08c4f6ac8e9da21dc2c6c0a4a2d2f to your computer and use it in GitHub Desktop.

Select an option

Save rkichenama/a2c08c4f6ac8e9da21dc2c6c0a4a2d2f to your computer and use it in GitHub Desktop.

Revisions

  1. rkichenama revised this gist Nov 20, 2020. 1 changed file with 10 additions and 8 deletions.
    18 changes: 10 additions & 8 deletions calculations.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,13 @@
    const NormDist = (avg, stdev) => {
    const variance = stdev * stdev;
    const thStdevTau = 1 / (stdev * Math.sqrt(2 * Math.PI));
    const { E, sqrt } = Math;
    const variance = stdev ** 2;
    const stdevTau = stdev * sqrt(2 * Math.PI);
    const doubleVariance = 2 * variance;
    const pdf = (x) => (
    thStdevTau * Math.pow(Math.E, Math.pow(-(x - avg), 2) / doubleVariance)
    );
    return {
    pdf,

    return (x) => {
    const distFromAvg = (x - avg) ** 2;
    return (
    (E ** -(distFromAvg / doubleVariance)) / stdevTau
    );
    };
    };
    };
  2. rkichenama revised this gist Nov 20, 2020. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion calculations.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    const NormDist = (avg, stdev) => {
    pdf (x) { return () ; }
    const variance = stdev * stdev;
    const thStdevTau = 1 / (stdev * Math.sqrt(2 * Math.PI));
    const doubleVariance = 2 * variance;
    const pdf = (x) => (
    thStdevTau * Math.pow(Math.E, Math.pow(-(x - avg), 2) / doubleVariance)
    );
    return {
    pdf,
    };
    };
  3. rkichenama created this gist Nov 19, 2020.
    3 changes: 3 additions & 0 deletions calculations.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    const NormDist = (avg, stdev) => {
    pdf (x) { return () ; }
    };
    3,465 changes: 3,465 additions & 0 deletions data.jsonn
    3,465 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.