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