MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Simulate a finite-state markov process

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91894] Re: Simulate a finite-state markov process
  • From: Mark Fisher <particlefilter at gmail.com>
  • Date: Fri, 12 Sep 2008 05:26:19 -0400 (EDT)
  • References: <gaar67$18e$1@smc.vnet.net>

On Sep 11, 6:16 am, edsferr <edsf... at uol.com.br> wrote:
> Dear Mark Fisher,
>
> I've seen a message in comp.soft-sys.math.mathematica :
>
> http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_...
>
> I found it very interesting and tried to develop a similar program
> using the same idea.
>
> The problem is that I'm not that good with programming...
>
> Suppose I have the following Emission matrix:
>
> {{0.470949,0.260239,0.268812},{0.529412,0.470588,0},{0.625,0,0.375},
> {0.722222,0,0.277778},{0.446667,0.24,0.313333},{0.5,0.5,0},
> {0.481301,0.252846,0.265854},{0.471374,0.257634,0.270992},
> {0.47293,0.269108,0.257962},{0.52027,0.239865,0.239865},
> {0.595238,0.214286,0.190476},{0.444444,0.296296,0.259259},
> {0.478528,0.263804,0.257669},{0.507874,0.233071,0.259055},
> {0.434251,0.308869,0.256881},{0.504274,0.262108,0.233618},
> {0.419753,0.320988,0.259259},{0.473684,0.315789,0.210526},
> {0.512012,0.231231,0.256757},{0.5,0.19469,0.30531},
> {0.390244,0.195122,0.414634},{0.510949,0.19708,0.291971},
> {0.464286,0.25,0.285714},{0.285714,0,0.714286}}
>
> The alphabet is {"A","B","C"}
>
> And the following Transition Matrix:
>
> {{0.470949,0,0,0,0,0,0.260239,0,0,0,0,0,0,0.268812,0,0,0,0,0,0,0,0,0,0},
> {0.529412,0,0,0,0,0,0,0.470588,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
> {0.625,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.375,0,0,0,0,0,0,0,0},
> {0.722222,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.277778,0,0,0,0,0,0},
> {0.446667,0,0,0.24,0,0,0,0,0,0,0,0,0,0,0,0.313333,0,0,0,0,0,0,0,0},
> {0.5,0,0,0,0.5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
> {0.481301,0,0,0,0,0,0,0,0.252846,0,0,0,0,0,0.265854,0,0,0,0,0,0,0,0,0},
> {0.471374,0,0,0,0,0,0,0,0,0.257634,0,0,0,0,0,0.270992,0,0,0,0,0,0,0,0},
> {0.47293,0,0,0,0,0,0,0,0,0,0,0,0.269108,0,0,0,0.257962,0,0,0,0,0,0,0},
> {0.52027,0,0,0,0,0,0,0,0,0,0,0,0.239865,0,0,0,0,0.239865,0,0,0,0,0,0},
> {0.595238,0,0,0,0.214286,0.190476,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
> {0.444444,0.259259,0,0,0,0,0,0,0.296296,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
> {0.478528,0,0,0,0,0,0,0,0,0,0.257669,0,0.263804,0,0,0,0,0,0,0,0,0,0,0},
> {0.507874,0,0,0,0,0,0,0.233071,0,0,0,0,0,0,0,0,0,0,0.259055,0,0,0,0,0},
> {0.434251,0,0,0,0,0,0,0.308869,0,0,0,0,0,0,0,0,0,0,0,0.256881,0,0,0,0},
> {0.504274,0,0,0,0,0,0,0.262108,0,0,0,0,0,0,0,0,0,0,0,0,0.233618,0,0,0},
> {0.419753,0,0,0,0.320988,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.259259,0,0,0,0},
> {0.473684,0,0,0,0.315789,0,0,0,0,0,0,0,0,0,0,0,0,0,0.210526,0,0,0,0,0},
> {0.512012,0,0,0,0,0,0,0.231231,0,0,0,0,0,0,0,0,0,0,0,0,0,0.256757,0,0},
> {0.5,0,0,0,0.19469,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.30531,0,0},
> {0.390244,0,0.195122,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.414634,0,0},
> {0.510949,0,0,0,0,0,0,0,0,0,0,0.19708,0,0,0,0,0,0,0,0,0,0,0.291971,0},
> {0.464286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.285714,0.25},
> {0.285714,0.714286,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
>
> How can I develop a program to generate x sequences of a specified
> length?
>
> By the way, does anyone know how to calculate the probability of a
> specific sequence to occur within n generated sequences??
>
> Thank you very much for your attention!
>
> Edson Ferreira

In definining your emission and transition matrixes, you need to make
sure that the rows sum to one. (Your's don't quite.) So use the
following:

EmisionMatrix = #/Total[#]& /@ {{0.470949,0.260239,0.268812},...};
TransmissionMatrix = #/Total[#]& /@
{{0.470949,0,0,0,0,0,0.260239,0,0,0,0,0,0,0.268812,0,0,0,0,0,0,0,0,0,0},...=
};

--Mark


  • Prev by Date: Re: Alternating sums of large numbers
  • Next by Date: Re: Simulate a finite-state markov process
  • Previous by thread: Simulate a finite-state markov process
  • Next by thread: Re: Simulate a finite-state markov process