正規分布データセットジェネレータ
データセットの平均: 0.023
データセットの標準偏差: 0.849
function binomialCalc() {
//get input values var mean = document.getElementById('mean').value; var sd = document.getElementById('sd').value; var n = document.getElementById('n').value;
//define function to generate random variables function gen_norm() { var u = 0, v = 0; while(u === 0) u = Math.random(); //Converting [0,1) to (0,1) while(v === 0) v = Math.random(); return Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v ); }
//fill array with values var num = []; for (i = 0; i < n; i++) { num.push(parseFloat(gen_norm()*sd-(-1*mean)).toFixed(2)) } //find mean and sd of values var meanOut = math.mean(num); var sdOut = math.std(num); //output mean and sd document.getElementById('meanOut').innerHTML = meanOut.toFixed(3); document.getElementById('sdOut').innerHTML = sdOut.toFixed(3); //output normally distributed data values var textarea = document.getElementById("output_data"); textarea.value = num.join("\n"); }