Hello.(adsbygoogle = window.adsbygoogle || []).push({});

I recall that the probability of generating a particular real number (in a bounded or unbounded interval) is exactly zero.

If I keep generating reals for a limited amount of time, can I get a number more than once?

About the computer, I know that the amount of different values the type double (for instance) can store is not infinite. This should mean I could get duplicates, but very unlikely, right?.

I'm working on an assignment where there are a bunch of random (in an interval) doubles inside a matrix and I have to pick the position of the least one. The assignment says: "if there are more, choose randomly among them".

If the answer to my first question is "no", then theoretically I will never be in that situation. But because of the machine limitations actually I could (especially if the matrix is read from a file which contains the numbers with a small number of digits).

I'm using C and in my particular assignment I find difficult to use rand(), because I'm writing this code inside a function, where I can't call srand(time(0)) [because the function will be executed in a loop (the matrix is modified each time in a way that I can't consider that position any more)]. srand is not called in the main() and I don't write the main().

I decided to assume that the numbers are indeed all different. Even if there were some equal and are the smallest I will pick the first when iterating the matrix, and I can say something like this: I should take one of them randomly, but because they were created and put randomly inside the matrix it seems like the same to take the first.

Another explaination is this: because the program simulates a physical phenomenon (that I know nothing about, it's called invasion percolation), IF the phenomenon is deterministic, considering the same matrix, the evolution of the system should always be the same and so the evolution of the matrix calling my function in the loop.

Sorry for writing so much and the terrible english. I'd like to have some discussion about this problem.

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Random generated doubles: can I get a number more than once?

Tags:

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads for Random generated doubles |
---|

How to distinguish the decimal expansions of irrational numbers from random numbers? |

Pseudo Random Encryption? |

Web Scraping Py Script Generates Error for Old Norse Chars |

C/++/# How to check if a list of numbers is random? |

Java Minesweeper JFrame Flicker |

**Physics Forums | Science Articles, Homework Help, Discussion**