Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created January 1, 2024 06:32
Show Gist options
  • Save rjurney/626e48b0227ccb06733028b0110bd474 to your computer and use it in GitHub Desktop.
Save rjurney/626e48b0227ccb06733028b0110bd474 to your computer and use it in GitHub Desktop.
Converting a 5-day drug schedule to a matching weekly drug schedule
import numpy as np
import pk
import seaborn as sns
drug = pk.Drug(hl=8, t_max=1)
# 5 day simulation
conc = drug.concentration(
60,
1,
doses={
0: 100,
5: 100,
10: 100,
15: 100,
20: 100,
25: 100,
30: 100,
35: 100,
40: 100,
45: 100,
50: 100,
55: 100,
60: 100,
}
)
# Weekly simulation
weekly_conc = drug.concentration(
60,
1,
doses={
0: 100,
7: 100,
14: 100,
21: 100,
28: 100,
35: 100,
42: 100,
49: 100,
56: 100,
63: 100,
}
)
sns.set_style("whitegrid")
sns.lineplot(x=range(0, conc.shape[0]), y=conc)
sns.lineplot(x=range(0, weekly_conc.shape[0]), y=weekly_conc)
# Now adjust the dosage to make them match
# 4 day simulation
new_conc = drug.concentration(
60,
1,
doses={
0: 125,
7: 125,
14: 125,
21: 125,
28: 125,
35: 125,
42: 125,
49: 125,
56: 125,
63: 125,
}
)
sns.set_style("whitegrid")
sns.lineplot(x=range(0, conc.shape[0]), y=conc)
sns.lineplot(x=range(0, new_conc.shape[0]), y=new_conc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment