Commit 915bb4c4 authored by George Perendia's avatar George Perendia

Estimation C++ DLL: Bug-fixing Sampler

parent e04a07c7
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
#include "RandSampler.hh" #include "RandSampler.hh"
#include "BlasBindings.hh"
/** /**
* draw = Mean + randn(1,n) * Sigma_upper_chol; * draw = Mean + randn(1,n) * Sigma_upper_chol;
...@@ -32,12 +33,14 @@ void ...@@ -32,12 +33,14 @@ void
RandSampler::randMultiVar(Prior &distribution, Vector &draw, const Vector &mean, const Matrix &Scale, const size_t n) RandSampler::randMultiVar(Prior &distribution, Vector &draw, const Vector &mean, const Matrix &Scale, const size_t n)
{ {
assert(n == draw.getSize()); assert(n == draw.getSize());
assert(n == mean.getSize() || 1 == mean.getSize()); assert(n == mean.getSize() );
assert(n == Scale.getRows() || 1 == Scale.getRows()); assert(n == Scale.getRows());
assert(n == Scale.getCols() || 1 == Scale.getCols()); assert(n == Scale.getCols());
draw=mean;
Vector drawTmp(n);
for (size_t i = 0; i < n; ++i) for (size_t i = 0; i < n; ++i)
draw(i) = mean(1 == mean.getSize() ? 0 : i) drawTmp(i) = distribution.drand();
+ distribution.drand() blas::gemv("T", 1.0, Scale, drawTmp, 1.0, draw);
*Scale((1 == Scale.getRows() ? 0 : i), (1 == Scale.getCols() ? 0 : i));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment