Markov Chain with an Exponential Distribution in Python

187 views Asked by At

I am new to random number generation in Python.

I understand the concept of a Markov Chain, but I am unable to convert it into a useful code:

Markov Chain - P(X_m+1 = j|X_m = i, X_m-1 = x_m-1,.....,X_0 = i_0) = P(X_m+1 = j |X_m = i)

For example how could I use Python to generate a Markov chain of real numbers distributed according to the exponential distribution :

P(x) = Ne^{−|x|}

where N is a normalization factor?

1

There are 1 answers

0
HadarM On

I think what you are looking for is

import numpy.random as npr    
p_x = npr.exponential(N,t)

where N is the inverse of the scaling factor and t is the number of random numbers you want to generate. You'll have to compute the parameters in advance, according to the order of the chain (in your case, 1).