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
21 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
  • 326
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
  • 18.6k
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
11 votes

Mathematica code for hidden Markov models (HMM)

Mathematica V10 introduced the following two functions: - HiddenMarkovProcess - FindHiddenMarkovStates Examples of their ...
dr.blochwave's user avatar
  • 8,698
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
  • 41.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
  • 41.1k
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
  • 19.3k
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

How to solve a stochastic differential equation?

Something like this? ...
zhk's user avatar
  • 11.9k
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
  • 21.6k
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
  • 22.7k
6 votes

ItoProcess for 3 coupled SDEs sourced by 5 Wiener processes

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

Stochastic process, Corelation function, Numerical solution, real data

Sample CorrelationFunction is a biased estimator. It works better when applied to the whole ensemble of paths instead of calculating it pathwise and taking means. ...
Gosia's user avatar
  • 808
5 votes

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

I'm currently implementing a MCMC in Mathematica. What I've done so far. 1.-Build your Model 2.-Import your data (X,Y,σ) 3.-Assign the initial parameters (P1=1 and P2=2) for example. 4.-Sample ...
BPinto's user avatar
  • 1,022
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
  • 19.3k
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.5k
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
  • 129k
4 votes
Accepted

Random Variable in Recurrence Function

You can avoid pre-evaluation with the following definition ...
ybeltukov's user avatar
  • 43.5k
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
  • 19.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
  • 41.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
  • 21.6k
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
  • 7,872
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
  • 45.4k
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
  • 41.1k

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