<?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 Generate Mixed Non-Normal Quasi-Random Vectors in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899166#M11137</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I need to be able to generate random numbers from a mixed non-normal set of vectors (e.g. 2 Normal, 1 Exponential, 2 Lognormal, etc.) from a Quasi-Random stream such as SOBOL. The documentation in vslnotes.pdf provides the code example (which I pasted in below) but this would bea 100x3 array of all Uniform. I need to be able to mix the vectors, so perhaps it is still 100 (rows) x 3 (columns)array but the first column is Normal, the second column is Uniform, and the third column is LogNormal. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I would appreciate any help with this anyone can provide. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;FONT size="1"&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;include &lt;STDIO.H&gt; &lt;/STDIO.H&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;include "mkl.h" &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;float r[100][3]; /* buffer for quasi-random numbers */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;VSLStreamStatePtr stream; &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;/* Initializing */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;vslNewStream( &amp;amp;stream, VSL_BRNG_SOBOL, 3 ); &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;/* Generating */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;vsRngUniform( VSL_METHOD_SUNIFORM_STD, &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;stream, 100*3, (float*)r, 2.0f, 3.0f ); &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;/* Deleting the streams */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;vslDeleteStream( &amp;amp;stream ); &lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
    <pubDate>Wed, 24 Oct 2007 21:36:24 GMT</pubDate>
    <dc:creator>digitalc6839</dc:creator>
    <dc:date>2007-10-24T21:36:24Z</dc:date>
    <item>
      <title>Generate Mixed Non-Normal Quasi-Random Vectors</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899166#M11137</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I need to be able to generate random numbers from a mixed non-normal set of vectors (e.g. 2 Normal, 1 Exponential, 2 Lognormal, etc.) from a Quasi-Random stream such as SOBOL. The documentation in vslnotes.pdf provides the code example (which I pasted in below) but this would bea 100x3 array of all Uniform. I need to be able to mix the vectors, so perhaps it is still 100 (rows) x 3 (columns)array but the first column is Normal, the second column is Uniform, and the third column is LogNormal. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I would appreciate any help with this anyone can provide. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;FONT size="1"&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;include &lt;STDIO.H&gt; &lt;/STDIO.H&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;include "mkl.h" &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;float r[100][3]; /* buffer for quasi-random numbers */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;VSLStreamStatePtr stream; &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;/* Initializing */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;vslNewStream( &amp;amp;stream, VSL_BRNG_SOBOL, 3 ); &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;/* Generating */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;vsRngUniform( VSL_METHOD_SUNIFORM_STD, &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;stream, 100*3, (float*)r, 2.0f, 3.0f ); &lt;/FONT&gt;&lt;/P&gt;
&lt;P align="left"&gt;&lt;FONT face="Courier New" size="2"&gt;/* Deleting the streams */ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;vslDeleteStream( &amp;amp;stream ); &lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
      <pubDate>Wed, 24 Oct 2007 21:36:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899166#M11137</guid>
      <dc:creator>digitalc6839</dc:creator>
      <dc:date>2007-10-24T21:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Mixed Non-Normal Quasi-Random Vectors</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899167#M11138</link>
      <description>&lt;P&gt;Generation of distribution mixture using SOBOL QRNG can be organizedby means ofLeapfrogStream routine for individual components of quasi-random vector. Example below demonstrates this.&lt;BR /&gt;&lt;BR /&gt;First component of the quasi-random vector is used to generate normally distrbuted random numbers.Second component of the quasi-random vector is for generation of uniform numbers. Finally, third component is for generation of lognormally distributed sequence. &lt;BR /&gt;Current implementation of VSL lognormal generator does not support Inverse Method for underlying Gaussian generator. So, direct call to RngLognormal function of the library is replaced with call to Gaussian generator which is followed by necessary transformations. MKL vector exponent function is used to transform normal numbers (low accuracy version of the function will speed up the application).&lt;/P&gt;
&lt;P&gt;#include &lt;STDIO.H&gt;&lt;/STDIO.H&gt;&lt;/P&gt;
&lt;P&gt;#include "mkl.h"&lt;/P&gt;
&lt;P&gt;#define SEED 3&lt;BR /&gt;#define N 100&lt;/P&gt;
&lt;P&gt;main()&lt;BR /&gt;{&lt;BR /&gt; VSLStreamStatePtr stream, stream1, stream2, stream3;&lt;BR /&gt; int old_mode;&lt;/P&gt;
&lt;P&gt; float r1&lt;N&gt;, r2&lt;N&gt;, r3&lt;N&gt;;&lt;BR /&gt; int i;&lt;BR /&gt; float a, b, m1, m2, sigma1, sigma2, b1, beta;&lt;BR /&gt;&lt;BR /&gt; /* Set low accuracy mode of calculations */&lt;BR /&gt; old_mode = vmlSetMode( VML_LA );&lt;BR /&gt; /* Initialize streams */&lt;BR /&gt; vslNewStream( &amp;amp;stream, VSL_BRNG_SOBOL, SEED );&lt;/N&gt;&lt;/N&gt;&lt;/N&gt;&lt;/P&gt;
&lt;P&gt; vslCopyStream( &amp;amp;stream1, stream );&lt;BR /&gt; vslCopyStream( &amp;amp;stream2, stream );&lt;BR /&gt; vslCopyStream( &amp;amp;stream3, stream );&lt;/P&gt;
&lt;P&gt; /* Leapfrog over individual components of quasi-random vector */&lt;BR /&gt; vslLeapfrogStream( stream1, 0, VSL_QRNG_LEAPFROG_COMPONENTS );&lt;BR /&gt; vslLeapfrogStream( stream2, 1, VSL_QRNG_LEAPFROG_COMPONENTS );&lt;BR /&gt; vslLeapfrogStream( stream3, 2, VSL_QRNG_LEAPFROG_COMPONENTS );&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; /* Call RNGs */&lt;BR /&gt; /* Uniform distribution parameters */&lt;BR /&gt; a = 0.0f; b = 1.0f;&lt;BR /&gt; /* Gaussian distribution parameters */&lt;BR /&gt; m1 = 10.0f; sigma1 = 3.0f;&lt;BR /&gt; /* Lognormal distribution parameters */&lt;BR /&gt; m2 = 0.0f; sigma2 = 1.0f; b1 = 3.0f; beta = 4.0f;&lt;/P&gt;
&lt;P&gt; /* Generate normal numbers */ &lt;BR /&gt; vsRngGaussian( VSL_METHOD_SGAUSSIAN_ICDF, stream1, N, r1, m1, sigma1 );&lt;BR /&gt; /* Generate uniform numbers */&lt;BR /&gt; vsRngUniform ( VSL_METHOD_SUNIFORM_STD, stream2, N, r2, a, b );&lt;BR /&gt; /* Generate lognormal numbers */&lt;BR /&gt; vsRngGaussian( VSL_METHOD_SGAUSSIAN_ICDF, stream3, N, r3, m2, sigma2 );&lt;BR /&gt; vsExp( N, r3, r3 );&lt;BR /&gt; for ( i = 0; i &amp;lt; N; i++ ) r3&lt;I&gt; = r3&lt;I&gt; * beta + b1;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt; /* Delete streams */&lt;BR /&gt; vslDeleteStream( &amp;amp;stream );&lt;BR /&gt; vslDeleteStream( &amp;amp;stream1 );&lt;BR /&gt; vslDeleteStream( &amp;amp;stream2 );&lt;BR /&gt; vslDeleteStream( &amp;amp;stream3 );&lt;/P&gt;
&lt;P&gt; /* Restoring old mode */&lt;BR /&gt; vmlSetMode( old_mode );&lt;/P&gt;
&lt;P&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;More details about MKL functions used in the ex
ample are available in MKL Manual and VslNotes.Please, let us know how this scheme works for you. &lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2007 08:45:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899167#M11138</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-25T08:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Mixed Non-Normal Quasi-Random Vectors</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899168#M11139</link>
      <description>&lt;P&gt;&lt;FONT face="Arial"&gt;Thanks for the excellent answer. I appreciate it. I have read the documentation on the LeapfrogStream to include the vslnotes.pdf. I am a little confused though... In my understanding of theory, any use of Quasi-Random streams should be paired with the inverse cdf method of variant generation. I tested this with the Normal by pairing Niederr with BOXMULLER2 by running 10,000 vectors of N=100 and while calculating the mean of each 100. The results is that the mean is significantly biased from the true value even over 10,000 runs. When I replace BOXMULLER2 with ICDF then the bias completely goes away and the mean and Standard Deviation of the N=100 samples is much closer to theoretical. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;So, my fundamental understanding would be that any Quasi-Random stream should always be paired with inverse CDF. When running any non-Quiasi-Random stream (such as MT2203) it is then faster to use something like BOXMULLER2 instead of inverse CDF. Is this correct?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;My confusion stems around your statement "Current implementation of VSL lognormal generator does not support Inverse Method for underlying Gaussian generator". The help system list four different methods for vdRngLognormal and they all appear to be inverse CDFs. They are listed as below. How can I tell from looking at the help system which of the non-uniform methods are available and which are not?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN class="keyword"&gt;VSL_METHOD_SLOGNORMAL_ICDF&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE class="code"&gt;&lt;SPAN class="keyword"&gt;VSL_METHOD_DLOGNORMAL_ICDF&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;CODE class="code"&gt;&lt;SPAN class="keyword"&gt;VSL_METHOD_SLOGNORMAL_ICDF_ACCURATE&lt;/SPAN&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;CODE class="code"&gt;&lt;SPAN class="keyword"&gt;VSL_METHOD_DLOGNORMAL_ICDF_ACCURATE&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;By the way, the on page 31 of vslnotes.pdf the word sentence "VSL implements the leapfrog method trough the function &lt;FONT face="Courier New,Courier New"&gt;vslLeapfrogStream&lt;/FONT&gt;:" has the word "trough" which should probably be "through". &lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2007 14:26:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899168#M11139</guid>
      <dc:creator>digitalc6839</dc:creator>
      <dc:date>2007-10-25T14:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Mixed Non-Normal Quasi-Random Vectors</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899169#M11140</link>
      <description>&lt;P&gt;Thanks for your answer.&lt;BR /&gt;We know that method name for Lognormal distribution generator is not accurately set; we work to fix it. Also, thank you for communicating the misprint in the documentation. &lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Inverse CDF method for Gaussian generator is faster than Box-Muller methodin 32 bit and EM64T versions of the library.&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2007 16:34:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899169#M11140</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-25T16:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Mixed Non-Normal Quasi-Random Vectors</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899170#M11141</link>
      <description>&lt;P&gt;&lt;FONT face="Arial"&gt;Thank you. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;I ran a quick test comparing ICDF and BOXMULLER2, and found BOXMULLER2 to be about twice as fast as ICDF. Of course, they are both blazingly fast but I would like to know if I am doing something wrong as in your post you indicate that ICDF is faster. I generated vectors of both of size 10,000 and iterated on this 10,000 times (for a total of 100 Million numbers of each). The results on my computer are ...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;ICDF = 4.25 seconds&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;BOXMULLER2 = 1.859 seconds&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;Of course BOXMULLER2 is faster than BOXMULLER (without the two aka single variant instead of pairs) but BOXMULLER still comes in at 3.328 seconds. The code I used is below. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Arial"&gt;Am I doing something wrong?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;double r1&lt;N&gt;,r2&lt;N&gt;;&lt;BR /&gt; &lt;BR /&gt; VSLStreamStatePtr stream,stream1,stream2;&lt;BR /&gt;int errcode,i;&lt;BR /&gt; DWORD startTime,endTime,deltaTime;&lt;/N&gt;&lt;/N&gt;&lt;/PRE&gt;&lt;PRE&gt; &lt;BR /&gt; //setup the stream&lt;BR /&gt; // VSL_BRNG_NIEDERR SL_BRNG_SOBOL // VSL_BRNG_MT19937 // VSL_BRNG_NIEDERR &lt;BR /&gt;errcode = vslNewStream( &amp;amp;stream, VSL_BRNG_NIEDERR, 2 );&lt;BR /&gt; CheckVslError( errcode );&lt;/PRE&gt;&lt;PRE&gt;&lt;/PRE&gt;&lt;PRE&gt;//two streas from Quasi-Random&lt;BR /&gt;//number of streams must match the last argument in vslNewStream&lt;BR /&gt;vslCopyStream( &amp;amp;stream1, stream );&lt;BR /&gt; vslCopyStream( &amp;amp;stream2, stream );&lt;/PRE&gt;&lt;PRE&gt;/* Leapfrog over individual components of quasi-random vector */&lt;BR /&gt; vslLeapfrogStream( stream1, 0, VSL_QRNG_LEAPFROG_COMPONENTS );&lt;BR /&gt; vslLeapfrogStream( stream2, 1, VSL_QRNG_LEAPFROG_COMPONENTS );&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;//Timing for ICDF Loop through 10,000 iterations of vectors of size N&lt;BR /&gt;startTime = GetTickCount();&lt;BR /&gt;for (i=0;i&amp;lt;10000;i++)&lt;BR /&gt;{&lt;/PRE&gt;&lt;PRE&gt;//Normal (Gaussian) Double Precision &lt;BR /&gt;errcode = vdRngGaussian(VSL_METHOD_DGAUSSIAN_ICDF,stream1, N, r1, 10.0f, 1.0f );&lt;BR /&gt;CheckVslError( errcode );&lt;/PRE&gt;&lt;PRE&gt;}&lt;BR /&gt;endTime = GetTickCount();&lt;BR /&gt;deltaTime = endTime - startTime;&lt;BR /&gt; printf ("Completetion Time ICDF:%ld
",deltaTime);&lt;/PRE&gt;&lt;PRE&gt; //Timing for BoxMuller2 Loop through 10,000 iterations of vectors of size N&lt;BR /&gt;startTime = GetTickCount();&lt;BR /&gt;for (i=0;i&amp;lt;10000;i++)&lt;BR /&gt;{&lt;/PRE&gt;&lt;PRE&gt;//Normal (Gaussian) Double Precision &lt;BR /&gt;errcode = vdRngGaussian(VSL_METHOD_DGAUSSIAN_BOXMULLER2,stream2, N, r2, 10.0f, 1.0f );&lt;BR /&gt;CheckVslError( errcode );&lt;/PRE&gt;&lt;PRE&gt;}&lt;BR /&gt;endTime = GetTickCount();&lt;BR /&gt;deltaTime = endTime - startTime;&lt;BR /&gt; printf ("Completetion Time BoxMuller2:%ld
",deltaTime);&lt;/PRE&gt;&lt;PRE&gt; vslDeleteStream( &amp;amp;stream );&lt;BR /&gt; vslDeleteStream( &amp;amp;stream1 );&lt;BR /&gt; vslDeleteStream( &amp;amp;stream2 );&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Oct 2007 20:34:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899170#M11141</guid>
      <dc:creator>digitalc6839</dc:creator>
      <dc:date>2007-10-25T20:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Generate Mixed Non-Normal Quasi-Random Vectors</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899171#M11142</link>
      <description>&lt;P&gt;What version of the library do you use? Speed-up of ICDF method vs. Box-Muller method is expected in MKL 10. Thanks, Andrey&lt;/P&gt;</description>
      <pubDate>Fri, 26 Oct 2007 07:00:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Generate-Mixed-Non-Normal-Quasi-Random-Vectors/m-p/899171#M11142</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2007-10-26T07:00:11Z</dc:date>
    </item>
  </channel>
</rss>

