search

Home  >  Q&A  >  body text

python3.x - Python随机数生成器的正确用法应该是什么

PHP中文网PHP中文网2824 days ago777

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-18 09:26:33

    The expected value is the average of a large number of experiments. This is just a single experiment. The reason why you get 0 several times is because the variance is very large, and the results are mainly distributed between large numbers and 0. The probability that the result is not 0 is the probability that 0 does not appear among 100 random numbers. This is 0.9 raised to the 100th power, which is about 0.000026. According to the theorem of large numbers (or some other theorem), this semester’s mathematical statistics and probability theory Hang up

    reply
    0
  • 阿神

    阿神2017-04-18 09:26:33

    Your random number is correct, there is something wrong with your program. In your y*=x line, as long as one x randomly reaches 0, the final y will be 0. If you loop 100 times, x will definitely reach 0 randomly. This is elementary school multiplication problem, classmate

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 09:26:33

    I suggest you take another look at the Theorem of Large Numbers. The hundred times you have here are just one experiment, and you need an outer loop. . .

    reply
    0
  • Cancelreply