## Processes Class SFSMarkovChain

```java.lang.Object Processes.StochasticProcess Processes.MarkovChain Processes.SFSMarkovChain
```
Direct Known Subclasses:
SFSMarkovChainImpl, SFSStoppableMarkovChain

public abstract class SFSMarkovChain
extends MarkovChain

A stationary finite state (SFS) Markov chain. * *

A Markov chain with finitely many states 0,1,...,N-1. * and transition probabilities q(t,i.j)=q(i,j) independent of time * and given as abstract class methods. These methods are to be defined * in subclasses or in the body of a constructor call instantiating an * SFSMarkovChain. * Recall from `MarkovChain` how we sample the transition * probabilities.

* *

The methods `a(int)`, `b(int)` provide information about the * possible movements of the chain: the chain can move * from state i only to the states j with a(i)<=j<=b(i). * This information speeds up all computations.

* *

We override the very inefficient sampling and timeStep methods * of the general `MarkovChain` with a faster algorithm by precomputing * the partition of the unit interval conditional on the state X(t)=i * according to the probabilities q(t,i,j)=q(i,j), a(i)<=j<=b(i):

* *

partition * [0,1) = union { [I(i,j),I(i,j+1)) : a(i)<=j<=b(i) } * of [0,1) into subintervals [I(i,j),I(i,j+1)) of length q(i,j):

* *

I(i,j)=sum_{k=a(i)}^{j-1}q(i,j), j=a(i),...,b(i) * (with I(i,a(i))=0).

* *

WARNING: methods do not check if parameter values are in their intended * ranges. Parameters outside these ranges lead to undefined and meaningless * behaviour.

* * @author Michael J. Meyer

 Constructor Summary ```SFSMarkovChain(int T, int j_0)```           Constructor leaving all initializations to subclasses. ```SFSMarkovChain(int T, int j_0, int N)```           Constructor performing all initializations using the abstract * methods `a(i), b(i)`. ```SFSMarkovChain(int T, int j_0, int N, int[] a, int[] b)```           Constructor performing all initializations.

 Method Summary `abstract  int` `a(int i)`           Lower bound for states. `abstract  int` `b(int i)`           Upper bound for states. ` double` ```I(int i, int j)```           Points I(i,j) of the partition of *[0,1) used to sample the transition probabilities q(i,j). `abstract  double` ```q(int i, int j)```           Time independent transition probabilities. ` double` ```q(int t, int i, int j)```           Definition of super.q(t,i,j). ` void` `timeStep(int t)`           Evolves the path of the chain from time t to time t+1.

 Methods inherited from class Processes.StochasticProcess `get_dt, get_path, get_T, get_X_0, newPath, newPathBranch, pathSegment, pathSegment, pathSegment, sampledAt, simulationInit, timeStep`

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Constructor Detail

### SFSMarkovChain

```public SFSMarkovChain(int T,
int j_0)```

Constructor leaving all initializations to subclasses.

* * This constructor is to be called from a subclass if initializations * in the subclas have to be carried out before SFSMarkovChain can be * initialized. In this case all initializations need to be carried out in * the subclass constructor. * * @param T time steps to horizon * @param j_0 initial state

### SFSMarkovChain

```public SFSMarkovChain(int T,
int j_0,
int N)```

Constructor performing all initializations using the abstract * methods `a(i), b(i)`.

* *

This constructor performs some work but does not define the methods * a(i), b(i), q(i,j). You can instantiate the class by calling this * constructor and defining these methods in the body of the constructor * call.

* * @param T time steps to horizon * @param j_0 initial state * @param N number of states

### SFSMarkovChain

```public SFSMarkovChain(int T,
int j_0,
int N,
int[] a,
int[] b)```

Constructor performing all initializations.

* * The methods a(i), b(i) are defined from the precopmputed arrays * a[], b[] as *
public int a(int i){ return a[i]; }
*
public int b(int i){ return b[i]; }
* * @param T time steps to horizon * @param j_0 initial state * @param N number of states * @param a array defining the `a(int)` values * @param b array defining the `b(int)` values

 Method Detail

### q

```public abstract double q(int i,
int j)```

Time independent transition probabilities.

* * q(i,j) is the probability that the chain transitions from state i * to state j in the next step.

### a

`public abstract int a(int i)`

Lower bound for states.

* * From state i only the states j=a(i),...,b(i) can be reached * in the next step.

### b

`public abstract int b(int i)`

Upper bound for states.

* * From state i only the states j=a(i),...,b(i) can be reached * in the next step.

### q

```public double q(int t,
int i,
int j)```

Definition of super.q(t,i,j).

* * This method is replaced with `q(int, int)` in path computations.

Specified by:
`q` in class `MarkovChain`

### I

```public double I(int i,
int j)```

Points I(i,j) of the partition of *[0,1) used to sample the transition probabilities q(i,j). * Here i=X(t) is the current state of the chain.

### timeStep

`public void timeStep(int t)`

Evolves the path of the chain from time t to time t+1.

* * Overrides MarkovChain.timeStep replacing j(t,i,u) * with the much faster j(i,u).

Overrides:
`timeStep` in class `MarkovChain`