Skip to content

Instantly share code, notes, and snippets.

@hatzka-nezumi
Created April 17, 2019 18:45
Show Gist options
  • Save hatzka-nezumi/e50325ce0e5299745fa7d831f7c73c85 to your computer and use it in GitHub Desktop.
Save hatzka-nezumi/e50325ce0e5299745fa7d831f7c73c85 to your computer and use it in GitHub Desktop.
Glover & Glover notoriety simulation
#!/usr/bin/env ruby
require 'average'
simcount = 5000
sims = []
simcount.times do
puts "Starting simulation..."
stage = :none
ticks = 0
while true do
ticks += 1
if stage == :none then
if rand < 0.3 then
puts "Warned after #{ticks} ticks"
stage = :warned
end
elsif stage == :warned then
if rand < 0.7 then
puts "Fired after #{ticks} ticks"
break
end
end
end
sims.push ticks
end
puts "Ran #{simcount} simulations, mean #{sims.mean}, median #{sims.median}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment