layer-oriented-deep-learning-network-js
Version:
A feed-forward neural network with injectable layers, activation functions, and optimizers.
29 lines (26 loc) • 854 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.gaussRandom = gaussRandom;
exports.getRandomInt = getRandomInt;
exports.getRandomIntWithZeroMin = getRandomIntWithZeroMin;
/**
* 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() {
var u = 1 - Math.random(); // Subtraction to flip [0, 1) to (0, 1].
var v = 1 - Math.random();
return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
function getRandomIntWithZeroMin(max) {
return Math.floor(Math.random() * max);
}