1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

モンテカルロ法で円周率を求める

Last updated at Posted at 2019-07-14

scratchで試したプログラム

モンテカルロ法とは?

1.円の外側で、ギリギリ円に接触する正方形を使う。
2.正方形のランダムなところに点を打つ。
3.円に触れたかを調べる。式は$x^2+y^2\leqq 1$
4.適当な回数をやったなら6に行く
5.2に戻す
6.$触れた個数 / 打った個数*4$が円周率

感想

とっても簡単でした。
この方法では円周率に近くなるまでに時間がとてもかかりますが、時間がある人はやってみてください。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?