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 6592967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:37:20+00:00 2026-05-25T17:37:20+00:00

I use some random numbers as initial values for my ‘metaheuristics optimization’ calculations. I

  • 0

I use some random numbers as initial values for my ‘metaheuristics optimization’ calculations. I run my same optimization program on different computers using MPI. I surprisingly obtained a lot of same results. For example I use 40 host computers, the results have few different values. Almost 6-7 values are the same. Actually, my results can be similar but they must not be same because I give random numbers as initials to them in the beginning of program (In my above example I must get 40 different values). If I run the program repeatedly and sequentially on a same computer, it produces different results as it should be.

I suspect that this situation is caused by insufficient quality of random number generation. How can I solve this problem. I open other ideas, may be different things cause this problem.

P. S. I use srand( (unsigned) time(NULL) ) once in the beginning of my program for generating random-like numbers. Then, I generate my random numbers in the range of [0, 1] by using (float)rand()/32767

One example of my results which I complained:

15.42161751
19.83328438
3.43446541
23.50453377
23.50453377
3.43446541
19.83328438
23.50453377
3.43446541
7.52127457
7.52127457
23.50453377
7.52127457
7.52127457
23.50453377
19.83328438
19.83328438
19.83328438
7.52127457
15.42161751
3.43446541
19.83328438
19.83328438
15.42161751
23.50453377
23.50453377
5.29145241
19.83328438
19.83328438
19.83328438
19.83328438
7.52127457
23.50453377
3.43446541
19.83328438
23.50453377
7.52127457
3.43446541
7.52127457
5.29145241
  • 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-25T17:37:21+00:00Added an answer on May 25, 2026 at 5:37 pm

    That’s because some of your host computers are having the same time, so the srand() takes the same time and therefore the random sequence have same starting point, so of course your are getting the same random numbers. Try to to this:

    srand(time(0)*my_computer_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I use random numbers in Linux and C++? I have found some
What I am trying to do is to generate some random numbers (not necessarily
I'm trying to generate some 8-bit random numbers with C++ and don't want to
Random numbers have been well covered here, so I'll keep it brief. I use
I want to generate unique and random numbers or IDs which I can use
I would like to generate some random numbers log-normally distributed with a specified geometric
I wrote some Java code to generate pseudo-random numbers but I'm running into what
I use some HTTP Handlers from my Web Forms days forms, to for example
I use some CSS styling to hide input buttton, images and so on but
i use some code for inline cell editing from Apples TaggedLocations Example and im

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.