• Hey Trainers! Be sure to check out Corsola Beach, our newest section on the forums, in partnership with our friends at Corsola Cove! At the Beach, you can discuss the competitive side of the games, post your favorite Pokemon memes, and connect with other Pokemon creators!
  • Due to the recent changes with Twitter's API, it is no longer possible for Bulbagarden forum users to login via their Twitter account. If you signed up to Bulbagarden via Twitter and do not have another way to login, please contact us here with your Twitter username so that we can get you sorted.

Post your current Ctrl+V (v2)

from random import uniform # This is the uniform distribution library. For more informtion, see 9.6. random — Generate pseudo-random numbers — Python 2.7.13 documentation

class results(object):

def __init__(self, integral, error):
self.integral = integral
self.error = error

def integral(self):
return self.integral

def error(self):
return self.error

def monteCarloUniform(function, N, a, b):

sumTotal = 0
sumTotalSquared = 0
xi = 0
for i in range(0, N-1):
xi = uniform(a,b)
sumTotal += function(xi)
sumTotalSquared += function(xi) ** 2

integral = sumTotal / N * (b-a)
error = 1/N * (1/N * sumTotalSquared - (sumTotal / N) ** 2)

result = results(integral, error)

return result

test = monteCarloUniform(sin, 1000, 0, pi)
print(test.integral)
# print(test.error)
 
Eelektrik 14
Eelektross 14
Ekans 5 -> 4
Electivire 12
Electrike 9
Elekid 12
Elgyem 12
Emboar 12
Emolga 13
Empoleon 16
Entei 12
Escavalier 16
Espeon 13
Espurr 5 -> 4
Excadrill 17 +> 18
Exeggcute 12
Exeggutor 8
Exploud 16
 
PY42Bh7.png
 
Back
Top Bottom