<?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 Re: Usage of vsrnggaussian() - very easy question in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854896#M6897</link>
    <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;I found all the answers (I think) and will try to implement them in my code as soon as I can. Thanks a lot everyone! Once I get it working (or not) I will let you know :)&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;~Johan&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 04 Nov 2008 11:09:32 GMT</pubDate>
    <dc:creator>johansoderstrom</dc:creator>
    <dc:date>2008-11-04T11:09:32Z</dc:date>
    <item>
      <title>Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854890#M6891</link>
      <description>&lt;P&gt;Dear FORTRAN experts&lt;/P&gt;
&lt;P&gt;I am stuck at a very beginner problem with FORTRAN and I hope that you can help me. I want to get a zero-mean, unit-varience (sigma=1) Gaussian-distributed number. I found the function vsrnggaussian() which should do the trick, but I have no idea of how to implement it in my FORTAN code. I found an example (&lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=48992"&gt;http://software.intel.com/en-us/forums/showthread.php?t=48992&lt;/A&gt;) but that seems to be not for FORTRAN.&lt;/P&gt;
&lt;P&gt;So, in essance, how do I go about to get such a random (non-integer) number?&lt;/P&gt;
&lt;P&gt;As you probably see I am very new to FORTRAN so I have no idea of how to initialize streams, and how to de-initialize them... If someone whould be kind enough to provide me with a short example I would be &lt;SPAN style="font-weight: bold;"&gt;very&lt;/SPAN&gt; happy and grateful&lt;/P&gt;
&lt;P&gt;Thank you so much,&lt;/P&gt;
&lt;P&gt;Johan S&lt;/P&gt;</description>
      <pubDate>Mon, 03 Nov 2008 10:28:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854890#M6891</guid>
      <dc:creator>johansoderstrom</dc:creator>
      <dc:date>2008-11-03T10:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854891#M6892</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/406869"&gt;johansoderstrom&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Dear FORTRAN experts&lt;/P&gt;
&lt;P&gt;I am stuck at a very beginner problem with FORTRAN and I hope that you can help me. I want to get a zero-mean, unit-varience (sigma=1) Gaussian-distributed number. I found the function vsrnggaussian() which should do the trick, but I have no idea of how to implement it in my FORTAN code. I found an example (&lt;A href="http://software.intel.com/en-us/forums/showthread.php?t=48992"&gt;http://software.intel.com/en-us/forums/showthread.php?t=48992&lt;/A&gt;) but that seems to be not for FORTRAN.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;The Fortran interface to VSL is described in the mklman.pdf in the MKL documentation. As this is part of the MKL library, you would be more likely to get expert answers on the MKL forum.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Nov 2008 13:21:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854891#M6892</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2008-11-03T13:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854892#M6893</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;I'll move this to the MKL forum (now that I can!)&lt;/P&gt;</description>
      <pubDate>Mon, 03 Nov 2008 14:20:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854892#M6893</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-11-03T14:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854893#M6894</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/336209"&gt;Steve Lionel (Intel)&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;I'll move this to the MKL forum (now that I can!)&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Here is a simple program to generate real numbers having a Guassian distribution with standard deviation SIGMA. It uses standard routines to generate a pseudorandom sequence of numbers uniform in the range 0 to 1.&lt;/P&gt;
&lt;P&gt;!****************************************************************************&lt;BR /&gt;!&lt;BR /&gt;! PROGRAM: gaussianrand&lt;BR /&gt;!&lt;BR /&gt;! PURPOSE: generate gaussian random numbers with given sigma&lt;BR /&gt;! Uses FUNCTION RAND(0) to generate uniform random numbers&lt;BR /&gt;! between 0 and 1, and ROUTINE SEED to set the seed&lt;BR /&gt;! Uses the Box-Muller algorithm to generate numbers with&lt;BR /&gt;! a Gaussian distribution of probability. &lt;BR /&gt;!&lt;BR /&gt;!****************************************************************************&lt;BR /&gt;program gaussianrandimplicit none&lt;BR /&gt;&lt;BR /&gt;integer,parameter:: nrand=1000000&lt;BR /&gt;REAL*8 UNIF1(nrand), UNIF2(nrand)&lt;BR /&gt;!&lt;BR /&gt;REAL*8 Y1,Y2,SIGMA,binsize, binhalf&lt;BR /&gt;INTEGER I,nbins, bins(201),ix&lt;/P&gt;
&lt;P&gt;! supply seed to get the same pseudorandom sequence each time&lt;BR /&gt;! program is run. To get a different sequence, change the seed&lt;BR /&gt;! by calling SEED with a different integer value.&lt;BR /&gt;call seed(1)&lt;BR /&gt;! set the sigma value you want&lt;BR /&gt;SIGMA=2&lt;BR /&gt;!&lt;BR /&gt;! get the random numbers. RGAUSS returns two gaussian random numbers&lt;BR /&gt;! for each call. &lt;BR /&gt;!&lt;BR /&gt;DO I=1,NRAND&lt;BR /&gt;CALL RGAUSS(SIGMA,Y1,Y2)&lt;BR /&gt;UNIF1(I)=Y1&lt;BR /&gt;UNIF2(I)=Y2&lt;BR /&gt;END DO&lt;BR /&gt;!&lt;BR /&gt;! there are NRAND values in each array UNIF1 and UNIF2, each with&lt;BR /&gt;! a Gaussian distribution with standard deviation SIGMA&lt;BR /&gt;!&lt;BR /&gt;! bin the results, bin size=0.05*sigma&lt;BR /&gt;nbins=201&lt;BR /&gt;binsize=0.05*sigma&lt;BR /&gt;binhalf=0.5*binsize&lt;/P&gt;
&lt;P&gt;do i=1,nrand&lt;BR /&gt;! compute which bin the number goes into&lt;BR /&gt;ix=101+floor((unif1(i)+binhalf)/binsize)&lt;BR /&gt;if(ix.gt.0.and.ix.lt.201) bins(ix)=bins(ix)+1&lt;BR /&gt;end do&lt;/P&gt;
&lt;P&gt;! save the numbers in each bin to display later&lt;BR /&gt;open(unit=10,file='rgauss.dat',form='formatted',status='unknown')&lt;BR /&gt;write(10,1000) (bins(i),i=1,201)&lt;BR /&gt;1000 format(10i8)&lt;BR /&gt;close(10)&lt;/P&gt;
&lt;P&gt;end program gaussianrand&lt;/P&gt;
&lt;P&gt;subroutine rgauss(sigma, y1,y2)&lt;BR /&gt;real*8 x1, x2, w, y1, y2, sigma&lt;BR /&gt;&lt;BR /&gt;do while ( (w .ge. 1.0).or.(w.eq.0) )&lt;BR /&gt;x1 = 2.0 * rand(0) - 1.0&lt;BR /&gt;x2 = 2.0 * rand(0) - 1.0&lt;BR /&gt;w = x1 * x1 + x2 * x2&lt;BR /&gt;end do&lt;/P&gt;
&lt;P&gt;w = sigma*sqrt( (-2.0 * log( w ) ) / w )&lt;BR /&gt;y1 = x1 * w&lt;BR /&gt;y2 = x2 * w&lt;/P&gt;
&lt;P&gt;end subroutine rgauss&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Nov 2008 17:47:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854893#M6894</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2008-11-03T17:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854894#M6895</link>
      <description>&lt;DIV style="margin:0px;"&gt;I wanted to edit my post to correct pasting error - but I cannot find an edit button&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Anyway, please note the error in&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;gaussianrandimplicit none&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;which should of course read&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Program gaussianrand&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;&lt;BR /&gt;implicit none&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Nov 2008 17:52:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854894#M6895</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2008-11-03T17:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854895#M6896</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;P&gt;Johan - following is a snipped of code from a test program I used to check different random methods. I have cut down to code to make it as simple as possible. Hope I have not introduced any errors. Yes - the descriptions in the documentation are confusing, but actual application is very simple. (Steve - not certain if this is the right forum, but have posted here in to increase chance of Johan finding it)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;USE mkl_vsl&lt;BR /&gt;IMPLICIT NONE&lt;BR /&gt;&lt;BR /&gt;integer status !Error / status &lt;BR /&gt;integer brng !Index of generator to initialize stream &lt;BR /&gt;integer method !Method = 0 in case of uniform distribution &lt;BR /&gt;integer dimen !Initial condition of the stream &lt;BR /&gt;TYPE (VSL_STREAM_STATE) stream !Random stream&lt;BR /&gt;integer, PARAMETER :: nr = 1000 !Number of values required (whatever you want)&lt;BR /&gt;real gauss(nr)&lt;BR /&gt;real mean, sigma&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;mean = 0.0&lt;BR /&gt;sigma = 1.0&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;!&lt;STRONG&gt;SOBEL&lt;/STRONG&gt;&lt;BR /&gt;method = VSL_METHOD_SGAUSSIAN_ICDF !NB - are different alternatives, but I found this worked well&lt;BR /&gt;&lt;STRONG&gt;brng = VSL_BRNG_SOBOL &lt;BR /&gt;&lt;/STRONG&gt;dimen = 1           ! &lt;STRONG&gt;&amp;lt;== different values may be needed depending on application&lt;/STRONG&gt;&lt;BR /&gt;gauss = 0.0&lt;BR /&gt;status = vslnewstream( stream, brng, dimen ) !Create new stream (SOBOL in this case&lt;BR /&gt;status = vsrnggaussian( method, stream, nr, gauss, mean, sigma ) &lt;BR /&gt;status = vsldeletestream( stream ) !Delete the stream&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;!For alternate random types, substitute&lt;BR /&gt;&lt;STRONG&gt;! brng = VSL_BRNG_MT19937&lt;BR /&gt;! brng = VSL_BRNG_MRG32K3A&lt;BR /&gt;&lt;/STRONG&gt;!NB: I found VSL_BRNG_MT19937 overall best for my application&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;OT: "&lt;EM&gt;Insert Code using SyntaxHighlighter&lt;/EM&gt;" facility has no option for Fortran !!! (in a Fortran forum)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Nov 2008 19:58:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854895#M6896</guid>
      <dc:creator>davidspurr</dc:creator>
      <dc:date>2008-11-03T19:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854896#M6897</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;I found all the answers (I think) and will try to implement them in my code as soon as I can. Thanks a lot everyone! Once I get it working (or not) I will let you know :)&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;~Johan&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Nov 2008 11:09:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854896#M6897</guid>
      <dc:creator>johansoderstrom</dc:creator>
      <dc:date>2008-11-04T11:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Usage of vsrnggaussian() - very easy question</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854897#M6898</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/406869"&gt;johansoderstrom&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;I found all the answers (I think) and will try to implement them in my code as soon as I can. Thanks a lot everyone! Once I get it working (or not) I will let you know :)&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;~Johan&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;SPAN style="font-size: x-small;"&gt;Please, have a look at Fortran VSLexamples available in examplesvslfsource folder of MKL installation directory. In particular, vdrnggaussian.f and vsrnggaussian.f files show how to use Gaussian generator.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2008 12:43:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Usage-of-vsrnggaussian-very-easy-question/m-p/854897#M6898</guid>
      <dc:creator>Andrey_N_Intel</dc:creator>
      <dc:date>2008-11-05T12:43:07Z</dc:date>
    </item>
  </channel>
</rss>

