Skip to content

Commit 8c63f2b

Browse files
authored
Generator expression instead of list comprehension
I'm learning python and I listened to this video (minute 47:54) https://youtu.be/OSGv2VnC0go?t=47m54s Let's see if I understood well :-D
1 parent 07c7109 commit 8c63f2b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

resampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def trial():
3434

3535
# Probability of the median of 5 samples being in the
3636
# middle two quartiles of the population
37-
trial = lambda : 2500 <= sorted([randrange(10000) for i in range(5)])[2] < 7500
37+
trial = lambda : 2500 <= sorted(randrange(10000) for i in range(5))[2] < 7500
3838
print(sum(trial() for i in range(10000)) / 10000.0) # compare with the beta distribution
3939

4040
# An exact permutation text

0 commit comments

Comments
 (0)