Qiita Teams that are logged in
You are not logged in to any team

Community
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@red-San

# 松尾研のDeep Learning基礎講座演習コンテンツをやってみた(Chap.2-総合)

More than 1 year has passed since last update.

さぁ、こっからはやっと実際的なことができるはずです！
オレはようやくのぼりはじめたばかりだからな このはてしなく遠いデータサイエンス坂をよ…

で、今回は解答だけなので折りたたまないよ。

# 総合問題

``````#(1)
import math

random.seed(0)
#生成
x=np.random.uniform(0.0,1.0,10000)
y=np.random.uniform(0.0,1.0,10000)
``````
``````#(2)
#math.hypotでの判別
in_circle_index=[i for i in range(0,len(x)) if math.hypot(x[i],y[i])<1]
out_circle_index=[i for i in range(0,len(y)) if math.hypot(x[i],y[i])>=1]
#indexからx,yをとる
in_circle_x=[x[in_circle_index]]
in_circle_y=[y[in_circle_index]]

out_circle_x=[x[out_circle_index]]
out_circle_y=[y[out_circle_index]]
#視覚化
plt.plot(in_circle_x,in_circle_y,'o',color='Blue')
plt.plot(out_circle_x,out_circle_y,'x',color='Cyan')
xlim=(0,1)
ylim=(0,1)
plt.legend
#数えるのは配列の長さでいい
in_point_number=len(in_circle_index)
print('Number:{}',format(in_point_number))
out_point_number=len(out_circle_index)

``````

``````#(3)
#点の数の比もin:all=π/4:1になるはず。比をとって4倍してみよう
print('π={}',format(4*in_point_number/len(x)))
``````

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away