From: <mma...@us...> - 2012-03-19 12:28:05
|
Revision: 9968 http://octave.svn.sourceforge.net/octave/?rev=9968&view=rev Author: mmarzolla Date: 2012-03-19 12:27:55 +0000 (Mon, 19 Mar 2012) Log Message: ----------- documentation improvements Modified Paths: -------------- trunk/octave-forge/main/queueing/doc/markovchains.txi trunk/octave-forge/main/queueing/inst/ctmc_bd.m trunk/octave-forge/main/queueing/inst/dtmc_bd.m Modified: trunk/octave-forge/main/queueing/doc/markovchains.txi =================================================================== --- trunk/octave-forge/main/queueing/doc/markovchains.txi 2012-03-19 09:34:32 UTC (rev 9967) +++ trunk/octave-forge/main/queueing/doc/markovchains.txi 2012-03-19 12:27:55 UTC (rev 9968) @@ -39,7 +39,8 @@ @iftex @tex -$$P\left(X_{n+1} = x_{n+1}\ |\ X_n = x_n, X_{n-1} = x_{n-1}, \ldots, X_0 = x_0 \right) = P\left(X_{n+1} = x_{n+1}\ |\ X_n = x_n\right)$$ +$$\eqalign{P\left(X_{n+1} = x_{n+1}\ |\ X_n = x_n, X_{n-1} = x_{n-1}, \ldots, X_0 = x_0 \right) \cr +& = P\left(X_{n+1} = x_{n+1}\ |\ X_n = x_n\right)}$$ @end tex @end iftex @ifnottex @@ -52,10 +53,10 @@ The evolution of a Markov chain with finite state space @math{@{1, 2, @dots{}, N@}} can be fully described by a stochastic matrix @math{{\bf -P}(n) = P_{i,j}(n)} such that @math{P_{i, j}(n) = P( X_{n+1} = j\ |\ +P}(n) = [ P_{i,j}(n) ]} such that @math{P_{i, j}(n) = P( X_{n+1} = j\ |\ X_n = i )}. If the Markov chain is homogeneous (that is, the transition probability matrix @math{{\bf P}(n)} is time-independent), -we can simply write @math{{\bf P} = P_{i, j}}, where @math{P_{i, j} = +we can simply write @math{{\bf P} = [P_{i, j}]}, where @math{P_{i, j} = P( X_{n+1} = j\ |\ X_n = i )} for all @math{n=0, 1, @dots{}}. The transition probability matrix @math{\bf P} must satisfy the @@ -244,7 +245,8 @@ @iftex @tex -$$P(X_{t_{n+1}} = x_{n+1}\ |\ X(t_n) = x_n, X(t_{n-1}) = x_{n-1}, \ldots, X(t_0) = x_0) = P(X(t_{n+1}) = x_{n+1}\ |\ X(t_n) = x_n)$$ +$$\eqalign{P(X(t_{n+1}) = x_{n+1}\ |\ X(t_n) = x_n, X(t_{n-1}) = x_{n-1}, \ldots, X(t_0) = x_0) \cr +&= P(X(t_{n+1}) = x_{n+1}\ |\ X(t_n) = x_n)}$$ @end tex @end iftex @ifnottex @@ -255,8 +257,9 @@ @emph{infinitesimal generator matrix} @math{{\bf Q} = [Q_{i,j}]} such that for each @math{i \neq j}, @math{Q_{i, j}} is the transition rate from state @math{i} to state @math{j}. The elements @math{Q_{i, i}} -must be defined in such a way that the infinitesimal generator matrix -@math{\bf Q} satisfies the property @math{\sum_{j=1}^N Q_{i, j} = 0}. +qre defined as @math{Q_{i, i} = - \sum_{j \neq i} Q_{i, j}}, such that +matrix @math{\bf Q} satisfies the property that, for all @math{i}, +@math{\sum_{j=1}^N Q_{i, j} = 0}. @DOCSTRING(ctmc_check_Q) @@ -373,8 +376,8 @@ @end ifnottex @noindent where @math{{\bf \pi}(t) = {\bf \pi}(0) \exp({\bf Q}t)} is -the state occupancy probability at time @math{t}; @math{\exp({\bf A})} -is the matrix exponential of @math{\bf A}. +the state occupancy probability at time @math{t}; @math{\exp({\bf Q}t)} +is the matrix exponential of @math{{\bf Q}t}. @DOCSTRING(ctmc_exps) Modified: trunk/octave-forge/main/queueing/inst/ctmc_bd.m =================================================================== --- trunk/octave-forge/main/queueing/inst/ctmc_bd.m 2012-03-19 09:34:32 UTC (rev 9967) +++ trunk/octave-forge/main/queueing/inst/ctmc_bd.m 2012-03-19 12:27:55 UTC (rev 9968) @@ -17,37 +17,51 @@ ## -*- texinfo -*- ## -## @deftypefn {Function File} {@var{Q} =} ctmc_bd (@var{birth}, @var{death}) +## @deftypefn {Function File} {@var{Q} =} ctmc_bd (@var{b}, @var{d}) ## ## @cindex Markov chain, continuous time ## @cindex Birth-death process ## -## Returns the @math{N \times N} infinitesimal generator matrix @math{Q} -## for a birth-death process with given rates. +## Returns the infinitesimal generator matrix @math{Q} for a continuous +## birth-death process over state space @math{1, 2, @dots{}, N}. +## @code{@var{b}(i)} is the transition rate from state @math{i} to +## @math{i+1}, and @code{@var{d}(i)} is the transition rate from state +## @math{i+1} to state @math{i}, @math{i=1, 2, @dots{}, N-1}. ## -## @strong{INPUTS} +## Matrix @math{\bf Q} is therefore defined as: ## -## @table @var +## @iftex +## @tex +## $$ \pmatrix{ -\lambda_1 & \lambda_1 & & & & \cr +## \mu_1 & -(\mu_1 + \lambda_2) & \lambda_2 & & \cr +## & \mu_2 & -(\mu_2 + \lambda_3) & \lambda_3 & & \cr +## \cr +## & & \ddots & \ddots & \ddots & & \cr +## \cr +## & & & \mu_{N-2} & -(\mu_{N-2}+\lambda_{N-1}) & \lambda_{N-1} \cr +## & & & & \mu_{N-1} & -\mu_{N-1} } +## $$ +## @end tex +## @noindent where @math{\lambda_i} and @math{\mu_i} are the birth and +## death rates, respectively. +## @end iftex +## @ifnottex +## @example +## @group +## / \ +## | -b(1) b(1) | +## | d(1) -(d(1)+b(2)) b(2) | +## | d(2) -(d(2)+b(3)) b(3) | +## | | +## | ... ... ... | +## | | +## | d(N-2) -(d(N-2)+b(N-1)) b(N-1) | +## | d(N-1) -d(N-1) | +## \ / +## @end group +## @end example +## @end ifnottex ## -## @item birth -## Vector with @math{N-1} elements, where @code{@var{birth}(i)} is the -## transition rate from state @math{i} to state @math{i+1}. -## -## @item death -## Vector with @math{N-1} elements, where @code{@var{death}(i)} is the -## transition rate from state @math{i+1} to state @math{i}. -## -## @end table -## -## @strong{OUTPUTS} -## -## @table @var -## -## @item Q -## Infinitesimal generator matrix for the birth-death process. -## -## @end table -## ## @end deftypefn ## Author: Moreno Marzolla <marzolla(at)cs.unibo.it> Modified: trunk/octave-forge/main/queueing/inst/dtmc_bd.m =================================================================== --- trunk/octave-forge/main/queueing/inst/dtmc_bd.m 2012-03-19 09:34:32 UTC (rev 9967) +++ trunk/octave-forge/main/queueing/inst/dtmc_bd.m 2012-03-19 12:27:55 UTC (rev 9968) @@ -17,68 +17,83 @@ ## -*- texinfo -*- ## -## @deftypefn {Function File} {@var{P} =} dtmc_bd (@var{birth}, @var{death}) +## @deftypefn {Function File} {@var{P} =} dtmc_bd (@var{b}, @var{d}) ## ## @cindex Markov chain, discrete time ## @cindex Birth-death process ## -## Returns the @math{N \times N} transition probability matrix @math{P} -## for a birth-death process with given rates. +## Returns the transition probability matrix @math{P} for a discrete +## birth-death process over state space @math{1, 2, @dots{}, N}. +## @code{@var{b}(i)} is the transition probability from state +## @math{i} to @math{i+1}, and @code{@var{d}(i)} is the transition +## probability from state @math{i+1} to state @math{i}, @math{i=1, 2, +## @dots{}, N-1}. ## -## @strong{INPUTS} +## Matrix @math{\bf P} is therefore defined as: ## -## @table @var +## @iftex +## @tex +## $$ \pmatrix{ (1-\lambda_1) & \lambda_1 & & & & \cr +## \mu_1 & (1 - \mu_1 - \lambda_2) & \lambda_2 & & \cr +## & \mu_2 & (1 - \mu_2 - \lambda_3) & \lambda_3 & & \cr +## \cr +## & & \ddots & \ddots & \ddots & & \cr +## \cr +## & & & \mu_{N-2} & (1 - \mu_{N-2}-\lambda_{N-1}) & \lambda_{N-1} \cr +## & & & & \mu_{N-1} & (1-\mu_{N-1}) } +## $$ +## @end tex +## @noindent where @math{\lambda_i} and @math{\mu_i} are the birth and +## death probabilities, respectively. +## @end iftex +## @ifnottex +## @example +## @group +## / \ +## | 1-b(1) b(1) | +## | d(1) (1-d(1)-b(2)) b(2) | +## | d(2) (1-d(2)-b(3)) b(3) | +## | | +## | ... ... ... | +## | | +## | d(N-2) (1-d(N-2)-b(N-1)) b(N-1) | +## | d(N-1) 1-d(N-1) | +## \ / +## @end group +## @end example +## @end ifnottex ## -## @item birth -## Vector with @math{N-1} elements, where @code{@var{birth}(i)} is the -## transition probability from state @math{i} to state @math{i+1}. -## -## @item death -## Vector with @math{N-1} elements, where @code{@var{death}(i)} is the -## transition probability from state @math{i+1} to state @math{i}. -## -## @end table -## -## @strong{OUTPUTS} -## -## @table @var -## -## @item P -## Transition probability matrix for the birth-death process. -## -## @end table -## ## @end deftypefn ## Author: Moreno Marzolla <marzolla(at)cs.unibo.it> ## Web: http://www.moreno.marzolla.name/ -function P = dtmc_bd( birth, death ) +function P = dtmc_bd( b, d ) if ( nargin != 2 ) print_usage(); endif - ( isvector( birth ) && isvector( death ) ) || \ + ( isvector( b ) && isvector( d ) ) || \ usage( "birth and death must be vectors" ); - birth = birth(:); # make birth a column vector - death = death(:); # make death a column vector - size_equal( birth, death ) || \ + b = b(:); # make b a column vector + d = d(:); # make d a column vector + size_equal( b, d ) || \ usage( "birth and death vectors must have the same length" ); - all( birth >= 0 ) || \ + all( b >= 0 ) || \ usage( "birth probabilities must be >= 0" ); - all( death >= 0 ) || \ + all( d >= 0 ) || \ usage( "death probabilities must be >= 0" ); - all( ([birth; 0] + [0; death]) <= 1 ) || \ - usage( "Inconsistent birth/death probabilities"); - ## builds the infinitesimal generator matrix - P = diag( birth, 1 ) + diag( death, -1 ); + all( ([b; 0] + [0; d]) <= 1 ) || \ + usage( "d(i)+b(i+1) must be <= 1"); + + P = diag( b, 1 ) + diag( d, -1 ); P += diag( 1-sum(P,2) ); endfunction %!test %! birth = [.5 .5 .3]; %! death = [.6 .2 .3]; -%! fail("dtmc_bd(birth,death)","Inconsistent"); +%! fail("dtmc_bd(birth,death)","must be"); %!demo %! birth = [ .2 .3 .4 ]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |