-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
row/col stochastic matrix documentation #807
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this up. I had a bajillion little detailed comments here---sorry about that in advance.
src/reference-manual/transforms.qmd
Outdated
\sum_{i=1}^N X_{ij} = 1. | ||
$$ | ||
|
||
A row stochastic matrix is defined similarly but with the axis flipped such |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as easy to say a row stochastic matrix is any matrix whose transpose is a column stochastic matrix.
I would also say in words that a column stochastic matrix has columns that are simplexes, whereas the row version has rows that are simplexes.
I've tried to write matrix subscripts as "i, j" rather than "ij" to allow for multiple-character subscripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, can't believe I forgot to just say what this is in simple terms
src/reference-manual/transforms.qmd
Outdated
@@ -672,6 +672,72 @@ z_k | |||
. | |||
$$ | |||
|
|||
## Stochastic Matrix {#stochastic-matrix-transform.section} | |||
|
|||
The `column_stochastic_matrix[N, M]` and `row_stochastic_matrix[N, M]` type in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've used "col" everywhere else for column. Should this match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed irl, we are wishy washy with col vs column abbreviation, but I like column here so going to keep it
src/reference-manual/transforms.qmd
Outdated
\sum_{j=1}^N X_{ij} = 1. | ||
$$ | ||
|
||
This definition ensures that each column(row) of the matrix \(X\) lies on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between column and ( --- this also appears later
Just stick to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I had a reason for why I did that (eigen docs did column(row)), but it looks like they fixed it in their docs so I'll fix it here as well
src/reference-manual/types.qmd
Outdated
A stochastic matrix is a matrix where each column, row, or both is a | ||
unit simplex, meaning that each column(row) vector has non-negative | ||
values that sum to 1. For example, a \(3 \times 4\) | ||
column stochastic matrix will look like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say:
"The following example is a
Note that it's a period at the end this way and doesn't assert that a column stochastic matrix will look one way or another. Also note that when you use a noun compound like "column stochastic" as an adjective (here modifying "matrix") then it should be hyphenated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fixed Column-matrix below
src/reference-manual/types.qmd
Outdated
\end{bmatrix} | ||
$$ | ||
|
||
While a row stochastic matrix will look like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a complete sentence---it's just a free-floating clause. How about:
"An example of a row-stochastic matrix is the following."
src/reference-manual/types.qmd
Outdated
each column represents a probability distribution across a | ||
set of categories, such as in multiple multinomial distributions, | ||
transition matrices in Markov models, or compositional data analysis. | ||
They can also be used in situations where multiple Dirichlet-distributed v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd drop the Dirichlet comment here. You can just say they can be used whenever you need multiple simplexes of the same dimensionality.
The other big application here is factor models, so you should definitely mention those. The rows in the row stochastic matrix in these models is, for exmaple, is something like the proportion of pollutants being emitted from a factory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added factor model to the examples
src/reference-manual/types.qmd
Outdated
ariables are required across different dimensions. | ||
|
||
The `column_stochastic_matrix` and `row_stochastic_matrix` types are declared | ||
with full dimensionality. For instance, a matrix `theta` with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full dimensionality ---> row and column sizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/reference-manual/types.qmd
Outdated
column_stochastic_matrix[3, 4] theta; | ||
``` | ||
|
||
A matrix `theta` with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many line breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/reference-manual/types.qmd
Outdated
row_stochastic_matrix[3, 4] theta; | ||
``` | ||
|
||
As with simplexes, `column(row)_stochastic_matrix` variables are subject to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too hard to parse---just repeat, we have tons of space here. That is, separate out column_stochastic_matrix and row_stochastic_matrix.
src/reference-manual/types.qmd
Outdated
|
||
#### Stability Considerations {-} | ||
|
||
In high-dimensional settings or when the matrix has many columns, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear how "high-dimensional" and "has many columns" differ. Is high-dimensional the rows? I'd just say "high-dimensional" here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple cosmetic changes and this is good to go.
the lower-triangular Jacobian matrix. This determinant is calculated as: | ||
|
||
$$ | ||
\left| \det J_j \right| = \prod_{i=1}^{N-1} \left( z_{i, j} (1 - z_{i, j}) \left( 1 - \sum_{i'=1}^{i-1} X_{i'j} \right) \right). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J_j is unfortunate notation. We've tried to maintain a convention of using n in 1:N for indexing with lower case matching the name of the upper case bounds. So I'd take this to be J_m for m in 1:M. And similarly, convert the earlier thing to using n.
I've also tried to use commas between indexes everywhere---you're doing this in some places (like z) but not others (like X). Please make this consistently use commas.
### Stochastic Matrices {-} | ||
|
||
A stochastic matrix is a matrix where each column, row, or both is a | ||
unit simplex, meaning that each column (row) vector has non-negative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the "both" description here as we're not providing that functionality for users (at least not yet!).
Adds docs for row and column stochastic matrix types.
I tried not to repeat myself too much by doing something similar to what Eigen does for csr matrices and csc matrices. I mostly explained the
column_stochastic_matrix
type and noted the differences forrow_stochastic_matrix
when necessary. Is that alright?Submission Checklist
<<{ since VERSION }>>
Summary
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Simons Foundation
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: