How to test a random generator

前端 未结 12 1155
滥情空心
滥情空心 2020-12-24 01:42

I need to test a random number generator which produces numbers randomly. How to make sure the numbers generated are random.

12条回答
  •  情歌与酒
    2020-12-24 02:03

    Use chi-square testing. What language are you using? I can offer a C++ example. Basically

    • Place random numbers in buckets (many times).
    • The number of buckets minus one is the degrees of freedom.
    • Compare the bucket tallies against "expected" tallies, yielding a chi-square result.
    • Use a chi-square calculator to see the probability of getting those results.

提交回复
热议问题