OpenBI Docs Buy

NETWORK.SIR OpenBI

Spreading through the network (the SIR model), step by step.

Group: Networks. OpenBI’s own: DAX has no function of this name.

Syntax

NETWORK.SIR ( <links>, <from>, <to>, <beta>, <gamma> [, <runs> [, <seeds>, <seed>]] )
ParameterTypeDescription
linksTableThe rows that make the network, one link a row: a table of the model or a table expression, as the filters leave it.
fromExpression
evaluated for each row
One end of each row's link, such as a payer, a customer or a place.
toExpression
evaluated for each row
The other end of each row's link.
betaNumberHow fast an infected node infects each neighbour that has not had it: infections per link per unit of time, 0 or more.
gammaNumberHow fast an infected node recovers: recoveries per unit of time, above 0. 1 / gamma is how long a node stays infectious, on average.
runsWhole number
optional
How many simulations are averaged, from 1 to 100,000: 100 when left out.
seedsTable
optional
The rows whose nodes are infected at the start. Left out, each run starts at one node chosen at random.
seedExpression
optional, evaluated for each row
The node of each row of seeds; it comes with seeds.

Returns

Table. 101 rows from time 0 to the end of the longest run. Their columns: Time; Susceptible, Infected and Recovered; Infected low and Infected high; and Reached share.

Remarks

  • The SIR model: every node is susceptible, infected or recovered. An infected node passes it on along each link at the rate beta and recovers at the rate gamma, and a recovered node is not infected again. Time runs on continuously, not in rounds.
  • The links are taken both ways, and no weight is used.
  • The runs draw their random numbers from a fixed start, so the same query gives the same numbers every time; more runs give steadier ones.
  • Susceptible, Infected and Recovered are the mean number of nodes in each state at that time, over the runs. Infected low and Infected high are the 10th and 90th percentiles of the infected: eight runs in ten fall between them.
  • Reached share is the mean share of the nodes that were ever infected, the same on every row.
  • For each node's chance of being reached, use NETWORK.SIR.NODES.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

How far word of mouth goes

Starting from one friend at random, at two rates of passing it on.

EVALUATE
VAR Links =
    DATATABLE (
        "From", STRING, "To", STRING,
        {
            { "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" },
            { "Di", "Ed" }, { "Ed", "Fay" }, { "Di", "Fay" }, { "Fay", "Gus" }
        }
    )
RETURN
    ROW (
        "Reached at beta 0.5", MAXX ( NETWORK.SIR ( Links, [From], [To], 0.5, 1 ), [Reached share] ),
        "Reached at beta 2", MAXX ( NETWORK.SIR ( Links, [From], [To], 2, 1 ), [Reached share] )
    )
Reached at beta 0.5Reached at beta 2
0.2885714285714280.571428571428572

The epidemic over time, from Ann

Every 20th of the 101 points.

EVALUATE
VAR Links =
    DATATABLE (
        "From", STRING, "To", STRING,
        {
            { "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" },
            { "Di", "Ed" }, { "Ed", "Fay" }, { "Di", "Fay" }, { "Fay", "Gus" }
        }
    )
VAR Start = DATATABLE ( "Person", STRING, { { "Ann" } } )
VAR Epidemic = NETWORK.SIR ( Links, [From], [To], 0.5, 1, 1000, Start, [Person] )
RETURN
    SELECTCOLUMNS (
        FILTER ( Epidemic, MOD ( ROUND ( 100 * [Time] / MAXX ( Epidemic, [Time] ), 0 ), 20 ) = 0 ),
        "Time", [Time],
        "Infected", [Infected],
        "Infected low", [Infected low],
        "Infected high", [Infected high],
        "Recovered", [Recovered]
    )
ORDER BY [Time]
TimeInfectedInfected lowInfected highRecovered
01110
2.216183946005170.376011.57
4.432367892010340.065001.987
6.64855183801550.007002.056
8.864735784020670.001002.062
11.08091973002580002.063

NETWORK.SIR.NODES, NETWORK.REACH, NETWORK.PROPAGATE, MONTECARLO.

NETWORK.SIR is OpenBI's own code: it calls no function of Open Graph, OpenBI's graph library. See the OAX network functions and Open Graph.

Last updated · OpenBI Studio 0.3.78