<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problem with geration method in random number generatior in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773348#M806</link>
    <description>Dear Andrey,&lt;BR /&gt;&lt;BR /&gt;Thanks so much for your correction. I define a constructor and a destructor and everything looks fine. But I still don't understand why BOXMULLER will work but ICDF doesn't.&lt;BR /&gt;&lt;BR /&gt;Thanks so much.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Stanley KO</description>
    <pubDate>Wed, 28 Jul 2010 07:40:45 GMT</pubDate>
    <dc:creator>stanleyimko</dc:creator>
    <dc:date>2010-07-28T07:40:45Z</dc:date>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773342#M800</link>
      <description>Hi, I am doing a linear regression simulation but found something confusing. I generate 1000 observations with the following design.&lt;BR /&gt;&lt;BR /&gt;True model:&lt;BR /&gt;&lt;BR /&gt;Model1: y_1 = x_1 + 0.9 * x_2 + 0.7 * x_3 + e_1&lt;BR /&gt;Model2: y_2 = x_1 + 0.9 * x_2 + 0.7 * x_3 + e_2&lt;BR /&gt;&lt;BR /&gt;where x_1, x_2, x_3 following Uniform distribution in (0, 1), e_1 and e_2 are both Gaussian(0, 1).&lt;BR /&gt;&lt;BR /&gt;I simulate e_1 and e_2 with different methods namely VSL_METHOD_DGAUSSIAN_BOXMULLER and VSL_METHOD_DGAUSSIAN_ICDF.&lt;BR /&gt;&lt;BR /&gt;vdRngGaussian ( VSL_METHOD_DGAUSSIAN_BOXMULLER, stream, 1000, e_1, 0.0, 1.0 );&lt;BR /&gt;&lt;BR /&gt;vdRngGaussian ( VSL_METHOD_DGAUSSIAN_ICDF, stream, 1000, e_2, 0.0, 1.0 );&lt;BR /&gt;&lt;BR /&gt;And then I run two regressions. The first model gives a good estimate but the second one is very poor. Just a few trails:&lt;BR /&gt;&lt;BR /&gt;Model1: 0.911859 0.995013  0.712112&lt;BR /&gt;Model2: 3.31478 -0.116816 - 0.232942&lt;BR /&gt;&lt;BR /&gt;Model1: 0.945507 0.89906 0.746299&lt;BR /&gt;Model2: 3.40879 -0.149013 -0.306843&lt;BR /&gt;&lt;BR /&gt;Model1: 1.10576 0.825391 0.694707&lt;BR /&gt;Model2: 3.32135 -0.122911 -0.276134&lt;BR /&gt;&lt;BR /&gt;At the very beginning I use ICDF but the bias is very serious. It costs me a lot of time to figure out the source of the problem. But I still don't understand why it is so sensitive to the generating method. Thanks.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Jul 2010 09:13:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773342#M800</guid>
      <dc:creator>stanleyimko</dc:creator>
      <dc:date>2010-07-27T09:13:22Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773343#M801</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Can you please provide more details for your linear regression simulations:&lt;BR /&gt;&lt;BR /&gt;1. Which Intel MKL version do you use? Which OS and mode, IA-32 or Intel 64?&lt;BR /&gt;2. How do you link against MKL?&lt;BR /&gt;3. Which basic random number generator(s) is(are) used for the simulations?&lt;BR /&gt;4. Do you provide the same sequence of uniform random numbers into both models, so the models are different in just source of Gaussian numbers?&lt;BR /&gt;5. Whatare the sample mean/other sample estimates in both models?Are theyclose to the theoretical?&lt;BR /&gt;&lt;BR /&gt;Ideally, a short test case (the extract from your simulation application)that demonstrates the issue would be sufficient.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Andrey &lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2010 09:41:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773343#M801</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2010-07-27T09:41:46Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773344#M802</link>
      <description>Hi, Andrey,&lt;BR /&gt;&lt;BR /&gt;I am using MKL10.2 with Intel64, Intel C++ compiler 11.1, and my OS is OpenSUSE 11.2. I compile with the following link&lt;BR /&gt;&lt;BR /&gt;-L$MKLPATH $MKLPATH/libmkl_solver_lp64.a -Wl,--start-group
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -Wl,--end-group -openmp
-lpthread &lt;BR /&gt;&lt;BR /&gt;and the following random number generator&lt;BR /&gt;&lt;BR /&gt;Uniform: vdRngUniform ( VSL_METHOD_DUNIFORM_STD_ACCURATE, stream, 1000, x, 0.0, 1.0 );&lt;BR /&gt;Gaussian: vdRngGaussian ( VSL_METHOD_DGAUSSIAN_BOXMULLER, stream, 1000, e_1, 0.0, 1.0 );&lt;BR /&gt; vdRngGaussian ( VSL_METHOD_DGAUSSIAN_ICDF, stream, 1000, e_2, 0.0, 1.0 );&lt;BR /&gt;&lt;BR /&gt;I use the same sequence of x's in two equations. all the sample mean and sd are consistent with the setting.&lt;BR /&gt;&lt;BR /&gt;I just come up with the idea that ICDF is the inverse transformation form the uniform distribution. So my x's would be correlated with the e generating by ICDF. That's why the regression will be bias. &lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Stanley KO</description>
      <pubDate>Tue, 27 Jul 2010 10:57:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773344#M802</guid>
      <dc:creator>stanleyimko</dc:creator>
      <dc:date>2010-07-27T10:57:49Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773345#M803</link>
      <description>&lt;P&gt;Hi Stanley,&lt;/P&gt;&lt;P&gt;Thank you much for the additional details. I still have a few questions below to clarify.&lt;BR /&gt;To my understanding, your computational scheme is as follows (please feel free to correct or/and add more details):&lt;/P&gt;&lt;P&gt;1. Create random stream&lt;BR /&gt;&lt;BR /&gt;errcode = vslNewStream( &amp;amp;stream, BRNG, SEED );&lt;BR /&gt;Can you please specify value for BRNG and SEED parameters?&lt;BR /&gt;&lt;BR /&gt;2. Generate random numbers&lt;/P&gt;&lt;P&gt;vdRngUniform ( VSL_METHOD_DUNIFORM_STD_ACCURATE, stream, 1000, x, 0.0, 1.0 );&lt;BR /&gt;vdRngGaussian ( method, stream, 1000, e, 0.0, 1.0 );&lt;/P&gt;&lt;P&gt;where method is VSL_METHOD_DGAUSSIAN_BOXMULLER or VSL_METHOD_DGAUSSIAN_ICDF and e is e_1 or e_2.&lt;/P&gt;&lt;P&gt;Both BoxMuller and ICDF methods transform uniform numbers to produce Gaussian sequence.&lt;BR /&gt;If you use pseudo-random number generator like MT19937 you would not expect that uniform numbers x_i and uniforms underneath Gaussian generator are correlated, and thus, no bias should be in your simulations. On the other hand, if you use SOBOL quasi-random number generator as the source of uniform random numbers generally you can run into correlated variates.&lt;BR /&gt;For those reasons it could be important to understand which BRNG and seed are used in the simulations.&lt;/P&gt;&lt;P&gt;3. Do regression computations.&lt;BR /&gt;According to the equations you provided you need 3 uniform numbers and one normal variate per one output. Does it make sense to generate 3000 uniforms and 1000 Gaussian numbers to obtain 1000 model outputs?&lt;BR /&gt;&lt;BR /&gt;4. Delete stream&lt;BR /&gt;&lt;BR /&gt;errcode = vslDeleteStream( &amp;amp;stream );&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jul 2010 12:01:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773345#M803</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2010-07-27T12:01:45Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773346#M804</link>
      <description>Dear Angrey,&lt;BR /&gt;&lt;BR /&gt;I may post my source code. I have two files. One defines the class for random number generation and the other is the main file.&lt;BR /&gt;&lt;BR /&gt;/******************CLASS FOR RANDOM NUMBER GENERATION*******************/&lt;BR /&gt;#include &lt;CTIME&gt;&lt;BR /&gt;#include "mkl.h"&lt;BR /&gt;&lt;BR /&gt;#define BRNG VSL_BRNG_MT19937 &lt;BR /&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;&lt;BR /&gt;class sim &lt;BR /&gt;{&lt;BR /&gt;private:&lt;BR /&gt;&lt;BR /&gt; VSLStreamStatePtr stream; &lt;BR /&gt;&lt;BR /&gt;public:&lt;BR /&gt;&lt;BR /&gt; int error_code;&lt;BR /&gt;&lt;BR /&gt; void gaussian_1 ( int, double *, double, double );&lt;BR /&gt;&lt;BR /&gt; void gaussian_2 ( int, double *, double, double );&lt;BR /&gt;&lt;BR /&gt; void uniform ( int, double *, double, double );&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;void sim::gaussian_1 ( int N, double * r, double mean, double sigma ) // gaussian with BOXMULLER&lt;BR /&gt;{&lt;BR /&gt; vslNewStream( &amp;amp;stream, BRNG, time(0) );&lt;BR /&gt; &lt;BR /&gt; error_code = vdRngGaussian ( VSL_METHOD_DGAUSSIAN_BOXMULLER, stream, N, r, mean, sigma );&lt;BR /&gt;&lt;BR /&gt; vslDeleteStream ( &amp;amp;stream );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void sim::gaussian_2 ( int N, double * r, double mean, double sigma ) // gaussian with ICDF&lt;BR /&gt;{&lt;BR /&gt; vslNewStream( &amp;amp;stream, BRNG, time(0) );&lt;BR /&gt; &lt;BR /&gt; error_code = vdRngGaussian ( VSL_METHOD_DGAUSSIAN_ICDF, stream, N, r, mean, sigma );&lt;BR /&gt;&lt;BR /&gt; vslDeleteStream ( &amp;amp;stream );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;void sim::uniform ( int N, double * r, double a, double b)&lt;BR /&gt;{&lt;BR /&gt; vslNewStream( &amp;amp;stream, BRNG, time(0) );&lt;BR /&gt;&lt;BR /&gt; error_code = vdRngUniform ( VSL_METHOD_DUNIFORM_STD_ACCURATE, stream, N, r, a, b );&lt;BR /&gt;&lt;BR /&gt; vslDeleteStream( &amp;amp;stream );&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/*************************THE MAIN FILE***************************/&lt;BR /&gt;&lt;P&gt;&lt;BR /&gt;#include "./sim.h"&lt;BR /&gt;
&lt;BR /&gt;
#define N 1000&lt;BR /&gt;
&lt;BR /&gt;
int main()&lt;BR /&gt;
{&lt;BR /&gt;
 double mean = 0.0;&lt;BR /&gt;
 double sigma = 1.0;&lt;BR /&gt;
 &lt;BR /&gt;
 double a = 0.0;&lt;BR /&gt;
 double b = 1.0;&lt;BR /&gt;
&lt;BR /&gt;
 double e_1&lt;N&gt;;&lt;BR /&gt;
 double e_2&lt;N&gt;;&lt;BR /&gt;
&lt;BR /&gt;
 sim eps;&lt;BR /&gt;
&lt;BR /&gt;
 eps.gaussian_1 ( N, e_1, mean, sigma
); // generate e_1&lt;BR /&gt;
 eps.gaussian_2 ( N, e_2, mean, sigma
); // generate e_2&lt;BR /&gt;
&lt;BR /&gt;
 double x_1&lt;N&gt;;&lt;BR /&gt;
 double x_2&lt;N&gt;;&lt;BR /&gt;
 double x_3&lt;N&gt;;&lt;BR /&gt;
 &lt;BR /&gt;
 double * tem_x;&lt;BR /&gt;
 tem_x = new double[3*N];&lt;BR /&gt;
&lt;BR /&gt;
 eps.uniform ( 3*N, tem_x, a, b ); // generate x_1, x_2, x_3&lt;BR /&gt;
 &lt;BR /&gt;
 for ( int i = 0; i &amp;lt; N; i++)&lt;BR /&gt;
 {&lt;BR /&gt;
 x_1&lt;I&gt; = tem_x&lt;I&gt;;&lt;BR /&gt;
 x_2&lt;I&gt; = tem_x[N+i];&lt;BR /&gt;
 x_3&lt;I&gt; = tem_x[(2*N)+i];&lt;BR /&gt;
 }&lt;BR /&gt;
 delete[] tem_x;&lt;BR /&gt;
&lt;BR /&gt;
 double y_1&lt;N&gt;;&lt;BR /&gt;
 double y_2&lt;N&gt;;&lt;BR /&gt;
&lt;BR /&gt;
 for( int i = 0; i &amp;lt; N; i++ )&lt;BR /&gt;
 {&lt;BR /&gt;
 y_1&lt;I&gt; = x_1&lt;I&gt; + 0.9 * x_2&lt;I&gt; +
0.7 * x_3&lt;I&gt; + e_1&lt;I&gt;; // model 1&lt;BR /&gt;
 y_2&lt;I&gt; = x_1&lt;I&gt; + 0.9 * x_2&lt;I&gt; +
0.7 * x_3&lt;I&gt; + e_2&lt;I&gt;; // model 2&lt;BR /&gt;
 }&lt;BR /&gt;
&lt;BR /&gt;
 return 0;&lt;BR /&gt;
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/N&gt;&lt;/N&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/P&gt;Thanks for your time.&lt;BR /&gt;&lt;BR /&gt;Stanley KO&lt;/CTIME&gt;</description>
      <pubDate>Tue, 27 Jul 2010 15:18:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773346#M804</guid>
      <dc:creator>stanleyimko</dc:creator>
      <dc:date>2010-07-27T15:18:21Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773347#M805</link>
      <description>&lt;P&gt;Hi Stanley,&lt;/P&gt;&lt;P&gt;You initialize and remove the random stream immediately before and after the generation of random numbers. Output of the function time() is used to set the seed for initialization of the random stream. This could result in the same seed in the generation of both uniform and Guassian variates, the same uniform variates underneath Gaussian numbers and biased results.&lt;/P&gt;&lt;P&gt;May I suggest you to make initialization of the VSL random stream once, in the constructor of class sim? Deallocation of VSL RNG related resources can be done once in the destructor of the class. Thus, methods gaussian_1(), gaussian_2() and uniform() of the class sim would be just wrappers around MKL random number generators. Alternatively, you could use different seeds for generation of Gaussian and uniform numbers.This should help you to avoid potentially biased results in your simulations.&lt;BR /&gt;&lt;BR /&gt;Please, let me know if this answers your question.&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2010 07:01:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773347#M805</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2010-07-28T07:01:45Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773348#M806</link>
      <description>Dear Andrey,&lt;BR /&gt;&lt;BR /&gt;Thanks so much for your correction. I define a constructor and a destructor and everything looks fine. But I still don't understand why BOXMULLER will work but ICDF doesn't.&lt;BR /&gt;&lt;BR /&gt;Thanks so much.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Stanley KO</description>
      <pubDate>Wed, 28 Jul 2010 07:40:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773348#M806</guid>
      <dc:creator>stanleyimko</dc:creator>
      <dc:date>2010-07-28T07:40:45Z</dc:date>
    </item>
    <item>
      <title>Problem with geration method in random number generatior</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773349#M807</link>
      <description>&lt;P&gt;Hi Stanley,&lt;BR /&gt;&lt;BR /&gt;The output of the uniform generator is u= (u(i)), i=1,...,3*n. If the random stream is initialized with the same seed the same unifrom variates, n in case of ICDF and 2*n in case of Box-Muller would be used in Gaussian generator.&lt;/P&gt;&lt;P&gt;If ICDF method is used for generation of normal variates then the output of the Gaussian generator x=(x(i)), i=1,...,n, is just a one to one transformation of the same sequence u: x(i) = sqrt(2) erfinv( u(i) ) (section 9.3.4 of VSLNotes). In this case the simulations would result in biased results. &lt;/P&gt;&lt;P&gt;Box-Muller transformation is more complex and requires a pair of uniform variates to produce one Gaussian number:&lt;BR /&gt;x(i) = sqrt( -2 ln( u(2*i) ) ) sin (2 * pi * u(2*i+1) ) (section 9.3.2 of VSLNotes).&lt;/P&gt;&lt;P&gt;Let us consider your regression scheme in more details. To produce regression output you need 3 uniforms and 1 normal number that is, according to your testcase &lt;/P&gt;&lt;P&gt;y(0) needs (u(0), u(N+0), u(2N+0), x(0) ), x(0) uses ( u(0), u(1) )&lt;BR /&gt;y(1) needs (u(1), u(N+1), u(2N+1), x(1) ), x(1) uses ( u(2), u(3) )&lt;BR /&gt;y(2) needs (u(2), u(N+2), u(2N+2), x(2) ), x(2) uses ( u(4), u(5) )&lt;BR /&gt;y(3) needs (u(3), u(N+3), u(2N+3), x(3) ), x(3) uses ( u(6), u(7) )&lt;BR /&gt;etc &lt;/P&gt;&lt;P&gt;Thus, in case of Box-Muller transformation you would expect that the results are biased in "less degree", but the dependence between y(i)looks to be possible. So, it really makes sense to avoid the usage model of the test case that potentially can results in biased simulation outputs.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please, let me know if this helps.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Andrey&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2010 09:02:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-geration-method-in-random-number-generatior/m-p/773349#M807</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2010-07-28T09:02:51Z</dc:date>
    </item>
  </channel>
</rss>

