math.random()->是等概率返回【0--1)

/**
 * math.random()->是等概率返回【0--1)
 */
// 验证 math。random是等概率
function r(math){
    var count=0
    for(var i=0;i<math;i++){
        if(Math.random()<0.3){
            count++
        }
    }
    return count/math
}
var math=100000
console.log(r(math));
posted @ 2022-05-24 01:10  NaziriteGTC  阅读(81)  评论(0)    收藏  举报