stochasticMatrixProjection(A,projection_type)
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
Cita come
Lior Kirsch (2024). stochasticMatrixProjection(A,projection_type) (https://www.mathworks.com/matlabcentral/fileexchange/50779-stochasticmatrixprojection-a-projection_type), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxCategorie
- MATLAB > Mathematics > Elementary Math > Polynomials >
Tag
Riconoscimenti
Ispirato da: Projection onto simplex
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.