We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 531bcbc commit 1a19ddbCopy full SHA for 1a19ddb
interview_query/Bernoulli Sample.py
@@ -0,0 +1,10 @@
1
+Write a function to get a sample from a Bernoulli trial.
2
+
3
+import random
4
5
+def bernoulli_sample(p):
6
+ x=random.random()
7
+ if x<=p:
8
+ return 1
9
+ else:
10
+ return 0
0 commit comments