# Documentation - multi\_normal\_cholesky\_lpdf

**URL:** <https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404>\
**Category:** Modeling\
**Tags:** specification\
**Created:** [January 23, 2019, 12:20pm UTC](https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404 "2019-01-23T12:20:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jozsef\_Hegedus](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jozsef_hegedus/32/3825_2.png) [@Jozsef\_Hegedus](https://discourse.mc-stan.org/u/Jozsef_Hegedus)\
**Post date:** [January 23, 2019, 12:20pm UTC](https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404/1 "2019-01-23T12:20:43Z")

</div>

Dear STAN Community,

I am trying to understand [this](https://maggielieu.com/2017/03/21/multivariate-gaussian-mixture-model-done-properly/) tutorial on multivariate GMM in STAN for which the code can be seen below.

Where can I read a documentation about `multi_normal_cholesky_lpdf` ? Or what it does exactly ?

I did a Google search on “`multi_normal_cholesky_lpdf`”, but I only got STAN source code as result :) . I cannot really read very well C++ :(

Is there some way to figure out what “`multi_normal_cholesky_lpdf`” means ?

Regards,

Jozsef

```stan
data {
 int D; //number of dimensions
 int K; //number of gaussians
 int N; //number of data
 vector[D] y[N]; //data
}

parameters {
 simplex[K] theta; //mixing proportions
 ordered[D] mu[K]; //mixture component means
 cholesky_factor_corr[D] L[K]; //cholesky factor of covariance
}

model {
 real ps[K];
 
 for(k in 1:K){
 mu[k] ~ normal(0,3);
 L[k] ~ lkj_corr_cholesky(4);
 }
 

 for (n in 1:N){
 for (k in 1:K){
 ps[k] = log(theta[k])+multi_normal_cholesky_lpdf(y[n] | mu[k], L[k]); //increment log probability of the gaussian
 }
 target += log_sum_exp(ps);
 }

}

```

---

<div class="post-metadata">

**Author:** ![jjramsey](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jjramsey/32/3319_2.png) [@jjramsey](https://discourse.mc-stan.org/u/jjramsey)\
**Post date:** [January 24, 2019, 1:30pm UTC](https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404/2 "2019-01-24T13:30:58Z")

</div>

Try either of these:

- [https://mc-stan.org/docs/2\_18/functions-reference/multi-normal-cholesky-fun.html](https://mc-stan.org/docs/2_18/functions-reference/multi-normal-cholesky-fun.html)
- [https://github.com/stan-dev/stan/releases/download/v2.18.0/functions-reference-2.18.0.pdf](https://github.com/stan-dev/stan/releases/download/v2.18.0/functions-reference-2.18.0.pdf)

---

<div class="post-metadata">

**Author:** ![Jozsef\_Hegedus](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jozsef_hegedus/32/3825_2.png) [@Jozsef\_Hegedus](https://discourse.mc-stan.org/u/Jozsef_Hegedus)\
**Post date:** [January 26, 2019, 12:17am UTC](https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404/3 "2019-01-26T00:17:37Z")

</div>

Many thanks @jjramsey ! This is a life saver !

OTOH

I am reading the ScalaStan source code and it is almost the best documentation I found so far :)

> <https://github.com/cibotech/ScalaStan/blob/5cb89d4a8c7f566de570839cf95822cf7002680d/src/main/scala/com/cibo/scalastan/StanType.scala>

---

<div class="post-metadata">

**Author:** ![increasechief](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/increasechief/32/2039_2.png) [@increasechief](https://discourse.mc-stan.org/u/increasechief)\
**Post date:** [January 27, 2019, 4:26am UTC](https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404/4 "2019-01-27T04:26:51Z")

</div>

I often turn to [mc-stan.org/math](http://mc-stan.org/math) as a first reference for the Stan language. I think the presentation is often more direct to the code that what is found in the documentation.

Here’s the entry for the mnc\_ldpf: [http://mc-stan.org/math/d4/d84/namespacestan\_1\_1math.html#a01a389356ff3fe918b7add26367c87c2](http://mc-stan.org/math/d4/d84/namespacestan_1_1math.html#a01a389356ff3fe918b7add26367c87c2)

This happens to be a particularly good example as it even includes a citation omitted from the function documentation.

---

<div class="post-metadata">

**Author:** ![Jozsef\_Hegedus](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jozsef_hegedus/32/3825_2.png) [@Jozsef\_Hegedus](https://discourse.mc-stan.org/u/Jozsef_Hegedus)\
**Post date:** [January 28, 2019, 10:46am UTC](https://discourse.mc-stan.org/t/documentation-multi-normal-cholesky-lpdf/7404/5 "2019-01-28T10:46:58Z")

</div>

Thanks for the tip @increasechief !

I just had a look.

Is it possible to directly “test drive” these functions ?

Without any sampling or anything ?

Just put some numbers into them and calculate/plot what they output ?

Without writing a custom C++ code for that ? (I don’t feel like learning C++ :( - so that I can understand / debug Stan code / functions.)

For example, if I create a likelihood function in Stan, is it possible to “plot it” (as a function of it’s parameters) ? Say using R ?

Cheers,

Jozsef
