DateLong

The Transition Matrix Package°

°working title

A package for experiments with markov models

Version 0.2

Jan-Hendrik Prinz

Please send any errors, problems, comments or suggestions to me.

.FOREWORD & VERSION

Last changes

Added Total Exit Rate for TPT. Also added an error function, but it has not yet been tested.

Added Error in MFPT

Version 0.2

Corrected Error in CommittorSensitivityMatrix, former CommittorSensitivityVector is removed

Corrected Error in StateExitFlowRateSensitivityMatrix

May 3rd, 2009

.DOCUMENTATION

I will start with a short introduction on the idea behind the package, then give some examples on the usage and the list all functions implmented yet. Puh, lots of work. Some short infos can be obtained with the questions mark operator ?function.

Load the package

<<"/Users/jan-hendrikprinz/Desktop/TMPackage/TransitionMatrix.m";

Objects to be used

To be a close as possible to the mathematical ideas implemented, I choosed to create different kinds of objects which have a mathematical partner. In general we a discrete state space for the markov models used here. The Objects are

CountMatrix (ℂ)

A squared matrix of the number of transitions inside the discrete state space.

Clustermatrices are represented by the symbol ℂ.

CountMatrix[matrix, options]

Example

CountMatrix[{{9,1},{8,2}}]

TransitionMatrix (𝕋)

A squared matrix of transition probabilites inside the discrete state space. All TransitionMatrices need a Lagtime, which is assumed to be one if not specified otherwise.

Clustermatrices are represented by the symbol 𝕋.

TransitionMatrices can also be constructed with TransitionMatrixNormalized, which ensures normalization.

TransitionMatrix[matrix, options]

TransitionMatrixNormalized[matrix,options]

Example

TransitionMatrix[{{0.9,0.1},{0.8,0.2}}, Lagtime->0.2]

RateMatrix (ℝ)

A sqaured matrix of transition rates inside the discrete state space.

Clustermatrices are represented by the symbol ℝ.

RateMatrices can also be constructed with RateMatrixNormalized, which ensures normalization.

RateMatrix[matrix, options]

RateMatrixNormalized[matrix,options]

Example

RateMatrix[{{-2.0,1.0,1.0},{0.2,-1.0,0.8},{0.2,0.2,-0.4}}]

ClusterMatrix (𝕃)

A (n-by-m)-matrix representing a clustering of m states into n states. For a real clustering the column-sum has to be one, but this is not a requirement. Each row i contains the probabilities of each column j to belong to cluster i.

Clustermatrices are represented by the symbol 𝕃.

ClusterMatrix[matrix, options]

Example

ClusterMatrix[{{1,1,1,0,0},{0,0,0,1,1}}]

TimeSeries (𝕊)

A vector of integers representing a series of states. Optionally a larger state space can be given by using States->n.

Timeseries are represented by the symbol 𝕊.

TimeSeries[vector, options]

Example

TimeSeries[{1,2,3,3,2,3,2,1,2}, States->4]

Trajectory (𝕄)

A vector of vectors representing a series of vectors like positions. In most cases you should only use Timeseries and create them by whatever means appear suitable. Trajectories are represented by the symbol 𝕄.

Trajectory[matrix, options]

Example

Trajectory[{{1,1.2},{1.1,1.3},{1,0.9},{1.1,1.1}}]

All objects have a short illustrative representation, but the objects still contain all information, so that they can still be used in other functions. This is done with an interpretation box, that hides. To access the matrices in the objects use the function Normal

tMatrix1=TransitionMatrix[{{0.9,0.1},{0.8,0.2}}]

Normal[tMatrix1]

Normal[(Subscript[𝕋, 2])(({{0.9`, 0.1`}, {0.8`, 0.2`}}))]

All functions assume always an object, that is reasonable with the function. So a TransitionMatrix has a Spectrum, while a CountMatrix has not. So, if a function does not work with your object, presumeably you used

Spectrum[TransitionMatrix[{{0.9,0.1},{0.8,0.2}}]]

Spectrum[CountMatrix[{{0.9,0.1},{0.8,0.2}}]]

Instead you could use something like

Eigenvalues[Normal[CountMatrix[{{0.9,0.1},{0.8,0.2}}]]]

because this is what you probably meant to compute.

You can use the Matrices with MatrixPlot, which is nothing else than a combination of Normal and MatrixPlot with a few predifined settings.

MatrixPlot[CountMatrix[{{9,1},{8,2}}],ImageSize->60]

Functions for Properties of Objects

Normal

Returns the matrix or vector of any of the objects defined above. Keep in mind, that if you use sparse matrices Normal will return the sparse matrix object and not a normal form.

Normal[object]

Example

Normal[TransitionMatrix[{{0.9,0.1},{0.8,0.2}}]]

NormalForm

Returns a vector of all contents of the objects, which can be used to reproduce the object. The returned vector can be used with Apply to get the object

NormalForm[object]

Example

Apply[TransitionMatrix,NormalForm[TransitionMatrix[{{0.9,0.1},{0.8,0.2}},Lagtime->2,ShowSize->0]]]

Length

Returns the length of the contained vector or the size of the squared matrix. For Clustermatrices Length returns the dimensions of the matrix

Length[object]

Example

Length[ClusterMatrix[{{1,1,1,0,0},{0,0,0,1,1}}]]

MatrixForm

Return the contained matrix or vector wrapped with MatrixForm

MatrixForm[object]

Example

TransitionMatrix[{{0.9,0.1},{0.8,0.2}},Lagtime->2,ShowSize->0]//MatrixForm

MatrixPlot

Plots the objects using MatrixPlot. Works also with TimeSeries, but not Trajetories.

MatrixPlot[object, MatrixPlotOptions]

Example

MatrixPlot[ClusterMatrix[{{1,1,1,0,0},{0,0,0,1,1}}],ImageSize->120]

MatrixPlot[TimeSeries[{3,2,1,1,1,2,3,3,2,3,2,1,2,10,2,1,2,10,10,10,2}, States->5],ImageSize->320,ColorFunction->"Rainbow",Mesh->True]

Basic Functions

Normalize

Normalizes a countmatrix by dividing each row by its sum. The is often used to generate a transitionmatrix. In general you should use statistical methods to derive this, even if the result is the same

Normalize[transitionmatrix]

Example

Normalize[CountMatrix[{{9,1},{8,2}}]]

Normalize

Normalizes a countmatrix by dividing each row by its sum. The is often used to generate a transitionmatrix. In general you should use statistical methods to derive this, even if the result is the same

Normalize[transitionmatrix]

Example

Normalize[CountMatrix[{{9,1},{8,2}}]]

Testing Functions

Object Testing

You can test for any kind of objects by using the Q-functions TransitionMatrixQ, RateMatrixQ, CountMatrixQ, ClusterMatrixQ, TimeSeriesQ, TrajectoryQ.

TransitionMatrixQ[object]

RateMatrixQ[object]

CountMatrixQ[object]

ClusterMatrixQ[object]

TimeSeriesQ[object]

TrajectoryQ[object]

Example

CountMatrixQ[CountMatrix[{{9,1},{8,2}}]]

TransitionMatrixQ[CountMatrix[{{9,1},{8,2}}]]

Row Sum Testing

Check, if a matrix has a certain structure. Especially rowsums of one or zero with RowSumOneQ and RowSumZeroQ. These tests are included in TransitionMatrixQ and RateMatrixQ. The function can be applied to Transitionmatrices, Ratematrices or directly to matrices. NormalizedQ applied the correct function to TransitionMatrices or RateMatrices

RowSumOneQ[object]

RowSumZeroQ[object]

NormalizedQ[object]

Example

RowSumZeroQ[Normal[RateMatrix[{{-2.0,1.0,1.0},{0.2,-1.0,0.8},{0.2,0.2,-0.4}}]]]

Here we create a false Ratematrix! See first row...

RowSumZeroQ[RateMatrix[{{-1.0,1.0,1.0},{0.2,-1.0,0.8},{0.2,0.2,-0.4}}]]

Connections between Countmatrices, Transitionmatrices and Ratematrices

Countmatrices are objects representing observations of a (discrete state) dynamic, which is explicitely markovian, so only the absolute number of transition counts and not the order in which they occur. This is a very strong assumption but significantly simplifies computations and algebra.

These observations can be associated with a specific markov model. In our case either a time-independent generator (Ratematrix) or a time-evlving operator for a fixed time (Transitionmatrix). This specific model can be a good choice to reproduce the markov observation of the countmatrix or not. Usually one introduces some kind of measure for the quality of the chosen model given an observation and chooses the mean or maximumlikelihood estimator as ones representation.

The folowing function given a rather small selection of ways to connect these matrices.

Each CountMatrix has an associated Distribution, that will be used to generate TransitionMatrices. Predefined is always a DirichletDistribution. Alternatively there are also a DiracDistribution (it means it is just fixed at the normalized countmatrix) and so far a DirichletDistribution with included Contraint of detailed balance using a iterative scheme from George Boxer

The Distribution is given as an Option for the Countmatrix

CountMatrix[matrix, Distribution->selectedDistribution]

Example

CountMatrix is used nested, which keeps the inner countmatrix and changes the options. This is sometimes very convenient and short. The first matrix inherits the dirichlet distribution as the default setting.

testCountMatrix=CountMatrix[{{9.,1.,2.},{1.,13.,1.},{1.,2.,19.}}];
testCountMatrixDirac=CountMatrix[testCountMatrix, Distribution->DiracDistribution];
testCountMatrixDirichlet=CountMatrix[testCountMatrix, Distribution->DirichletDistribution];
testCountMatrixDetailedBalance=CountMatrix[testCountMatrix, Distribution->DirichletWithDBDistribution];

Compute the maximum likelihood probabilites

MaximumLikelihoodMatrix[testCountMatrixDirac]
MaximumLikelihoodMatrix[testCountMatrixDirichlet]
MaximumLikelihoodMatrix[testCountMatrixDetailedBalance,MaximalResidue->0]

Compute the mean probabilites. This is not implemented for the detailed balance. Notice, that the mean is different in both distribution, while the maximum likelihood ist not

MeanMatrix[testCountMatrixDirac]
MeanMatrix[testCountMatrixDirichlet]

MaximumLikelihoodMatrix

Returns the most probable transition matrix given the observations in the CountMatrix and the specified distribution.

MaximumLikelihoodMatrix[countmatrix, options]

Example

MaximumLikelihoodMatrix[CountMatrix[{{9.,1.},{8.,2.}}]]

MeanMatrix

Returns the mean expectation transition matrix given the observations in the CountMatrix and the specified distribution. The mean values are usually closer to 0.5 than the maximumlikelihood values.

MeanMatrix[countmatrix, options]

Example

MeanMatrix[CountMatrix[{{9.,1.},{8.,2.}}]]

VarianceMatrix

Returns a matrix containing the (assumed to be independent) variance in each entry of the transitionmatrix around the mean. In some cases you would need the complete covariance tensor for the matrix, but this is a tensor of 4th order. The complete tensor is not yet implemeted. The result is not a transitionmatrix, since it is not meant to be used as transition probabilities

VarianceMatrix[countmatrix, options]

Example

VarianceMatrix[CountMatrix[{{9.,1.},{8.,2.}}]]//MatrixForm

DrawTransitionMatrix

Returns a transitionmatrix draw from the specified distribution given the obervation

DrawTransitionMatrix[countmatrix, options]

Example

Sample 10000 Matrices

testCountMatrix=CountMatrix[{{9.,1.},{8.,2.}}];

listOfMatrices=Table[Normal[DrawTransitionMatrix[testCountMatrix]],{10000}];

Compute Mean Values

Map[Mean,Transpose[listOfMatrices]]//MatrixForm

Compare with exact values

MeanMatrix[testCountMatrix]

Same with variance

Map[Variance,Transpose[listOfMatrices]]//MatrixForm

VarianceMatrix[testCountMatrix]//MatrixForm

Conversion between Transition Matrices and RateMatrices

Transitionmatrices and Ratematrices are connected by a matrix exponential or matrix logarithm resp. This means a Ratematrix can always generate Transitionmatrices, but not backwards. TransitionMatrices can be generated by ToTransitionMatrix, backwards is done with ToRateMatrix.

ToTransitionMatrix[countmatrix,lagtime]

ToRateMatrix[transitionmatrix,options]

Example

We generate a TransitionMatrix for the time 2

testTransitionMatrix=ToTransitionMatrix[RateMatrix[{{-2.0,1.0,1.0},{0.2,-1.0,0.8},{0.2,0.2,-0.4}}],2]

The time is store inside the Transitionmatrix Object

NormalForm[testTransitionMatrix]

Convert back to the RateMatrix

ToRateMatrix[testTransitionMatrix]

Analytic Functions

ImpliedTimeScales

Computes the Implied Timescales for a TransitionMatrix using the given Lagtime either included in the TransitionMatrix or overridden as an option. For RateMatrices this is just the negative reciprocal of the eigenvalues.

ImpliedTimeScales[transitionmatrix, options]

ImpliedTimeScales[ratematrix]

Example

ImpliedTimeScales[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}},Lagtime->3]]

ImpliedTimeScales

Computes the Implied Timescales for a TransitionMatrix using the given Lagtime either included in the TransitionMatrix or overridden as an option

ImpliedTimeScales[transitionmatrix, options]

Example

ImpliedTimeScales[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}},Lagtime->3]]

Spectrum

Returns the eigenvalues for Transition and Ratematrices. One eigenvalue is always zero for Ratematrices and one for Transitionmatrices, but can be slightly non-zero due to numerical errors.

Spectrum[object]

Example

Spectrum[RateMatrix[{{-2.0,1.0,1.0},{0.2,-1.0,0.8},{0.2,0.2,-0.4}}]]

Equilibrium

Returns the first left normalized eigenvector for Transition and Ratematrices. This corresponds to the equilibrium distribution of the system described

Equilibrium[object]

Example

Equilibrium[RateMatrix[{{-2.0,1.0,1.0},{0.2,-1.0,0.8},{0.2,0.2,-0.4}}]]

EquilibriumSensitivityTensor

The sensitivity tensor for the equilibrium distribution. Dependence of entries in the equilibrium distribution vector on all entries of the transition matrix

EquilibriumSensitivityTensor[transitionmatrix]

Example

EquilibriumSensitivityTensor[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}},Lagtime->3]]//MatrixForm//Chop

MeanFirstPassageTime

Return the average time to move to a specified state.

MeanFirstPassageTime[transitionmatrix,state,options]

Example

MeanFirstPassageTime[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],1,Lagtime->3]

MeanFirstPassageTimeSensitivityTensor

Returns the sensitivity tensor of the MFPT on changes in the Transitionmatrix.

MeanFirstPassageTimeSensitivityTensor[transitionmatrix,state,options]

Example

MeanFirstPassageTimeSensitivityTensor[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],1,Lagtime->3]//MatrixForm

Committor

Returns the probabilites to reach each of the specified by the states vector before one of the others is reached. Commonly used is the setting for 2-states, but the definition here is more general. It can be used with any amount of states

Committor[transitionmatrix,statesvector]

Example

Committor[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],{1,2}]

CommittorSensitivityMatrix

Returns a sensitivity vector for the committor. More specifications will be added soon...

CommittorSensitivityMatrix[transitionmatrix,statesvector]

Example

CommittorSensitivityMatrix[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],{1,2}]

ToTimeSeries

Returns a TimeSeries of a specified number of transitions using the given transitionmatrix and a given initial state.

ToTimeSeries[transitionmatrix,initialstate,numberoftransitions]

Example

ToTimeSeries[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],1,8]

VisitPredictionMatrix

Returns a matrix with the mean number of visits you get in each state (in columns), when you start in state x (rows) and using a trajectory of length n. So, if you start a trajectory with n transition starting in state i, and want to know, how

often in average state j is visited, then you need to look at element (i,j) of the VisitPredictionMatrix.

VisitPredictionMatrix[transitionmatrix, numberoftransitions]

Example

How often in average do I visit state 3, when I start in 2?

testPredictionMatrix=Chop[VisitPredictionMatrix[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],2]
];
% //MatrixForm

The result is

testPredictionMatrix[[2,3]]

Do 10000 Trajectories and check

testListOfSimulations=Table[ToTimeSeries[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],2,2],{10000}];

Apply Normal to all Simulations and Count How often each number occurs

testResult=Tally[Flatten[Map[Normal,testListOfSimulations]]];
%//TableForm

Pick the result for state 2 and divide it by the number of runs

Select[testResult,#[[1]]==3&]
N[%[[1,2]]/Length[testListOfSimulations]]

This should be pretty close to the analytical result.

Scale

Change the lagtime in a transitionmatrix. Be careful. This is always possible for positive integers, but not necessarily for other real-values numbers. This is the same problem encountered for the conversion from Transitionmatrices to Ratematrices.

Scale[transitionmatrix, scalefactor]

Example

Scale[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}],2]

Applying the matrix twice should have the same effect.This would do the same

TransitionMatrix[#.#,Lagtime->2]&[Normal[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{.1,.15,.75}}]]]

ToTransitionMatrix

Converts a Ratematrix into a Transitionmatrix with given Lagtime using MatrixExp;

ToTransitionMatrix[ratematrix, lagtime]

Example

ToTransitionMatrix[RateMatrix[{{-0.2,.1,.1},{0.05,-0.15,0.1},{.15,0.05,-.2}}],0.1]

Cluster Functions

There are several functions, that create Clustermatrices for various purposes. These can be applied to cluster TimeSeries or other matrices.

CrispClusterMatrix

Creates a clustermatrix assuming that the states in each row belong to one cluster.

CrispClusterMatrix[{statesofcluster1,statesofcluster2,…}]

Example

CrispClusterMatrix[{{1,2},{3,4,5}}]//Normal

RemoveClusterMatrix

Creates a clustermatrix for a given number of states, which will remove the states specified.

RemoveClusterMatrix[statestoberemoved,totalnumberofstates]

Example

RemoveClusterMatrix[{1,5,4},6]//Normal

HasEmptyStatesQ

Checks, if a transition or countmatrix has emptz states

HasEmptyStatesQ[object]

Example

HasEmptyStatesQ[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{0,0,0}}]]

RemoveEmptyStatesClusterMatrix

Creates a clustermatrix that will remove all states, that have no observations in the countmatrix or no transition probabilites

RemoveEmptyStatesClusterMatrix[object]

Example

RemoveEmptyStatesClusterMatrix[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{0,0,0}},Lagtime->3]]

ToCrispRules

Transforms a clustermatrix into rules, that assigns each state a cluster.

ToCrispRules[clustermatrix]

Example

ToCrispRules[RemoveEmptyStatesClusterMatrix[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{0,0,0}},Lagtime->3]]]

Crispify

Returns a clustermatrix, that assign each state to exactly one cluster, no probabilites other than 100% or 0% are allowed.

Crispify[clustermatrix]

Example

Crispify[ClusterMatrix[{{0.2,0.8,0},{0.8,0.2,1}}]]//Normal

Cluster

Apply a clustering to a TimeSeries, Transitionmatrix, Ratematrix or Countmatrix.

Cluster[object,clustermatrix]

Example

Cluster[TransitionMatrix[{{0.7,.1,.2},{.1,.8,.1},{0,0,0}},Lagtime->3],ClusterMatrix[{{0.2,0.8,0},{0.8,0.2,1}}]]

PCCA+ Clustering

PCCASoftClusterMatrix

Performs a PCCA Soft Clustering of a transitionmatrix with a specified number of states

PCCASoftClusterMatrix[transitionmatrix, numberofclusters]

Example

PCCASoftClusterMatrix[TransitionMatrix[{{0.8,.1,.1},{.1,.8,.1},{0,.25,.75}},Lagtime->3],2]//Normal

PCCACrispClusterMatrix

Performs a PCCA Soft Clustering of a transitionmatrix with a specified number of states

PCCACrispClusterMatrix[transitionmatrix, numberofclusters]

Example

PCCACrispClusterMatrix[TransitionMatrix[{{0.8,.1,.1},{.1,.8,.1},{0,.25,.75}},Lagtime->3],2]//Normal

K-Means Clustering

KMeansClustering

Applies a K-Means Clustering to a Trajectory. The initial centers can either be given explicitely or a number can be specified and it will be randomly initialised.

KMeansClustering[trajectory,centers,options]

Example

points=KMeansClustering[Trajectory[RandomReal[1,{100,2}]],5]

Transition Path Theory

ReactiveFluxMatrix

Returns the matrix of reactive flows between all states.

ReactiveFluxMatrix[transitionmatrix,stateA,stateB]

Example

ReactiveFluxMatrix[TransitionMatrix[{{0.8,.1,.1},{.1,.8,.1},{0,.25,.75}}],1,3]//MatrixForm

NetFluxMatrix

Returns the matrix of net reactive flows between all states in direction from A to B.

NetFluxMatrix[transitionmatrix,stateA,stateB]

Example

NetFluxMatrix[TransitionMatrix[{{0.8,.1,.1},{.1,.8,.1},{0,.25,.75}}],1,3]//MatrixForm

ReactivityVector

Returns the reactivity for each state, the probability, that the state participates in trajectories, that start in state A and end in state B.

ReactivityVector[transitionmatrix,stateA,stateB]

Example

ReactivityVector[TransitionMatrix[{{0.8,.1,.1},{.1,.8,.1},{0,.25,.75}}],1,3]

StateExitFlowRate

Compute the StateExitFlowRate. This is the sum over all outgoing TransitionFlows from stateA. This is equivalent to the sum over all incoming TransitionFlowRates into stateB

StateExitFlowRate[transitionmatrix, stateA, stateB]

Example

StateExitFlowRate[TransitionMatrix[{{0.8,.1,.1},{.1,.8,.1},{0,.25,.75}}],1,3]

StateExitFlowRateSensitivityMatrix

Returns a matrix with sensitivity weights for the StateExitFlowRate. This means the complete Error in the StateExitFlowRate is the sum over all errors in the

transitionmatrix weighted with the according element in the sensitivity matrix. In this way the sensitivity matrix is a measure of how strongly a transition

influences the error in the StateExitFlowRate

StateExitFlowRateSensitivityMatrix[transitionmatrix, stateA, stateB]

Example

Compute everything

textCountMatrix=CountMatrix[{{8,1,1},{1,8,1},{0,1,3}}];
testSensitivityMatrix=StateExitFlowRateSensitivityMatrix[MeanMatrix[textCountMatrix],1,3];
testVarianceMatrix=VarianceMatrix[textCountMatrix];
testExitRate=StateExitFlowRate[MeanMatrix[textCountMatrix],1,3]

Compute the total rate by summing over all elements

testExitRateTotalError=Apply[Plus,Flatten[Abs[testSensitivityMatrix*testVarianceMatrix]]];

Plot the sum over all outgoing states, which is the total error by all transitions from a specific state. This is, what you should plot or use in an adaptive method.

testErrorByState=Map[Apply[Plus,#]&,Abs[testSensitivityMatrix*testVarianceMatrix]];
N[%]//MatrixForm

Plot Functions

Usually it is difficult to plot systems with more than two dimensions. I added a few functions, that can plot densities or streams given an arbitrary spacing of points, not only a uniform grid. In most cases the states are associated with a certain position, so that the important object is a list of these points in two dimensions. If this list is just a number n, then it is assumed to be a uniform spaced grid with length n. All functions have the option InterpolationOrder, which can be used in the usual manner.

PositionStreamPlot

Plots Streamlines as given in StreamPlot. In addition there is an option FieldStyle, which can be set to Gradient, Rotation or any other function, that projects a point in the 2 dim space (where the list of points is from) to a 2 dim vector.

PositionStreamPlot[positionlist, valuelist, options]

PositionDensityPlot

Plots a density plot given the positions in positionlist. The options are identitcal to DensityPlot.

PositionDensityPlot[positionlist, valuelist, options]

PositionStreamDensityPlot

A combination of the two above. Options are as StreamDensityPlot with the FieldStyle Option.

PositionStreamDensityPlot[positionlist, valuelist, options]

Examples

We need to read in some example data for later

testTransitionMatrixLarge = TransitionMatrix[ReadSparseMatrix["/Users/jan-hendrikprinz/Desktop/Committor Paper/data/02.t"]];

Show, that it has the correct size. If you run this command, it takes a little while. This is, because internally the whole matrix is printed into the notebook, so don't use this too excessively.

testTransitionMatrixLarge

The matrix has 30x30 = 900 states. Compute the equilibrium distribution for later.

testEquilibriumDistribution = Equilibrium[testTransitionMatrixLarge];

Plot the Density

PositionDensityPlot[30, testEquilibriumDistribution , ColorFunction -> "TemperatureMap"]

And with a higher interpolation order

PositionDensityPlot[30, testEquilibriumDistribution , InterpolationOrder -> 3, ColorFunction -> "TemperatureMap"]

Plot the gradient of the equilibrium distribution

PositionStreamPlot[30, testEquilibriumDistribution ]

Plot the Normals (the rotation of the field)

PositionStreamPlot[30, testEquilibriumDistribution , FieldStyle -> Rotation, InterpolationOrder -> 1]

PositionStreamDensityPlot[30, testEquilibriumDistribution, ColorFunction -> "SunsetColors", StreamColorFunction -> (GrayLevel[1] &)]

Read / Write Functions

ReadSparseMatrix

Import a Matrix in sparse format (row column value). Returned is a regular matrix

ReadSparseMatrix[filename, options]

Example

testTransitionMatrix=TransitionMatrix[ReadSparseMatrix["filename"]];

WriteSparseMatrix

Export a Transitionmatrix, Ratematrix, Countmatrix or a regular matrix in sparse format (row column value), options are not saved!!!

WriteSparseMatrix[filename, object, options]

Example

WriteSparseMatrix["filename",TransitionMatrix[{{0.9,0.1},{0.8,0.2}}]]

.STILL TO BE IMPLEMENTED

Hummer Method to get Rate Matrices

Easy concept, but not easy to implement with simple Mathematica Functions
Got a working scheme for a 4x4 system. Larger failed because of a complicated solution of the MatrixExp Method. Need some way to make it evaluate only inside the NMinimize function, when explicit numbers are given
Maybe it is possible to adapt the Boxer Method to result in same solution.

Franks Method to sample Matrices from Dirichlet Distribution with Detailed Balance Constraint, Positivity Constraint and/or given Equilibrium Distribution

Should be easy, but not sure yet, what is the easiest way to add it to the library, maybe also as a Distribution without Mean / Variance, just DrawTransitionMatrix / DrawTransitionMatrixSeries implemented, Options may be given to set initial conditions

Visualization

Use some things from other former notebooks. Maybe make a suitable colorrange. Makes no sense to incluse 0.5 in the colorrange, since this is not precise enough. Use Mesh -> 0.5 instead.

Display states with number at their given position

Error Messages

Enter all error messages necessary for reasonable usage and debugging

Documentation

Finished all included functions. Extended Examples Section, Introduction and Bibliography still missing

.BIBLIOGRAPHY

Literature Links, etc.

.APPENDIX

Additional Material