Skip to main content
26 votes
Accepted

Efficient way to simulate thousands of Markov chains

While the other answers focus on circumventing the simulations, I focus on how to speed up the simulations themselves. (Sometimes, simulations might be unavoidable.) In this situation, when calling <...
Henrik Schumacher's user avatar
23 votes
Accepted

How to implement Markov Chain Monte Carlo with built-in functions?

As of Version 11.3, there is an undocumented utility package, called Statistics`MCMC` I came to know of it from the example notebook of this repository by @...
raja's user avatar
  • 346
18 votes

Efficient way to simulate thousands of Markov chains

I essentially derive a second distribution - without a need for stochastic modelling - from DiscreteMarkovProcess timeslices according to your state to value ...
kirma's user avatar
  • 19.1k
16 votes

Efficient way to simulate thousands of Markov chains

In general, Mathematica is not always the best tool for this type of simulation. That said, you do not need to compute sample paths to compute the mean or variance. For a Markov chain with ...
overfull hbox's user avatar
10 votes

How can I remove a stochastic trend from a time series

I am having some troubles with removing a stochastic trend from a time series on Mathematica. It is not clear to me what exactly "removing a stochastic trend" means. If we assume "difference-...
Anton Antonov's user avatar
10 votes
Accepted

Optimization of the following code

The function $x \mapsto P_x([a,b])$ is continuous and piecewise linear, so it can be easily and exactly integrated with the trapezoidal rule. Then the resulting quadrature rule can be compiled for ...
Henrik Schumacher's user avatar
8 votes
Accepted

Can built-in functions deal with stochastic delay differential equations (SDDE)?

For numerical model we can define RandomFunction[] with WienerProcess[] outside of NDSolve ...
Alex Trounev's user avatar
  • 46.1k
8 votes
Accepted

Numerically solving a system of SDE's with Levy noise?

To simulate Levy jumps we can use numerical model described in the paper Analysis of a stochastic SEIS epidemic model with the standard Brownian motion and Lévy jump. In this model we use ...
Alex Trounev's user avatar
  • 46.1k
7 votes

How to solve a stochastic differential equation?

Something like this? ...
zhk's user avatar
  • 12k
7 votes
Accepted

Continuous noise representation

For white noise, you can use WhiteNoiseProcess. This is just a process, so you need to pass it to RandomFunction to get actual ...
Parsifal's user avatar
  • 136
7 votes
Accepted

ItoProcess for stochastic reaction-diffusion equation

Here's a solution following @acl's suggestion of discretizing in space. I added a diffusion coefficient d and used reflecting boundary conditions. ...
Chris K's user avatar
  • 20.3k
7 votes
Accepted

Find PDF of a stochastic process

For simple processes this can be done by using the function PDF: ...
Sjoerd Smit's user avatar
6 votes
Accepted

How to reformulate differential equation problem as OrnsteinUhlenbeckProcess

One could do: ...
b.gates.you.know.what's user avatar
6 votes
Accepted

Ito Process paths over a Plot3D

Using the code as in the OP, slightly modified: ...
march's user avatar
  • 24k
6 votes
Accepted

ItoProcess for 3 coupled SDEs sourced by 5 Wiener processes

The typographic error is in the definition of the matrix ...
chris's user avatar
  • 23.1k
5 votes
Accepted

Solving a stochastic dynamical system

A few things: 1) The second equation doesn't match the ODEs as noted by @b.gatessucks. 2) You need to use \[DifferentialD]t on the right hand sides. 3) ...
Chris K's user avatar
  • 20.3k
4 votes

Hypergeometric function with a matrix argument

You can use the new in M9 function MatrixFunction to do this. For instance: ...
Carl Woll's user avatar
  • 131k
4 votes
Accepted

ITO Process with random initial position

I don't believe this is directly possible - the process is evaluated before the random paths are generated. I'll ponder further, but if you want the same effect, try something like this: ...
ciao's user avatar
  • 25.9k
4 votes
Accepted

Build a histogram from stochastic data

When requiring details information for many built in "data types" that are represented graphically by a gray box (e.g., TemporalData or ...
Henrik Schumacher's user avatar
4 votes
Accepted

Defining stochastic differential equations and simulating a system of three SDEs

Two things: 1) You can't use {} to group terms as in your z equation. See, for example, here for more info. 2) You need to ...
Chris K's user avatar
  • 20.3k
4 votes
Accepted

Ito Process with Piecewise

Try this with UnitStep and a numeric value for V0: ...
Henrik Schumacher's user avatar
4 votes

Ito Process sourced by Gaussian Process?

It is not a solution, but some comparison two different approach to the same problem (oscillator with random force). What we expecting from ItoProcess in this case? ...
Alex Trounev's user avatar
  • 46.1k
4 votes
Accepted

How can I calculate the Allan Variance of a list of Data?

I think this does what you need: ...
Sjoerd Smit's user avatar
4 votes
Accepted

How add noise to a differential equation?

One way to make random noise over the range t = 0 to 10: ...
Bill Watts's user avatar
  • 8,237
4 votes
Accepted

Stochastic process: Understanding Ornstein Uhlenbeck Process

You have different x axes. For the correlation function the x axis is 0,1,2,... And for the Table you have 0,0.1,0.2,0.3,... (Note: f is not defined, I set it to f=0.1) If we change the x axis of the ...
Daniel Huber's user avatar
  • 53.5k
4 votes
Accepted

Solving Stochastic Gross-Pitaevskii equation

We can compute correlation function with OrnsteinUhlenbeckProcess[] using mean in time as follows ...
Alex Trounev's user avatar
  • 46.1k
4 votes

Difficulties in solving a system of differential equations with a matrix differential equation

If I fill in arbitrarily chosen values for the missing parameters and functions, NDSolve computes a solution. Note the use of ...
Michael E2's user avatar
  • 239k
4 votes

Log scale of y-axis is still very small

...
Bob Hanlon's user avatar
  • 160k
3 votes

Stochastic ODE Integration problems using RandomFunction

Here's a crazy idea: maybe it's easier to add noise to NDSolve's adaptive step size algorithms than to deal with ...
Chris K's user avatar
  • 20.3k
3 votes
Accepted

Ignoring overflows in SDE simulations

From you comment, I read off that you are actually interested only in the behavior close to $t = 0$. Then it would suffice to use a significantly smaller time horizon. For example, ...
Henrik Schumacher's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible