Created
March 7, 2017 21:42
-
-
Save workmad3/4d5ea6ba1bd6c064ebfb2f65538863d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit = ARGV[2] | |
if unit == "hours" | |
report = 12 | |
dosing_interval = 24 | |
elsif unit == "days" | |
report = 1 | |
dosing_interval = 1 | |
else | |
unit = "days" | |
report = 1 | |
dosing_interval = 1 | |
end | |
half_life = ARGV[0].to_i * dosing_interval | |
period = ARGV[1].to_i * dosing_interval | |
dose = 25 | |
steady_states = { | |
3 => 121.18, | |
4 => 157.13, | |
5 => 193.126, | |
6 => 229.145, | |
7 => 265.18, | |
8 => 301.22, | |
9 => 337.27, | |
10 => 373.32 | |
} | |
steady_state = steady_states[half_life / dosing_interval] || 10 | |
remaining_in_system = 0 | |
0.upto(period).each do |p| | |
remaining_in_system = remaining_in_system * (0.5**(1.fdiv(half_life))) | |
remaining_in_system += dose if (p % dosing_interval).zero? | |
if (p % report).zero? | |
puts "After #{p} #{unit}, dose in system: #{remaining_in_system} - #{remaining_in_system.fdiv(steady_state) * 100}%" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment