Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 660261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:08:11+00:00 2026-05-13T23:08:11+00:00

I am trying to implement the SIR epidemic model . Basically, the way I

  • 0

I am trying to implement the SIR epidemic model. Basically, the way I understand the model is that at each time step, it tells us how many nodes get infected and how many nodes are recovered. I am now trying to convert this into an discrete-event simulation and am confused at a point.

The model is generally solved using Euler’s method. Now, when I am converting it into a discrete event simulation, I am doing something like this (the numbers are used for clarity):

Initialize 100 members
At every time step t,
  //Determine how many get infected
  for i = 1 to 100
     let i pass a message to its neighbors
     When the neighbor receives the message from an infected member, it generates a random number and if it is less than beta*(infected/total), where beta is the infection rate, then the member gets infected
     Update the count for infected, recovered, susceptible

  //Determine how many are recovered
  for i = 1 to 100
      Generate a random number from a uniform distribution and check if it is less than gamma*infected. If it is, then this member is recovered.
      Update the count for infected, recovered, susceptible

I was essentially wondering if the above approach is right. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:08:11+00:00Added an answer on May 13, 2026 at 11:08 pm

    Looks pretty good as a start, except that for the first loop you need to remember that only susceptible individuals can become infected, and for the second one, that only infected individuals can become recovered. I also believe the probabilities of transition on each event (susceptible receiving message from infected neighbor, infected possibly recovering) are not a function of the current number of infected individuals — they’re constants (I think you’re misleading the “mass effect” probabilities as applying to each individual episode at a time step — they don’t).

    A bit subtler is how you do the first loop (not obvious to me from the SIR model): I think you want to determine all “messages” first, then which ones cause transitions susceptible -> infected — i.e., two loops rather than one — because an individual that’s just gotten infected at this time step cannot infect yet others in this same time step but only in the future; also, the transition infected -> recovered is not possible for individual who just became infected at this very time step, so you’d have to arrange your loops a bit differently!

    Consider modeling each individual with two “state” attributes:

    -- nummsgs, number of "messages" received this time step
    -- compartment (susceptible, infected or recovered)
    

    as well as a fixed set of neighbors. Then:

    for each individual:
        if individual.compartment != infected:
            continue
        for each neighbor of the individual:
            neighbor.nummsgs += 1
        if (random number says so):
            individual.compartment = recovered
    
    for each individual:
        if individual.compartment != susceptible:
            continue
        maybe (depending on random number & nummsgs):
            individual.compartment = infected
    
    for each individual:
        individual.nummsgs = 0
    

    this seems to better capture the overall flow (net of collecting and logging overall counts, which you can conceptually do as part of the last loop).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however
Ok well I'm trying implement something similar to the 'undo' function in many image
Trying to implement some nested loops that are spitting out good old nested html
Trying to implement a function that will return a list of ints the represent
Trying to implement NSCopying for the first time, and I have a question about
I'm trying implement a way to recursively template using jsRender. The issue is, my
SetFocus I'm trying implement the above Se Focus code in a Class Library that
When trying to implement a simple OpenGL application, I was surprised that while it
Am trying to implement a generic way for reading sections from a config file.
I am currently trying implement a QThread that contains a socket connection. The socket

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.