<p dir="auto">Currently, <code class="notranslate">numpy.random.multivariate_normal</code> makes use of SVD decomposition, <code class="notranslate">numpy.dual.svd</code>, on the provided covariance matrix to perform the sampling. This approach allows the use of positive semi-definite covariance matrix. However, it is not unique as the singular vectors are not guaranteed to be. In fact,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[[-1, 0],
 [0,  -1]]"><pre class="notranslate"><code class="notranslate">[[-1, 0],
 [0,  -1]]
</code></pre></div>
<p dir="auto">and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[[1, 0],
 [0,  1]]"><pre class="notranslate"><code class="notranslate">[[1, 0],
 [0,  1]]
</code></pre></div>
<p dir="auto">can be the singular-vectors of a 2-by-2 identity matrix.</p>
<p dir="auto">A Cholesky decomposition instead would result in an unique decomposition with the down side of only working on positive definite matrices. We could use instead a Cholesky decomposition with complete pivoting: <a href="http://www.netlib.org/lapack/explore-html/da/dba/group__double_o_t_h_e_rcomputational_ga31cdc13a7f4ad687f4aefebff870e1cc.html" rel="nofollow">http://www.netlib.org/lapack/explore-html/da/dba/group__double_o_t_h_e_rcomputational_ga31cdc13a7f4ad687f4aefebff870e1cc.html</a><br>
It provides both advantages: works on positive semi-definite matrices and are unique (as far as I know).</p>
<p dir="auto">Any thoughts?</p>
<p dir="auto">Related issue: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="434285705" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/13358" data-hovercard-type="issue" data-hovercard-url="/numpy/numpy/issues/13358/hovercard" href="https://github.com/numpy/numpy/issues/13358">#13358</a></p>
<p dir="auto">Reported on the distutils-sig by Paul Moore.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="A quick test later:
No BLAS/ATLAS/LAPACK causes a string of warnings, And ignoring the
rest of the error stack (which I'm frankly not interested in investing
the time to diagnose and fix) I get &quot;RuntimeError: Broken toolchain:
cannot link a simple C program&quot;. Which is utter rubbish - I routinely
build extensions with this installation."><pre class="notranslate"><code class="notranslate">A quick test later:
No BLAS/ATLAS/LAPACK causes a string of warnings, And ignoring the
rest of the error stack (which I'm frankly not interested in investing
the time to diagnose and fix) I get "RuntimeError: Broken toolchain:
cannot link a simple C program". Which is utter rubbish - I routinely
build extensions with this installation.
</code></pre></div>