python应用-随机漫步
2021-06-17 01:05
标签:width ram att cti pyplot range data 技术分享 atp 对python应用的一个巩固,以及熟悉matplotlib的用法 效果如下: python应用-随机漫步 标签:width ram att cti pyplot range data 技术分享 atp 原文地址:https://www.cnblogs.com/pprp/p/9723030.html# -*- coding: utf-8 -*-
"""
Created on Fri Sep 28 22:39:55 2018
@author: pprp
"""
from random import choice
import matplotlib.pyplot as plt
class RandomWalk():
"""a class using to generate random data"""
def __init__(self,num_points=5000):
"""init the class"""
self.num_points=num_points
# start at (0,0)
self.x_val=[0]
self.y_val=[0]
def fill_walk(self):
"""calculate the points"""
while len(self.x_val)