Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- How do I use MKL to sample from discrete probability distribution

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

junuylia

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-12-2010
08:38 PM

96 Views

How do I use MKL to sample from discrete probability distribution

I want to sample from a distribution with

x=1, 2, 3

p(x)=1/2, 1/3, 1/6

how do I do it with mkl library?

Thank you very much.

Jun

Link Copied

4 Replies

Andrey_N_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-12-2010
11:06 PM

96 Views

You may want to follow the algorithm described below.

1. Split the interval I=[0,1) into three sub-intervals:

I1 = [0, 1/2)

I2 = [1/2, 5/6), 5/6=1/2+1/3

I3 = [5/6,1)

2. Generate uniformly distributed on the interval I random numbers u(1),...,u(n) using VSL RNG routine

v[d|s]RngUniform.

3. For each number u(i) find the interval Ij which contains u(i) and set y(i) to j

4. Output of the algorithm is sequence y(1),...,y(n)

Please, let me know if this answers your question.

Best,

Andrey

junuylia

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-13-2010
09:17 AM

96 Views

I guess it will work. I'll make some follow up notes after I try this algorithm. Thanks!

Jun

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-15-2010
03:19 AM

96 Views

For discrete random distributions, replace integrals by sums in the definition of

To supplement the mathematical argument that I stated, you can easily run a Monte-Carlo simulation, generating a few million random numbers with your distribution. Count the numbers of times that 1, 2 and 3 occur in the sequence, and divide by the number of random numbers generated. The resulting fractions should be close to 1/2, 1/3 and 1/6.

junuylia

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-21-2011
02:20 PM

96 Views

This method is new for me, and I'll try it later. Thanks a lot!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.