stochasticMatrixPro​jection(A,projectio​n_type)

Finds the closest stochastic matrix
169 Downloads
Updated 23 May 2015

View License

Given a matrix A it finds the closest matrix which is column stochastic (left stochastic matrix ).
This is based on vector implementation in http://www.mathworks.com/matlabcentral/fileexchange/30332-projection-onto-simplex which is based on the paper http://arxiv.org/abs/1101.6081
Two type of projections are supproted:
1. "on simplex" - Each entry is in [0,1] and each columns sums to one.
2. "inside simplex" - Each entry is in [0,1] and each columns sum is also in [0,1]
input:
A - matrix, which columns to project
projection_type - which type of projection to make:
'on' - on the simplex, each column sums to one (default)
'inside' - inside the simplex, each column sum is in the interval[0,1]
example:
vec_2d = rand(2,200)*3 - 1;
proj_vec = stochasticMatrixProjection(vec_2d,'on');
subplot(1,2,1);
plot([vec_2d(1,:);proj_vec(1,:)],[vec_2d(2,:);proj_vec(2,:)],...
[vec_2d(1,:);proj_vec(1,:)],[vec_2d(2,:);proj_vec(2,:)],'.'); axis equal
subplot(1,2,2);
proj_vec = stochasticMatrixProjection(vec_2d,'inside');
plot([vec_2d(1,:);proj_vec(1,:)],[vec_2d(2,:);proj_vec(2,:)],...
[vec_2d(1,:);proj_vec(1,:)],[vec_2d(2,:);proj_vec(2,:)],'.'); axis equal

Cite As

Lior Kirsch (2024). stochasticMatrixProjection(A,projection_type) (https://www.mathworks.com/matlabcentral/fileexchange/50779-stochasticmatrixprojection-a-projection_type), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Polynomials in Help Center and MATLAB Answers
Acknowledgements

Inspired by: Projection onto simplex

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.3.0.0

Replaced repmat with bsxfun

1.2.0.0

Example added.

1.1.0.0

* added text to the description

1.0.0.0