法算专题

利用蒙特卡罗法算PI,并绘制曲线图和散点图

原理 落在圆内的概率=圆与正方形面积之比=0.25Π 先上图 绘制折线图 import randomimport matplotlib.pyplot as plt#原理 落在圆内的概率=圆与正方形面积之比=0.25Π# total指代在圆里面晒的豆子数def pi(total):count = 0for i in range(total):x = random.random()