Ooops
September 27, 2021, 08:54:19

bplus

• Full Member
• Posts: 221
« on: March 28, 2020, 00:34:41 »
Thanks to TomToad's link, I managed to replicate the model in the link with SmallBASIC. I confess I fudged some stuff to get graphs to match. Pretty simple, if I can figure it out, but we gotta start from somewhere.

Code: [Select]
`' Model Disease Spread.bas trans to SB from QB64, bplus 2020-03-27' Numberphile math model of disease spread' [youtube]https://www.youtube.com/watch?v=k6nLfCbAzgo[/youtube] Trans = 3.2 ' Transmission Rate - this number is the one we might have greatest control over Recov = .23 ' Recovery Rate - mostly up to nature but medicines might speed up recovery rate I = .01 ' Infected S = 1 - I ' Susceptibledt = .015 ' time interval for snapshots = pixels on y-axisytitle = ymax - 20yaxis = ytitle - 10at 10, ytitle: ? "The Curve: Blue = Susceptible, Red Infected, Green = Neither S nor I"WHILE t < xmax    newS = S + dSdt ' update main variables    newI = I + dIdt    newR = R + dRdt    PSET t, yaxis - (yaxis - 20) * newS, 9    PSET t, yaxis - (yaxis - 20) * newI, 12    PSET t, yaxis - (yaxis - 20) * newR, 10    S = newS ' now change the values for next loop    I = newI    R = newR    t = t + 1 'next snapshot along y-axisWENDFUNC dSdt ()    dSdt = (-Trans * S * I) * dtENDFUNC dIdt ()    dIdt = (Trans * S * I - Recov * I) * dtENDFUNC dRdt ()    dRdt = (Recov * I) * dtEND  `

bplus

• Full Member
• Posts: 221
« Reply #1 on: March 28, 2020, 00:45:03 »
By severely cutting the transmission rate the disease will die out before all Susceptible (Blue) are Infected.
(Below I increased dt because cutting Transmission rate increases the longevity of the time of infections.)

Code: [Select]
`' Model Disease Spread.bas trans to SB from QB64, bplus 2020-03-27' Numberphile math model of disease spread' [youtube]https://www.youtube.com/watch?v=k6nLfCbAzgo[/youtube] Trans = .8 '<<< from 3.2, Transmission Rate - this number is the one we might have greatest control over Recov = .23 ' Recovery Rate - mostly up to nature but medicines might speed up recovery rate I = .01 ' Infected S = 1 - I ' Susceptibledt = .025 '>>> from .015, time interval for snapshots = pixels on y-axisytitle = ymax - 20yaxis = ytitle - 10at 10, ytitle: ? "The Curve: Blue = Susceptible, Red Infected, Green = Neither S nor I"WHILE t < xmax    newS = S + dSdt ' update main variables    newI = I + dIdt    newR = R + dRdt    PSET t, yaxis - (yaxis - 20) * newS, 9    PSET t, yaxis - (yaxis - 20) * newI, 12    PSET t, yaxis - (yaxis - 20) * newR, 10    S = newS ' now change the values for next loop    I = newI    R = newR    t = t + 1 'next snapshot along y-axisWENDFUNC dSdt ()    dSdt = (-Trans * S * I) * dtENDFUNC dIdt ()    dIdt = (Trans * S * I - Recov * I) * dtENDFUNC dRdt ()    dRdt = (Recov * I) * dtEND `

lettersquash

• Jr. Member
• Posts: 96
« Reply #2 on: April 04, 2020, 22:19:05 »
Very clever - you've inspired me to write a much more modest program to graph the crashing of my investments!
I'll have you know, I'm coding all the right commands, just not necessarily in the right order.

• Full Member
• Posts: 221