- 29
- 0
- 约6.09千字
- 约 7页
- 2021-08-02 发布于广东
- 举报
Compute the value of π using Monte Carlo
In [7]: %pylab inline
import pandas as pd
import proc
import sys
import fmt
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: [beta]
`%matplotlib` prevents importing * from pylab and numpy
In [3]: def sim_pi(ns) :
es = np.random.uniform(size=[ns[-1], 2])
d = np.array([x*x + y*y 1. for x, y in es])
return np.array([4.*np.sum(d[:n])/n for n in ns])
原创力文档

文档评论(0)