I want to be able to generate my own random numbers without using the random module. I want to do this that way I can learn somewhat how to do the big boy code on my own.

Recommended Answers

All 2 Replies


There is even a link to an algorithm with a psuedocode implementation.

Personally, I think you should find something else to work on. I think reimplementing established algorithms will provide little educational value.

Best way to create one is to not to.

Pseudo-random number generators are a very complex subject, so it's better off to use the implementations produced by the people that have a good understanding of the subject.

Python uses the Mersenne twister as the core generator. It produces 53-bit precision floats and has a period of 2**19937-1.
The underlying implementation in C is both fast and threadsafe.

You can of course look at all code for python.

Pitfalls in Random Number Generation

def get_random_number():
    '''Chosen bye a fair dice roll,guaranteed to be random'''
    return 4
commented: nice post +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.