lundi 7 mars 2016

I wrote a simple random number generator, how can I graph the distribution of the function I wrote?

This is my first time writing a random number generator and I was just messing around to see what I can do with just random formulas.

I am curious, however, with how bias my function is and with the distribution of the function (between 1 through 9). Here is my unnecessarily long code:

import time

class Random:
    """random generator"""

    def __init__(self):
        """ Random()-> create a random number generator with a random seed
        a seed is needed in order to generate random numbers"""
        self.seed = time.time()

    def random(self):
        """ Random.random() -> get a random number using a formula"""
        self.seed =(((int(self.seed)*129381249123+2019383)**0.74123)/517247) % 288371

    def get_ran_num(self):
        """ Random.get_ran_num() -> return a random integer from 1 thru 10"""
        self.random()
        return int(list(str(int(self.seed)))[3])


ranNum = Random()

It would be great if there exist some tools that can take a random function and then run it some thousand times and then graph the distribution of it.

Thank you in advance

p/s: How can I improve my RNG and make it even random-er?




Aucun commentaire:

Enregistrer un commentaire