1 Star 0 Fork 0

自由民/feymanCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
randomwalk.py 431 Bytes
一键复制 编辑 原始数据 按行查看 历史
自由民 提交于 2018-04-02 12:09 . 费曼物理学讲义的Python程序
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
n = int(input('请输入模拟次数:'))
distance = np.zeros(n)
step = np.random.randint(2,size=n)
z = np.zeros(n)
for i in range(1, n):
if step[i] == 1:
distance[i] = distance[i-1] + step[i]
else:
distance[i] = distance[i-1] - 1
z[i] = np.sqrt(i)
dis = np.sqrt(distance**2)
x = np.linspace(1, n, n)
plt.plot(x, dis, x, z)
plt.savefig( 'walk.png')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zwdnet/feymanCode.git
git@gitee.com:zwdnet/feymanCode.git
zwdnet
feymanCode
feymanCode
master

搜索帮助