0

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?

Axe319
  • 2,760
  • 2
  • 8
  • 23

1 Answers1

0

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).

HadarM
  • 103
  • 1
  • 8