Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I = 1000
- def tirage_seq
- counter = 0
- n = 0
- loop do
- counter += 1 if [0, 1].sample == 1
- n += 1
- break if counter == 10
- end
- n
- end
- def gen_str
- 10.times.reduce('') { |memo, _| memo + ['0', '1'].sample }
- end
- def tirage_bloc
- n = 0
- loop do
- n += 1
- break if gen_str == '1111111111'
- end
- n
- end
- sum_seq = sum_bloc = 0
- I.times do
- sum_seq += tirage_seq
- sum_bloc += tirage_bloc
- end
- puts "Tirage en séquence : #{sum_seq / I}"
- puts "Tirage par blocs : #{sum_bloc / I}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement