@@ -674,6 +674,83 @@ iterations, and in either case, with less dispersed parameter
674
674
initialization or custom initialization if there are informative
675
675
priors for some parameters.
676
676
677
+ ### Stochastic Matrices {-}
678
+
679
+ A stochastic matrix is a matrix where each column or row is a
680
+ unit simplex, meaning that each column (row) vector has non-negative
681
+ values that sum to 1. The following example is a \( 3 \times 4\)
682
+ column-stochastic matrix.
683
+
684
+ $$
685
+ \begin{bmatrix}
686
+ 0.2 & 0.5 & 0.1 & 0.3 \\
687
+ 0.3 & 0.3 & 0.6 & 0.4 \\
688
+ 0.5 & 0.2 & 0.3 & 0.3
689
+ \end{bmatrix}
690
+ $$
691
+
692
+ An example of a \( 3 \times 4\) row-stochastic matrix is the following.
693
+
694
+ $$
695
+ \begin{bmatrix}
696
+ 0.2 & 0.5 & 0.1 & 0.2 \\
697
+ 0.2 & 0.1 & 0.6 & 0.1 \\
698
+ 0.5 & 0.2 & 0.2 & 0.1
699
+ \end{bmatrix}
700
+ $$
701
+
702
+
703
+ In the examples above, each column (or row) sums to 1, making the matrices
704
+ valid ` column_stochastic_matrix ` and ` row_stochastic_matrix ` types.
705
+
706
+ Column-stochastic matrices are often used in models where
707
+ each column represents a probability distribution across a
708
+ set of categories such as in multiple multinomial distributions,
709
+ factor models, transition matrices in Markov models,
710
+ or compositional data analysis.
711
+ They can also be used in situations where you need multiple simplexes
712
+ of the same dimensionality.
713
+
714
+ The ` column_stochastic_matrix ` and ` row_stochastic_matrix ` types are declared
715
+ with row and column sizes. For instance, a matrix ` theta ` with
716
+ 3 rows and 4 columns, where each
717
+ column is a 3-simplex, is declared like a matrix with 3 rows and 4 columns.
718
+
719
+ ``` stan
720
+ column_stochastic_matrix[3, 4] theta;
721
+ ```
722
+
723
+ A matrix ` theta ` with 3 rows and 4 columns, where each row is a 4-simplex,
724
+ is similarly declared as a matrix with 3 rows and 4 columns.
725
+
726
+ ``` stan
727
+ row_stochastic_matrix[3, 4] theta;
728
+ ```
729
+
730
+ As with simplexes, ` column_stochastic_matrix ` and ` row_stochastic_matrix `
731
+ variables are subject to validation, ensuring that each column (row)
732
+ satisfies the simplex constraints. This validation accounts for
733
+ floating-point imprecision, with checks performed up to a statically
734
+ specified accuracy threshold \( \epsilon\) .
735
+
736
+ #### Stability Considerations {-}
737
+
738
+ In high-dimensional settings, ` column_stochastic_matrix ` and ` row_stochastic_matrix `
739
+ types may require careful tuning of the inference
740
+ algorithms. To ensure stability:
741
+
742
+ - ** Smaller Step Sizes:** In samplers like Hamiltonian Monte Carlo (HMC),
743
+ smaller step sizes can help maintain stability, especially in high dimensions.
744
+ - ** Higher Target Acceptance Rates:** Setting higher target acceptance
745
+ rates can improve the robustness of the sampling process.
746
+ - ** Longer Warmup Periods:** Increasing the warmup period allows the sampler
747
+ to better explore the parameter space before the actual sampling begins.
748
+ - ** Tighter Optimization Tolerances:** For optimization-based inference,
749
+ tighter tolerances with more iterations can yield more accurate results.
750
+ - ** Custom Initialization:** If prior information about the parameters is
751
+ available, custom initialization or less dispersed initialization can lead
752
+ to more efficient inference.
753
+
677
754
### Unit vectors {-}
678
755
679
756
A unit vector is a vector with a norm of one. For instance, $[ 0.5,
0 commit comments