How to use gaussian - 6 common examples

To help you get started, we’ve selected a few gaussian examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github irskep / stellardream / src / stars.ts View on Github external
export function computeMetallicityValue(aRandomNumber: number, n2: number): number {
  const dist1 = gaussian(0.3, 0.1);
  const dist2 = gaussian(-0.45, 0.1);
  const val1 = dist1.ppf(aRandomNumber);
  const val2 = dist2.ppf(aRandomNumber);
  // According to stats.stackexchange.com there's a super mathy way to
  // combine two Gaussian distributions, but using a weighted choice
  // seems to produce similar results, so whatever.
  return weightedChoice([[val1, 1.5], [val2, 0.5]], n2);
}
github irskep / stellardream / src / stars.ts View on Github external
export function computeMetallicityValue(aRandomNumber: number, n2: number): number {
  const dist1 = gaussian(0.3, 0.1);
  const dist2 = gaussian(-0.45, 0.1);
  const val1 = dist1.ppf(aRandomNumber);
  const val2 = dist2.ppf(aRandomNumber);
  // According to stats.stackexchange.com there's a super mathy way to
  // combine two Gaussian distributions, but using a weighted choice
  // seems to produce similar results, so whatever.
  return weightedChoice([[val1, 1.5], [val2, 0.5]], n2);
}
github downforacross / downforacross.com / src / lib / xword-filler / index.js View on Github external
import _ from 'lodash';
import gaussian from 'gaussian';
import CandidateGrid, {convertToCandidateGrid, convertFromCandidateGrid} from './candidateGrid';
import beamSearch from './beamSearch';
import {getMatches} from './common';
// randomize our word list, to introduce non-determinism early in the process.
// non-determinism is important if we don't to generate the same puzzle every timeI

const normal = gaussian(0, 1);

const sample = (mean, stdev) => Math.max(0.0001, mean + normal.ppf(Math.random()) * stdev);

// scoredWords: an object of shape { word: { score, stdev }, ... }
// returns an object with same keys { word: sampledScore }
const assignScores = (wordlist) => {
  const result = {};
  _.forEach(_.keys(wordlist), (k) => {
    result[k] = sample(wordlist[k].score, wordlist[k].stdev);
  });
  return result;
};

const makeWordlist = (words, score = 30, stdev = 10) => {
  const result = {};
  _.forEach(words, (k) => {
github tayden / VAE-Latent-Space-Explorer / src / containers / App.jsx View on Github external
constructor(props) {
    super(props);
    this.getImage = this.getImage.bind(this);

    this.norm = gaussian(0, 1);

    this.state = {
      model: null,
      digitImg: tf.zeros([28, 28]),
      mu: 0,
      sigma: 0
    };
  }
github yongjun21 / loess / src / index.js View on Github external
}
        fitted.push(math.squeeze(math.multiply(point, fit.beta)))
        residuals.push(fit.residual)
        betas.push(fit.beta.toArray())
        const median = math.median(math.abs(fit.residual))
        wt[idx] = fit.residual.map(r => weightFunc(r, 6 * median, 2))
      })
    }

    const robustWeights = Array(n).fill(math.ones(this.n))
    for (let iter = 0; iter < this.options.iterations; iter++) iterate.bind(this)(robustWeights)

    const output = {fitted, betas, weights}

    if (this.options.band) {
      const z = gaussian(0, 1).ppf(1 - (1 - this.options.band) / 2)
      const halfwidth = weights.map((weight, idx) => {
        const V1 = math.sum(weight)
        const V2 = math.multiply(weight, weight)
        const intervalEstimate = Math.sqrt(math.multiply(math.square(residuals[idx]), weight) / (V1 - V2 / V1))
        return intervalEstimate * z
      })
      Object.assign(output, {halfwidth})
    }

    return output
  }
github mikberg / codenamer / src / score / gaussian.js View on Github external
export default function gaussian(mean, variance = 10) {
  const dist = gauss(mean, variance);
  return words => dist.pdf(
    words.map(w => w.length).reduce((l, r) => l + r, 0)
  );
}

gaussian

A JavaScript model of a Gaussian distribution

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis

Popular gaussian functions