Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6072099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:07:21+00:00 2026-05-23T10:07:21+00:00

i use in my program boost uniform distribution between 0 and 1: #include <boost/random/uniform_01.hpp>

  • 0

i use in my program boost uniform distribution between 0 and 1:

 #include <boost/random/uniform_01.hpp>
 #include <boost/random.hpp>

 static boost::mt19937 rng;
 static boost::uniform_01<boost::mt19937&> zeroone(rng);

zeroone() function is called inside a for-loop which i would like to parallel, using OpenMP.

 for ( int index = 0 ; index < 4096 ; index++ ) {
     if ( node[ index ] == false ) {
        if ( zeroone() < 0.03 )
           node[ index ] = true;
      }
 }

The question if it is possible using OpenMP to parallel the for-loop and not damaging the uniform distribution pseudorandom number generator?

e.g. Is it possible to define for the first core a seed, for the second core the corresponding seed that the first core pseudorandom number generator will reach after 6 times?

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:07:22+00:00Added an answer on May 23, 2026 at 10:07 am

    You can do what you suggest, but

    1. it would be insane…ly inefficient (because the purpose of a RNG is to generate hard-to-predict pseudo random sequences, the only way to …. predict the nth successor would be to generate the intervening ones as well.)
    2. most likely unnecessary:

    You can give each thread it’s own private RNG (seed each one independently). The uniform distribution property will still hold unless your dataset is really small (in which case, the uniformness would be swamped by the sample noise anyway, regardless of threads)

    My scheme would look something like this:

    typedef boost::.... rng_t;
    static rng_t g_rng; // notice how you never seed this, is this on purpose?
    
    #per thread
    {
         rng_t rng(g_rng()); // need synchronized access to g_rng here
         boost::uniform_01<boost::mt19937&> zeroone(rng);
    
         // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to use boost::thread in my program, but get the following compiler error
So I am wanting to use boost signals in my C++ program. I add:
I have a program where I use boost::threads for multi threading. Unfortunately drd (
I'm trying to use the boost threads, but when running the program i get
i'm trying to use boost regex within my program the problem is i get
I use boost.program_options library. Consider this simplified case. po::options_description desc(Usage); desc.add_options() (uninstall,u, uninstall program)
I've written a simple program in C++ with use of boost::variant. Program's code is
My program use UdpClient to try to receive 27 responses from 27 hosts. The
The problem: We use a program written by our biggest customer to receive orders,
First a bit about the environment: We use a program called Clearview to manage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.