vendredi 14 décembre 2018

Type error when generating a Geometric distribution (python 3)

I'm creating a class for my personal RNG, but when doing this implementation for the Geometrical one, I keep getting the error : TypeError: unsupported operand type(s) for /: 'method' and 'float' but I cannot find where it is wrong, neither using the documentation for "floor", where I think is the issue.

class mi_rng:
        def __init__ (self, seed=0):
            self.seed= 0
            self.m= 2**32
            self.a= 1664525
            self.c= 1013904223
            self.normal_stored= None
    def geometrica2(self, p):
            return int(floor(log(self.uniforme/log(1.0-p))))
    muestra= [rng.geometrica2(0.7) for _ in range(1000)]
    print("Geometrica 2, media: ", mean(muestra), ", varianza: ", var(muestra))




Aucun commentaire:

Enregistrer un commentaire