dnd5-scripts/generate_npc/norminv.js
2026-06-17 22:32:48 +03:00

13 lines
622 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function generateNormalRandom(mean, stdDev) { // математическое ожидание (mean) и стандартное отклонение (stdDev)
var u1 = Math.random(); // Генерация случайной величины
var u2 = Math.random();
var z0 = Math.sqrt(-2.0 * Math.log(u1)) * Math.cos(2.0 * Math.PI * u2); // Box-Muller transform
// Преобразование в нормальное распределение с указанным мат. ожиданием и стандартным отклонением
return z0 * stdDev + mean;
}
dv.norminv = {
generateNormalRandom
}