# Thread: keeping stats - probability

1. ## keeping stats - probability

How would I determine the probability of a given number occuring in the follow code? Just how bad is the infamous rand()?
Code:
```#include<iostream>
#include<ctime>

int main()
{
srand(time(0));
int testCases = 100;
for(int i = 1; i <= testCases; i++)
{
int x = rand()%20+1;
std::cout<<x<<'\t';}
std::cin.get();
return 0;
}```
I need another test loop and 20 variables to increment(?). I'm a little over my head on this.

Thanks -

JM

2. int count[20];
...
count[x]++; // count how many times each x occurred...

3. >> Just how bad is the infamous rand()?
gg

4. Well, you can always run the DieHard tests.

Keep in mind, you don't necessarily need a cryptographically secure PRNG for many applications of random numbers.

Cheers

5. cryptographically secure PRNG
I don't know what this means - you keep your pants on while solving crossword puzzles??

6. PRNG : Pseudo-random number generator (e.g. rand)
A lot of cryptographic protocols rely on the generation of very good random numbers to keep your data secure. Because of their application, the numbers must be really "good" random numbers (cryptographically secure).

7. PRNG : Pseudo-random number generator (e.g. rand)
Cool, got it, thanks; pardon my smart-assedness!
I've done a little testing using Salem's suggestion (thanks Salem).
Rand() is good enough for the simple stuff I'm doing but thank you for all the info, I've learned a lot!

- JM