Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:57:26+00:00 2026-06-10T10:57:26+00:00

So I’m testing an calculating the probabilities of certain dice rolls, for a game.

  • 0

So I’m testing an calculating the probabilities of certain dice rolls, for a game.
The base case if that rolling one 10sided die.

I did a million samples of this, and ended up with the following proportions:

Result
0       0.000000000000000%
1       10.038789961210000%
2       10.043589956410000%
3       9.994890005110000%
4       10.025289974710000%
5       9.948090051909950%
6       9.965590034409970%
7       9.990190009809990%
8       9.985490014509990%
9       9.980390019609980%
10      10.027589972410000%

These should of course all be 10%.
There is a standard deviation of 0.0323207% in these results.
that, to me, seems rather high.
Is it just coincidence?
As I understand it the random module accesses proper pseudo-random numbers.
Ie ones from a method that pass the statistical tests to be random.
Or are these pseudo-pseudo-random number generators

Should I be using cryptographic pseudo-random number generators?
I’m fairly sure I don’t need a true random number generator (see http://www.random.org/, http://en.wikipedia.org/wiki/Hardware_random_number_generator).

I am currently regenerating all my results with 1 billion samples,
(cos why not, I have a crunchy server at my disposal, and some sleep to do)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:57:27+00:00Added an answer on June 10, 2026 at 10:57 am

    Martijn’s answer is a pretty succinct review of the random number generators that Python has access to.

    If you want to check out the properties of the generated pseudo-random data, download random.zip from http://www.fourmilab.ch/random/, and run it on a big sample of random data. Especially the χ² (chi squared) test is very sensitive to randomness. For a sequence to be really random, the percentage from the χ² test should be between 10% and 90%.

    For a game I’d guess that the Mersenne Twister that Python uses internally should be sufficiently random (unless you’re building an online casino :-).

    If you want pure randomness, and if you are using Linux, you can read from /dev/random. This only produces random data from the kernel’s entropy pool (which is gathered from the unpredictable times that interrupts arrive), so it will block if you exhaust it. This entropy is used to initialize (seed) the PRNG used by /dev/urandom. On FreeBSD, the PRNG that supplies data for /dev/random uses the Yarrow algorithm, which is generally regarded as being cryptographically secure.

    Edit: I ran some tests on bytes from random.randint. First creating a million random bytes:

    import random
    ba = bytearray([random.randint(0,255) for n in xrange(1000000)])
    with open('randint.dat', 'w+') as f:
        f.write(ba)
    

    Then I ran the ent program from Fourmilab on it:

    Entropy = 7.999840 bits per byte.
    
    Optimum compression would reduce the size
    of this 1000000 byte file by 0 percent.
    
    Chi square distribution for 1000000 samples is 221.87, and randomly
    would exceed this value 93.40 percent of the times.
    
    Arithmetic mean value of data bytes is 127.5136 (127.5 = random).
    Monte Carlo value for Pi is 3.139644559 (error 0.06 percent).
    Serial correlation coefficient is -0.000931 (totally uncorrelated = 0.0).
    

    Now for the χ² test, the further you get from 50%, the more suspect the data is. If one is very fussy, values <10% or >90% are deemed unacceptable. John Walker, author of ent calls this value “almost suspect”.

    As a contrast, here is the same analysis of 10 MiB from FreeBSD’s Yarrow prng that I ran earlier:

    Entropy = 7.999982 bits per byte.
    
    Optimum compression would reduce the size
    of this 10485760 byte file by 0 percent.
    
    Chi square distribution for 10485760 samples is 259.03, and randomly
    would exceed this value 41.80 percent of the times.
    
    Arithmetic mean value of data bytes is 127.5116 (127.5 = random).
    Monte Carlo value for Pi is 3.139877754 (error 0.05 percent).
    Serial correlation coefficient is -0.000296 (totally uncorrelated = 0.0).
    

    While there seems not much difference in the other data, the χ² precentage is much closer to 50%.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.