UNPKG

layerganza

Version:

A feed-forward neural network with injectable layers, activation functions, and optimizers.

26 lines (25 loc) 935 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRandomIntWithZeroMin = exports.getRandomInt = exports.gaussRandom = void 0; /** * Returns a random float who's distribution is gaussian. * * This uses the "Box-Muller transform". More info at: * http://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve * * @returns {number} */ function gaussRandom() { let u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1]. let v = 1 - Math.random(); return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v); } exports.gaussRandom = gaussRandom; function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min) + min); } exports.getRandomInt = getRandomInt; function getRandomIntWithZeroMin(max) { return Math.floor(Math.random() * max); } exports.getRandomIntWithZeroMin = getRandomIntWithZeroMin;