Demo entry 6626755

py

   

Submitted by anonymous on Jun 26, 2017 at 15:36
Language: Python. Code size: 248 Bytes.

#coding=utf8
import numpy as np
import pylab as pl
import math
# 对于2^-i次方,我们可以在0~1之间求关于1/2的对数
data=[]
for i in range(1000):
	data.append(int(math.log(np.random.random_sample(),0.5))+1) 
pl.hist(data)
pl.xlabel('practice 10.1')
pl.show()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).