text:
# Example 9: Lotka-Volterra Dynamic Population Model

## Example 9: Prob-C Code for the Lotka-Volterra Dynamic Population Model

In their overview article about probabilistic programming the authors present a series of paradigmatical examples (Gordon, Henzinger, Nori & Rajamani, Probabilistic Programming, 2014). Example 9 deals with the classical predator-prey population model known as Lotka-Volterra model. The convential model is formulated as system of deterministic differential equations. Here the authors offer a stochastic solution in form of a probabilistic C-like computer code (Prob-C). The underlying mathematical model is a Continous-Time Markov Chain (CTMC).

"The Lotka-Volterra predator-prey model (Lotka, 1925; Volterra, 1926) is a population model which describes how the population of a predator and prey species evolves over time. It is specified using a system of so called 'stoichiometric' reactions as follows:

$$G \longrightarrow 2G$$

$$G+T \longrightarrow 2T$$

$$T \longrightarrow 0$$

We consider an ecosystem with goats (denoted by G) and tigers (denoted by T). The first reaction models goat reproduction. The second reaction models consumption of goats by tigers and consequent increase in tigers. The third reaction models death of tigers due to natural causes.

It turns out that this system can equivalently modelled as a Continuous Markov Chain (CTMC) whose state is an ordered pair (G, T) consisting of the number of goats G and the number of tigers T. The first reaction can be thought of as a transition in the CTMC  from state (G, T) to (G + 1, T) and this happens with a rate equal to $$c_1 \cdot G$$ where c1 is some rate constant, and is enabled only when G > 0. Next, the second reaction can be thought of as a transition in the CTMC from state (G, T) to (G-1, T+1) and this happens with a rate equal to $$c_2 \cdot G \cdot T$$, where c2 is some rate constant, and is enabled only when G > 0 and T > 0. Finally , the last reaction can be thought of as a transition in the CTMC from state (G, T) to (G, T-1) and this happens with a rate equal to $$c_3 \cdot T$$ where c3 is some rate constant, and is enabled only when T > 0.

Using a process called uniformization, such a CTMC can be modeled using an embedded Discrete-Time Markov Chain (DTMC), and encoded as a probabilistic program, shown in Figure 1. The program starts with an initial population of goats and tigers and executes the transitions of the Lotka-Volterra model until a prescribed time limit is reached, and returns the resulting population of goats and tigers.

Since the executions are probabilistic, the program models the output distribution of the population of goats and tigers. The body of the while loop is divided into 3 conditions:

1. The first condition models the situation when both goats and tigers exist, and models the situation when all 3 reactions are possible.
2. The second condition models the situation when only goats exist, which is an extreme case, where only reproduction of goats is possible.
3. The third condition models the situation when only tigers exist, which is another extreme case, where only death of tigers is possible." (Gordon et al., 2014, p.6)

## Example 9: Formal Reconstruction of Gordon's et al. Prob-C Code

We think that the so called 'stoichiometric' reactions are misleading because they are rather different from chemical stoichiometric 'equations' or 'patterns'. According to Gordon et al. agent 'molecules' can appear out of nothing or disappear into nothing. This is not allowed in classical stoichiometry (Erban & Jonathan, 2020).

So we prefer to model the Lotka-Volterra-Scenario directly as a competitive Continuous Time Markov Chain (CTMC) with countable state space along its definition (e.g. Pishro-Nik, 2014, p.666; Ross, 2010, 10/e, p.373) with two subprocesses:

1. a holding-time process, when in state i
2. a jump process from state i to a different state j

Besides their standard use in natural (Erban & Chapman, 2020) and computational (Gordon, 2014; Mitzenmacher & Upfahl, 2018; Cassandras & Lafortune, 2008) sciences CTMCs are a non-standard modelling tool in psychology (Wickens, 1982, McGill, 1967; Diederich & Mallahi-Karai, 2020) and sociology (Coleman, 1964; Bartholomew, 1967; Tuma & Hannan, 1984).

The holding-time Poisson counting process is waiting for an event of type birth (of prey) or fatal attack (of predator), or death (of predator). In this kind of process it is assumed that holding or waiting times are exponential distributed with rates:

$$\lambda(G,T) = \lambda_1(G) +\lambda_2(G,T) + \lambda_3(T).$$

$$\lambda_1(G) = c_1 \cdot G \text{ ; birth process with birth events}$$

$$\lambda_2(G, T) = c_2 \cdot G \cdot T \text{ ; birth-death process with attack events}$$

$$\lambda_3(T) = c_3 \cdot T \text{ ; death process with death events}$$

Because rates are state-dependent the Poisson counting processes are inhomogeneous. The total rate is a sum of the rates of the three individual and independent Poisson counting subprocesses (birth, birth-death, and death) running parallel and in competion to each other. Poisson race processes are widely used in such diverse fields as cognitive reaction time (RT), choice processes or reliability studies (Ibe, 2013, ch. 2.7.5; 2014, ch. 12.5.9). In independent Poisson race processes the total rate is the sum of the rates of the subprocesses and the probability of winning this race can be determined by the ratio:

$$p_{j} = \frac{\lambda_{j}}{\lambda} \text{ ; j = 1,...,3} \text{ ; probability of j is winning the process race}.$$

As the interarrival times of a Poisson counting process have an exponential distribution we can sample holding times ('dwellTime') of the merged Poisson process

$$\Delta t(G, T) \sim DExp(\lambda(G,T)) = DExp('rate')$$

add them up to the current time ('curTime'), and compare the current time with our TIMELIMIT.

At the end of the holding-time interval the CTMC has to determine which of the three subprocesses generated the event. The probability of winning the race between the three Poisson counter processes and the  jump-to probability is the simple standardized rate parameter (Ibe, 2013, ch. 2.7.5; 2014, ch. 12.5.9):

$$p_{ij}(G,T) = \frac{\lambda_{ij}(G,T)}{\lambda_i(G,T)} \text{ ; i = 1, 2, ..., ; j = 1,...,3}.$$

Since the rates and probabilities for all i are constant ("uniform"), we suppress the state index i from now on.

$$p_{j}(G,T) = \frac{\lambda_{j}(G,T)}{\lambda(G,T)} \text{ ; j = 1,...,3} \text{ ; probability that j is winning the process race}.$$

The jump-to index j is sampled from discrete distribution with the jump probabilities as parameter vector

$$j(G,T) \sim Discrete(p_1(G,T), p_2(G,T), p_3(G,T)) \text{ ; j = 1, ..., 3}$$

According to the selected jump-to index j the three processes generate at most two simultaneous actions. According to Gordon et al. these actions are:

$$(G, T) \stackrel{c_1 \cdot G}{\longrightarrow} (G+1, T) \text{ ; if j = 1, then birth process}$$

$$(G, T) \stackrel{c_2 \cdot G \cdot T}{\longrightarrow} (G-1, T+1) \text{ ; if j = 2, then birth-death process}$$

$$(G, T) \stackrel{c_3 \cdot T}{\longrightarrow} (G, T-1) \text{ ; if j = 3, then death process}$$

The simultaneous actions of the birth-death process (j = 2) are definitional for this kind of process, though they seem to be a bit unnatural in the Lotka-Volterra context. It is a bit unrealistic that during an exponential distributed attack episode a goat's disappearance is accompanied in the same episode by a birth of a tiger.

These transitions reach every state i in two-dimensional state-space S.

$$S \subseteq G \times T$$ $$G, T \subset \mathbb{N}$$

Transitions of the Lotka-Volterra CTMC are visualized in a transition-rate diagram (Fig. 2). This 2-dimensional transition space is typical for a competition process (Reuter, 1961; Iglehart, 1964) . It deviates from the conventional one-dimensional transition space typically used in CTMC definitions.

Empirical research has shown that the maximum of the predator frequency distribution appears most times later than the maximum of the prey distribution. This is not true for Gordon et al's model, when we use their rate-constants c as we demonstrate with our WebPPL-coded reconstruction (see below).

The classical Lotka-Volterra model is valuable for educational purposes but too too simple for empirical predictions and as an agent-based model it is not embedded in an ecological context (Charles J. Krebs, Rudy Boonstra, Stan Boutin, A.R.E. Sinclair, 2001). This is the fundamental deficit.

## Lotka-Volterra Simulation Run with WebPPL Script and Mateos' Parameters

Mateos' parameters were obtained from his 2018 lecture slides (visited 2020/07/27)

$$c_1 = 1.0$$

$$c_2 = 0.005$$

$$c_3 = 0.6$$

$$Goats(0) = 50$$

$$Tigers(0) = 100 .$$

The WebPPL-Code was developed independently. Results are similar though some of our simulations runs end in an ex- or implosion of the state space.

## Lotka-Volterra Simulation Run with WebPPL Script and Gordon et al.'s Parameters and Rates

Gordon et al.'s parameters and rates were obtained from the authors 2014 publication (visited 2020/07/28).

$$c_1 = 1.0$$

$$c_2 = 5.0$$

$$c_3 = 1.0$$

$$Goats(0) = 100$$

$$Tigers(0) = 4 .$$

The pure functional WebPPL-Code is an independently developed reimplementation of the imperative Prob-C code . Results demonstrate that the model does not show the typical Lotka-Volterra behavior with its cyclic trajectories. A model run with Mateos' start parameters and rate are much more typical for the Lotka-Volterra model trajectories (see above).

## References

Bartholomew, D.J., Stochastic Models for Social Processes, John Wiley, 1/e 1967, 3/e 1982

Cassandras Ch.G. & Lafortune, St., Introduction to Discrete Event Systems, 2/e, Springer, 2008

Diederich, A. & Mallahi-Karai, K., Stochastic Methods for Modelling Decision-Making, p.1-70, in: Batchelder, W.H., Colonius, H. & Dzhafarov, E.N., New Handbook of Mathematical Psychology, Vol.2: Modeling and Measurement, Cambrige University Press, 2018

Erban, R. & Chapman, J., Stochastic Modelling of Reaction-Diffusion Processes, Cambrige University Press, 2020

Gordon, A. D., et al. Probabilistic programming. In: Proceedings of the on Future of Software Engineering. 2014. S. 167-181.

Ibe, O., Markov Processes for Stochastic Modeling, 2/e, Elsevier, 2013

Ibe, O., Fundamentals of Applied Probability and Random Processes, Academic Press, 2014

Iglehart, D. L., et al. Multivariate competition processes. The Annals of Mathematical Statistics, 1964, 35. Jg., Nr. 1, S. 350-361.

Krebs, Ch. J., et al. What Drives the 10-year Cycle of Snowshoe Hares? The ten-year cycle of snowshoe hares—one of the most striking features of the boreal forest—is a product of the interaction between predation and food supplies, as large-scale experiments in the Yukon have demonstrated. BioScience, 2001, 51. Jg., Nr. 1, S. 25-35.

Lotka, A., Elements of physical biology, Williams & Wilkins company, Baltimore, 1925.

Mateos, G., Predator-Prey Population Dynamics, Lecture Slides, 2018/11/13, Dept. of ECE and Goergen Institute for Data Science, University of Rochester (visited 2020/07/28)

McGill, W.J., Stochastic Latency Mechanisms, p.309-360, in: Luce, R.D., Bush, R.R. & Galanter, E. (eds), Handbook of Mathematical Psychology, Vol. I, John Wiley & Sons, 2/e, 1967

Mitzenmacher, M. & Upfahl, E., Probability and Computing; Randomization and Probabilistic Techniques in Algorithms and Data Analysis, 2/e, 2017

Pishro-Nik, H., Probability, Statistics, and Random Processes, Kappa-Research LLC, 2014

Reuter, G. E. H. Competition processes. In: Proc. 4th Berkeley Symp. Math. Statist. Prob. 1961. S. 421-430.

Ross, S.M, Introduction To Probability Models, Elsevier, 2010, 10/e

Ruan, Sh., Poisson Race Models: Theory and Application in Conjoint Choice Analysis. 2007. PhD-Thesis. The Ohio State University.

Tuma, N.B. & Hannan, M.T., Social Dynamics: Models and Methods, Academic Press, 1984

Volterra, V., Fluctuations in the abundance of a species considered mathematically, Nature, 118: 558–560, 1926.

Wickens, Th.D., Models For Behavior: Stochastic Processes in Psychology, Freeman & Co., 1982

(Changed: 2020-08-05)


text:
Time Limit: Java: 2000 ms / Others: 2000 ms

Memory Limit: Java: 65536 KB / Others: 65536 KB

## Description

Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in the sea can be covered by a radius installation, if the distance between them is at most d.

We use Cartesian coordinate system, defining the coasting is the x-axis. The sea side is above x-axis, and the land side below. Given the position of each island in the sea, and given the distance of the coverage of the radar installation, your task is to write a program to find the minimal number of radar installations to cover all the islands. Note that the position of an island is represented by its x-y coordinates.

## Input

The input consists of several test cases. The first line of each case contains two integers n (1 n 1000) and d, where n is the number of islands in the sea and d is the distance of coverage of the radar installation. This is followed by n lines each containing two integers representing the coordinate of the position of each island. Then a blank line follows to separate the cases.

The input is terminated by a line containing pair of zeros.

## Output

For each test case output one line consisting of the test case number followed by the minimal number of radar installations needed. "-1" installation means no solution for that case.

## Sample Input

3 2
1 2
-3 1
2 1
1 2
0 2
0 0

## Sample Output

Case 1: 2
Case 2: 1

None

## Source

Asia 2002, Beijing (Mainland China)

format: plain


text:
# A pulley os radius 2m is rotated about its axis by a force F= (20 t- 5t^2) newton (where t is measured in seconds) applied tangentially. If the moment of inertia of the pulley about its axis of rotation is 10kg m^2 the number of rotaitons made by the pulley before its direction of motion is reversed, is:

Step by step solution by experts to help you in doubt clearance & scoring excellent marks in exams.

Updated On: 8-6-2021

Apne doubts clear karein ab Whatsapp par bhi. Try it now.

Watch 1000+ concepts & tricky questions explained!

6.8 K+

300+

Text Solution

less than 3more than 3 but less than 6more than 6 but less than 9more than 9

B
Solution :
tau =(20t-5t^(2))2=40t -10^(2)t, alpha = tau/I=(40t -10t^(2))/10=4t -t^(2), omega = int_(0)^(t) alpha dt = 2t^(2) -t^(3)/3
 When direction is reversed, omega is zero, So
 2t^(2) -t^(3)/3 = 0 rArr t^(3) =6t^(2) rArr t=6s , theta = int omega dt = int_(0)^(6)(2t^(2) - t^(3)/3)dt=[(2t^(3))/3 -t^(4)/12]_(0)^(6) = 36
 Number of revolution =36/(2pi) = Less than 6.


text:
I have a file where I restricted the menu and suddenly there is a delay when the user clicks "Next".  All slides are set to "Advance by User", but it now takes a few seconds for each slide to advance.

I see no setting for this.

Is there a reason for the delay?

###### 2 Replies

I saw on another thread that one workaround is to access each slide and reduce the duration. That seems to work; but I have two questions.

1. Are there any additional effects to slides from reducing the duration?

2. is there a quicker way to do this rather than manually adjusting each slide?

Hello Christopher,

The navigation settings in Articulate Storyline 2 affect both the menu and the player buttons, making it much easier to control the overall navigation for your course.

Should be no additional effects to doing so if the learner is seeing what you need them to see and I am not aware of a quicker way to update the duration across slides.


text:
# [Tex/LaTex] Smaller font for subscript within subscript in math mode

fontsfontsizemath-modesubscripts

How to get smaller font for subscript within subscript in math mode? For example, I want the subscript $c$ to be much smaller than it is in the following example:

\documentclass{article}
\begin{document}
$a_{b_{c}}$
\end{document}

But "\scriptstyle" or "\scriptscriptstyle" is not working for some reason for subscripts within subscripts, i.e.

\documentclass{article}
\begin{document}
$a_{b_{\scriptscriptstyle c}}$
\end{document}

has the same result for the size of $c$. So have to make $c$ even smaller?

For even smaller, you could scale the sub-subscript:

\documentclass{article}
\usepackage{scalerel}
\begin{document}
$a_{b_{\scaleto{c}{1pt}}}$
\end{document}

If you need consistency across a range of subscripts, you may wish to add a normalizer like a \mathstrut:

\documentclass{article}
\usepackage{scalerel}
\begin{document}
$a_{b_{\scaleto{c\mathstrut}{2pt}}}$
$a_{b_{\scaleto{g\mathstrut}{2pt}}}$
\end{document}

Here, \scaleto from the scalerel package operates on its arguments in math mode by default, unlike \scalebox of the graphicx package, which operates in text mode.


text:
# Drag¶

class Drag(duration: Union[int, ParameterExpression], amp: Union[complex, float, ParameterExpression], sigma: Union[float, ParameterExpression], beta: Union[float, ParameterExpression], angle: Optional[Union[float, ParameterExpression]] = None, name: Optional[str] = None, limit_amplitude: Optional[bool] = None)[source]

Bases: object

The Derivative Removal by Adiabatic Gate (DRAG) pulse is a standard Gaussian pulse with an additional Gaussian derivative component and lifting applied.

It can be calibrated either to reduce the phase error due to virtual population of the $$|2\rangle$$ state during the pulse or to reduce the frequency spectrum of a standard Gaussian pulse near the $$|1\rangle\leftrightarrow|2\rangle$$ transition, reducing the chance of leakage to the $$|2\rangle$$ state.

$\begin{split}g(x) &= \exp\Bigl(-\frac12 \frac{(x - \text{duration}/2)^2}{\text{sigma}^2}\Bigr)\\ g'(x) &= \text{A}\times\frac{g(x)-g(-1)}{1-g(-1)}\\ f(x) &= g'(x) \times \Bigl(1 + 1j \times \text{beta} \times \Bigl(-\frac{x - \text{duration}/2}{\text{sigma}^2}\Bigr) \Bigr), \quad 0 \le x < \text{duration}\end{split}$

where $$g(x)$$ is a standard unlifted Gaussian waveform, $$g'(x)$$ is the lifted Gaussian waveform, and $$\text{A} = \text{amp} \times \exp\left(i\times\text{angle}\right)$$.

References

Create new pulse instance.

Parameters
• duration -- Pulse length in terms of the sampling period dt.

• amp -- The magnitude of the amplitude of the DRAG envelope. Complex amp support will be deprecated.

• sigma -- A measure of how wide or narrow the Gaussian peak is; described mathematically in the class docstring.

• beta -- The correction amplitude.

• angle -- The angle of the complex amplitude of the DRAG envelope. Default value 0.

• name -- Display name for this pulse envelope.

• limit_amplitude -- If True, then limit the amplitude of the waveform to 1. The default is True and the amplitude is constrained to 1.

Returns

ScalableSymbolicPulse instance.

Attributes

alias = 'Drag'


text:
# Labeling the ticks on the imaginary axis with multiples of i in ComplexListPlot

I would like to have the ticks on the imaginary axis of a ComplexListPlot to be labeled with $$-2i$$,$$-i$$,$$0$$,$$i$$,$$2i$$ instead of $$-2$$,$$-1$$,$$0$$,$$1$$,$$2$$.

I have already tried it with the Ticks option like it is suggested in this question, but then I got the error

A tick position in the value of the Ticks option should be a number.

We can use the undocumented function ChartingFindTicks[] to generate ticks whose tick labels we can alter to be multiples of $$i$$, like so: