情報
大学生・専門学校生・社会人

Pythonです。
昨日まる一日調べましたが、やはり無い頭で考えても、さっぱり何をどうすれば良いのか分からないので教えてください。
やりたいことは、モンテカルロ法で円周率を求める際の横軸を試行回数、縦軸を円内に点を打った回数です。
なお、写真はこのプログラムを実行したときに出たメッセージです。
import math
import numpy as np
import matplotlib.pyplot as plt

n = 100000

x = np.zeros([n])
y = np.zeros([n])
xin = np.zeros([n])
yin = np.zeros([n])
xout = np.zeros([n])
yout = np.zeros([n])

ins = 0
out = 0

def monte(n,ins): 
result_x = []
result_y = []
for i in range(n):
x[i] = 1-2*np.random.random()
y[i] = 1-2*np.random.random()

if x[i]**2 + y[i]**2 <= 1:
xin[ins] = x[i]
yin[ins] = y[i]
ins += 1

result_x.append(i)
result_y.append(ins)
return result_x, result_y

result = monte(n,ins)
result_x = result[0]
result_y = result[1]
plt.plot(result_x, result_y)
plt.axhline(math.pi, color='r')
plt.xlim([0,result_x])
plt.ylim([0,result_y])

plt.show()

「raceback (most recent caLl tast): FtLe "pt_ftgure.py", Ltne 49。 tn <modute> pLt.xLtm([9,resutt_x]) Ftte "/usr/Ltb/python3/dtst-packages/matptotLtb/pyptot.py", Ltne 1542。 tn xttm ret = ax.set_xttn(*args, **kwargs) Ftte "/usr/Ltb7python3/dtst-packages/matptotLtb/axes/_base.py", Ltne 2962。 tn set_xttm Teft, rtght = mtransforms nonstngutar(teft, rtght。 tncreastng=Fase) Ftte "/usr/Ltb/python3/dtst-packages/matptotLtb/transforms.py"。 Ltne 2964, tn nonstngutar あのiT も症 いい二TR<還3 下はそっ生っ呈Mはも半了I
python

回答

まだ回答がありません。

疑問は解決しましたか?

この質問を見ている人は
こちらの質問も見ています😉