Last active
May 8, 2018 14:37
-
-
Save kyoro1/94c1e68f2b644b8b4fd03e75aa9556ce to your computer and use it in GitHub Desktop.
確率 epsilon で1を出力 ref: https://qiita.com/kyoro1/items/b48e6840d26902098e7f
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
import numpy.random import * | |
## 0~1までの乱数を設定 | |
tmp = rand() | |
if tmp <= epsilon: | |
output = 1 | |
else: | |
output = 0 | |
print(output) |
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
import numpy as np | |
output = np.random.binomial(1,epsilon) |
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
epsilon = 0.2 | |
N = 100 | |
tmp_list = [] | |
for i in range(N): | |
a = np.random.binomial(1, epsilon) | |
tmp_list.append(a) | |
print(sum(tmp_list)/N) #0.22 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment