Mersenne Twister random generator - two VS2010 running in parrallel [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is it farfetched to assume that when two instances of VS2010 are running in parallel, seeds for random generator (Mersenne Twister) are taken from the same sequence ?
This would mean that seed for random generator is different whether I run the two programs one after another, or in parallel in two instances of VS.

The various random number generators don't seed themselves, you have to provide a seed.
If you don't, you most likely get 0. The implementation of Mersenne Twister et al does not
share data between instances, so multiple concurrent processes will operate independently.

Related

Is there any optimal way to implement N byte integer and it's arithmetic operations in c++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 months ago.
Improve this question
I'm trying to think of some interesting, reusable way to implement big integers using passed amount of bytes or resizing themselves when needed. I have no idea how to make it optimal in any way tho. Are there any tricks I could use, or do I have to simply work on those numbers bit by bit while adding/multiplying/dividing?
edit: if it is important, I need it to safe text as number in base 10 so I can play with some ideas for encrypting it
Use The GNU Multiple Precision Arithmetic Library. If you try to reinvent the wheel you will end up with a square.

How std::random_device generate non-deterministic random numbers? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Why std::random_device generate non-deterministic random numbers? What is the seed in this generator? It's not a time, so what?
It is not specified. Implementation is supposed to provide suitable ways of doing this, and usually they would recourse to OS-provided tools.
For example, on Linux there are /dev/[u]random devices which will provide entropy from a system state.

how can i get periodicity of random function in c++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I want to calculate pattern at which stage random numbers repeat
string a="abcd";
for(int i=0;i<10000;i++)
{
a=swap(a[i%4],a[rand()]%4)
cout<<a<<"\n";
}
I want to calculate the stage at which, string pattern will same
Most random number generators' sequences do not repeat on successive calls to rand, and can pass tests for randomness.
The actual algorithm used in your C++ implementation can vary, and can be one of the algorithms listed here:
https://en.cppreference.com/w/cpp/numeric/random
Each has its own theory and implementation.
For example, the generation of one of the most common ones the Linear Congruential , is explained here:
https://en.wikipedia.org/wiki/Linear_congruential_generator
It is important to note that most C++ random number generators will generate the same sequence of numbers on different runs of the application, when seeded with the same seed.

Multiplicaton of big integers (factorial) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I accidentally saw on Internet that functional programming language SML allows to do arbitrary precision integer arithmetic. I had written big integer arithmetic on C++ before and I decided(for curiosity) to compare my implementation with SML's by computing factorial of big numbers. I found out that SML program works about 15 times faster than mine. My implementation uses elementary school multiplication algorithm. But as I know the fast algorithms (such as FFT or Karatsuba's algorithm) worked better than elementary school multiplication when multipliers aren't much different. In this case they are, because (n-1)! is much greater than n. My question is what are the other possible reasons that the SML program works so faster.
Three possible reasons:
It uses multiple CPU cores (easy to test)
It uses SIMD instructions
It uses GPU (rare, but not unheard of)

Duplicate output when using srand for random seed [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm using srand (time(NULL)); to generate a random seed.
Problem is, I'm submitting 30+ identical jobs to a LINUX cluster. If I submit them one at a time, everything is fine, but of course I prefer to use a batch job to submit all 30 at once. Much easier and quicker. Problem is, then several batches of the jobs all appear to access exactly the same time, and I get duplicate results! Can anyone suggest an easy solution to this?
Consider reading from /dev/random or /dev/urandom. They have higher quality randomness than rand() (which is usually just a simple linear congruential generator), and /dev/random blocks until sufficient entropy has built up.
Look into the new features in <random> in C++11. In particular std::random_device. Otherwise, a cheesy solution is to add pid to time(NULL).