View Single Post

KeyboardNinja's Avatar


KeyboardNinja
11.03.2012 , 04:04 PM | #23
Curiouser and curiouser…

Code:
ITERATIONS = 1000000

count = 0
prob = 0.4595
hits = 0

ITERATIONS.times do
  i = 0
  while i < 185
    if rand < prob
      hits += 1
      
      if hits >= 10
        count += 1
        i = 185
      end
    else
      hits = 0
    end
    i += 1
  end
  hits = 0
end

puts "count = #{count}"
puts "probability = #{count.to_f / ITERATIONS}"
I had to modify your program somewhat, since it wasn't actually computing the per-fight probability of a consecutive streak. I get the following results from the above:

Code:
count = 39378
probability = 0.039378
Which is neither as high as you predicted, nor as low as I predicted. So, something is clearly wrong with my derivation, but yours isn't correct either. I suspect mine is headed in the right direction, but something went wrong in the middle.
Computer Programmer. Theory Crafter. Streaming Dilettante on The Ebon Hawk.
Tam (shadow tank) Tov-ren (commando healer) Aveo (retired sentinel) Nimri (ruffian scoundrel)
Averith (marksman sniper) Alish (lightning sorcerer) Aresham (vengeance jugg) Effek (pyro pt)