from scipy import stats
import math
def gaussian_random(mu, sigma):
return stats.norm.rvs(mu, sigma)
def calc_point(mu, sigma, max_limit):
def calc():
g = gaussian_random(mu, sigma)
g = round(g)
return g
while True:
ret = calc()
if ret >= 0 and ret <= max_limit:
return ret
def point_test(mu, sigma, max_limit, count):
ret = []
for i in xrange(0, count):
ret.append(calc_point(mu, sigma, max_limit))
return ret
# 抽選回数
TRY_COUNT = 5000
# 最頻値
MU = 0
# 標準偏差
SIGMA = 2.4
# 上限値
LIMIT = 10
######################################################
points = point_test(MU, SIGMA, LIMIT, TRY_COUNT);
wins = len(filter(lambda x: x > 0, points))
ret = hist(points, LIMIT * 2, rwidth=1)
xlabel('Atari Point')
ylabel('Count')
point_sum = reduce(lambda x, y: x + y, points)
print u"抽選回数:%i" % TRY_COUNT
print u"あたり回数: %s, (%s%%)" % (wins, 100.0*wins/len(points))
print u"発行ポイント数:%i" % point_sum
print u"コスト(円):%s" % (2.5 * point_sum)
抽選回数:5000 あたり回数: 3614, (72.28%) 発行ポイント数:8359 コスト(円):20897.5