Created
April 11, 2021 06:35
-
-
Save Yuuki77/452c08bde3474a1b28b0415eeb762dee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Package main implements scrapping of Git repositories on chromium for | |
storing commit messages and information about contributors | |
*/ | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
) | |
func main() { | |
count := 10 | |
for i := 0; i < count; i++ { | |
n := 1000000 | |
p := 0.0 | |
m := 0.0 | |
for i := 0; i < n; i++ { | |
// between [0, 1] | |
x := rand.Float64() * 2 | |
y := rand.Float64() * 4 | |
// 原点からxyの距離が半径1の円の中に入ってるかどうか | |
// 1なのでルートをはずしても1 | |
if y <= x*x { | |
m++ | |
} | |
// if x*x+y*y <= 1 { | |
// m++ | |
// } | |
} | |
p = 8 * m / float64(n) | |
// m /n で銀杏型の面積がもとまるよ | |
// p = m / float64(n) | |
// p = 4 * m / float64(n) | |
fmt.Println(p) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment