-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatslib_docs_wish.html
206 lines (147 loc) · 5.66 KB
/
statslib_docs_wish.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="StatsLib is a templated C++ library for fast computation of statistical distribution functions.">
<meta name="author" content="Keith O'Hara">
<meta name="keywords" content="Statistics, Probability, Distributions, C++, Cpp, C++11, constexpr, Econometrics" />
<link rel="shortcut icon" type="image/x-icon" href="siteicon.ico">
<title>StatsLib: Wishart Distribution</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/modern-business.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- Additional Settings -->
<link href="css/yuxuan_settings.css" rel="stylesheet">
<!-- Syntax Highlighter -->
<script type="text/javascript" src="js/syntaxhighlighter.js"></script>
<link type="text/css" rel="stylesheet" href="css/swift_theme.css">
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-93902857-1', 'auto');
ga('send', 'pageview');
</script>
<!-- MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
</script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script src="js/jquery.js"></script>
<script>
$(function(){
$("#mynavbar").load("navbar.html")
$("#statshead").load("statslib_header.html")
$("#myfooter").load("footer.html")
});
</script>
</head>
<style>
pre {
display: inline-block;
}
</style>
<body>
<!-- Navigation -->
<div id="mynavbar"></div>
<!-- Page Content -->
<div class="container">
<!-- Page Heading/Breadcrumbs -->
<div id="statshead"></div>
<!-- -->
<br>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-5">
<div class="panel panel-default">
<div class="panel-heading">
<a data-toggle="collapse" href="#collapse1"><h4><strong style="font-size: 120%;">StatsLib: Wishart Distribution</strong></h4></a>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
<a href="#intro">Introduction</a> <br>
<a href="#density">Density</a> <br>
<a href="#random">Random Sampling</a>
</div>
</div>
</div>
</div>
</div>
<!-- -->
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<hr style="height:2px;border-width:0;background-color:black">
<h3 style="text-align: left;" id="intro"><strong style="font-size: 120%;">Introduction</strong></h3>
<p>The density function of the inverse-Wishart distribution:</p>
$$
f(\mathbf{X}; \boldsymbol{\Psi}, \nu) = \dfrac{1}{2^{\frac{\nu p}{2}} |\boldsymbol{\Psi}|^{\frac{\nu}{2}} \Gamma_p\left( \frac{\nu}{2} \right)} | \mathbf{X} |^{\frac{\nu - p - 1}{2}} \exp \left( - \frac{1}{2} \text{tr} (\boldsymbol{\Psi}^{-1} \mathbf{X}) \right)
$$
<p>where $\Gamma_p$ is the multivariate gamma function.</p>
<p>Parameters:</p>
<ul>
<li><code>Psi_par</code> is $\boldsymbol{\Psi}$</li>
<li><code>nu_par</code> is $\nu$</li>
</ul>
<hr style="height:2px;border-width:0;background-color:black">
<!-- -->
<h3 style="text-align: left;" id="density"><strong style="font-size: 120%;">Density</strong></h3>
<br>
<p><strong>Definition:</strong></p>
<pre class="brush: cpp;">
template<typename mT, typename pT>
statslib_inline
return_t<pT> dwish(const mT& X, const mT& Psi_par, const pT nu_par, bool log_form = false);
</pre>
<p>Computes the density function.</p>
<hr>
<p><strong>Examples:</strong></p>
<pre class="brush: cpp;">
// parameters
arma::mat Psi = arma::eye(5,5);
double nu = 10.0;
// Armadillo input
arma::mat X(10,1);
X.fill(2.5);
arma::mat dens_vals_mat = stats::dwish(X,Psi,nu);
arma::mat log_dens_vals_mat = stats::dwish(X,Psi,nu,true);
</pre>
<hr style="height:2px;border-width:0;background-color:black">
<!-- -->
<h3 style="text-align: left;" id="random"><strong style="font-size: 120%;">Random Sampling</strong></h3>
<br>
<p><strong>Definition:</strong></p>
<pre class="brush: cpp;">
template<typename mT, typename pT>
statslib_inline
mT rwish(const mT& Psi_par, const pT nu_par, const bool pre_chol = false);
</pre>
<p>Generates pseudo-random draws.</p>
<p>Here <code>pre_chol</code> indicates whether <code>Psi_par</code> is being passed as a Cholesky decomposition (in <strong>lower triangular</strong> format).</p>
<hr>
<p><strong>Examples:</strong></p>
<pre class="brush: cpp;">
// parameters
arma::mat Psi = arma::eye(5,5);
double nu = 10.0;
// Armadillo output
arma::mat rand_mat = stats::rwish<arma::mat>(Psi,nu);
</pre>
<hr style="height:2px;border-width:0;background-color:black">
</div>
</div>
</div>
<div id="myfooter"></div>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>