How do you guys limit rand() results to a range?

G

glen herrmannsfeldt

(snip, I wrote)

Thinking about it again, the coupling between the two, classically,
is the probability of the particle emitted from one hitting the other.
That makes the argement for it being squared more obvious.
You can predict something based upon that overlap, but what you can
predict is only a shift in the probability distribution. The actual
decay time is still a perfectly random selection from that distribution.
You cannot predict the actual time until the next decay. No matter how
much information you have, the time until the next decay could be either
arbitrarily long or arbitrarily short, without violating any of the laws
of quantum physics as they are currently understood. That is the
fundamental distinction between quantum randomness and
pseudo-randomness. If you knew the full internal state of a
pseudo-random number generator, and the algorithm it uses, you could
determine the next random number precisely.

Yes. About the only point I was trying to make is that in quantum
mechanics things are rarely infinite and rarely zero, but instead
really huge and really tiny.

(snip)
It's not just a matter of some of the universe's state information being
hidden from us. Einstein, Podalsky and Rosen (EPR) tried to interpret
quantum uncertainty as being due to "hidden variables" - state
information about the universe that we were unaware of (and which we
might inherently be incapable of being aware of). They deliberately left
the details of what that state information was and how it influences the
measurements completely unspecified. Despite leaving it unspecified,
they were able to describe a quantum-mechanical experiment, and a
statistic that could be calculated from measurements that could be taken
while running that experiment. They rigorously derived a requirement
that this statistic must be greater than or equal to 1, regardless of
how the hidden variables actually worked. Quantum mechanics, on the
other hand, predicted that the value of that statistic should be 0.5.
From this, EPR concluded that quantum mechanics was unrealistic, and
could therefore be, at best, only an approximation to reality.

OK, but it is a slightly different problem. To make EPR tests work,
you have to be careful that you don't disturb the quantum state.

For quantum randomness, you want the systems to be uncoupled, but
will find that there is (a very small amount) of coupling.
At the time their paper was published, it was not possible to conduct
the experiment with sufficient precision to clearly distinguish a value
of 1 from a value of 0.5. Many years later, when scientist were finally
able to perform it, reality decided not to cooperate with EPR's concept
of "realism". The measured value unambiguously confirmed the quantum
mechanical prediction, violating the constraint that EPR had derived
from assuming that hidden variables were involved.
Scientists still believe that quantum mechanics can only be an
approximation to reality - but it's no longer because of the
fundamental role that true randomness plays in the theory.

More specifically, and the experiment that took longer to do than
some other ones, two particles can be created coupled, separated
in distance, and then have their state measured. Even when the
time between the two measurements is less than the distance
bewteen them divided by c, (so that no signal could propagate)
they are still found to keep their state.
I don't want to start an extended discussion of EPR - even experts get
into long pointless arguments talking about it. I just want to say that,
when I talk about "really random", I'm talking about the kind of thing
that EPR were implicitly assuming was inherently impossible when they
derived their limit equation.

Yes. The point that I was trying to make, with a very simplified
example, is that quantum systems, like PRNGs, have a finite number
of states. It might be a really huge number, though.

And then you have to extract some of that state information and
generate bits from it.

-- glen

S

Stefan Ram

James Kuyper said:
Einstein, Podalsky and Rosen (EPR) tried to interpret
quantum uncertainty as being due to "hidden variables"

Nowhere in EPR 1935 have they »tried to interpret quantum
uncertainty as being due to "hidden variables"«.

J

James Kuyper

The point is: The English noun phrase »real random number«
has a meaning in the realm of a technical discourse only
after the point of its definition.

The first message in this thread in which I used any variation on the
term "really-random" was the one with the header "Date: Tue, 03 Jun 2014
22:21:21 -0400". It was in response to your message more than an hour
earlier, with the header "Date: 4 Jun 2014 01:19:02 GMT". Whatever your
point was in your earlier message (which I remain unclear about) it
could not have been about my use of the term "really-random". Up to that
point, I had never bothered distinguishing pseudo-random and
really-random processes, the distinction being irrelevant to the issues
under discussion.

S

Stefan Ram

glen herrmannsfeldt said:
Yes. The point that I was trying to make, with a very simplified
example, is that quantum systems, like PRNGs, have a finite number
of states. It might be a really huge number, though.

Obviously not all quantum systems have a finite number of
states, often the space of their states (as rays in Hilbert
space) even has an infinite number of dimensions!

J

James Kuyper

On 06/04/2014 05:59 PM, Stefan Ram wrote:
....
I have only reacted to the wording »really-random numbers«,

Which was in response to your comment about "When one is using »real«
random numbers,".
wherein »really-random« is an attribute of the numbers, not of
their source, otherwise the wording would be »numbers from
a really-random source«.

Your comment applied the attribute "real random" to "numbers", just like
my later comment applied the attribute "really-random" to "numbers" -
neither comment clarifies that it's actually the source that's random,
and not the numbers themselves. I'll readily concede that, ideally, the
clarification should be made. However, what is the distinction that
makes your comment acceptable, and mine not?

J

James Kuyper

For any value of N. If knowing the first 1e100 numbers tells
you *anything* about the 1e100+1th, then the sequence is not
"really-random". If the numbers are bits, knowing that the next bit
is 1 with a probability of 50.001% means it's not "really-random".

Do you think otherwise?

Assume that, knowing the first N numbers, the exact algorithm, and
complete internal state, you could determine upper and lower limits on
the next number - but that it was impossible to determine which number
within that range would be generated - would you consider that a
deterministic system? I sure wouldn't.

I think you're talking about the probabilities being exactly even, not
about the selection from among those probabilities being random. Those
are two entirely distinct issues, as far as I'm concerned.

S

Stefan Ram

James Kuyper said:
Your comment applied the attribute "real random" to "numbers", just like
my later comment applied the attribute "really-random" to "numbers" -
neither comment clarifies that it's actually the source that's random,
and not the numbers themselves. I'll readily concede that, ideally, the
clarification should be made. However, what is the distinction that
makes your comment acceptable, and mine not?

What I wrote in

<[email protected]>

was:

|One cannot just assume that there are »real« random numbers,
|because the statistical properties of random numbers obtain
|from real quantum random number generators are different than
|the statistical properties of random numbers obtain from real
|classical random number generators, even if both are not
|pseudo-random number generators.

. So I was using the noun phrase in the negative: I wrote

»One can/not/ just assume that there are ...«.

Also, to further dissociate myself from that attribute »real«
and mark it as a kind of quotation of a wording some people
might use, I wrapped it in quotation marks.

~~

My point was that we had dices and coins even before the
20th century. There are classical sources of randomness such
as the bean machine (Galton box) or the roulette wheel, that
one really cannot predict and which deliver a certain
distribution of frequencies.

Dices and coins usually are random enough to be deemed
sources of randomness. I will call them »classical sources«
here.

However, today we also have quantum sources of randomness,
and we know that they have different properties than
classical sources.

So today, one cannot just use the term »real source«
anymore, because we have two kinds of real sources with
different properties, but both so random that they can be
used for gambling houses and lotteries, where some people
would lose a lot of money where the sources of randomness
predictable or biased in some way.

J

James Kuyper

On 06/04/2014 06:44 PM, Stefan Ram wrote:
....
My point was that we had dices and coins even before the
20th century. There are classical sources of randomness such
as the bean machine (Galton box) or the roulette wheel, that
one really cannot predict and which deliver a certain
distribution of frequencies.

They are unpredictable only due to a lack of sufficient information to
make the prediction, not because of inherent unpredictability (except
insofar as they serve as amplifiers for quantum mechanical randomness).
Dices and coins usually are random enough to be deemed
sources of randomness. I will call them »classical sources«
here.

However, today we also have quantum sources of randomness,
and we know that they have different properties than
classical sources.

It is only those sources which I would consider really random.
So today, one cannot just use the term »real source«
anymore, because we have two kinds of real sources with
different properties, but both so random that they can be
used for gambling houses and lotteries, where some people
would lose a lot of money where the sources of randomness
predictable or biased in some way.

I still don't understand why your brought this up. What does the
distinction (or lack thereof) between classical and quantum sources of
randomness have to do with the message that you were nominally
responding to?

I didn't use the term "real" to modify "source" or "number" or "random"
or any related term. I only used "real" to modify "time" - referring to
systems which have very hard, very important time constraints on the
completion time for various tasks. It was completely irrelevant to my
comment whether the process was used to generate those numbers involved
classical physics, quantum physics, or a pseudo-random algorithm. The
point was only whether or not the process had an upper bound on how long
it would take.

S

Stefan Ram

James Kuyper said:
They are unpredictable only due to a lack of sufficient information to
make the prediction, not because of inherent unpredictability (except
insofar as they serve as amplifiers for quantum mechanical randomness).

Even in classical mechanics, physical states are probability
measures on phase space, not points of the phase state¹.
And then there is classical chaos! Which together gives ...

(¹ See Section 1.3 and the rest in: A Course in Mathematical
Physics; I Classical Dynamical Systems; Thirring, W.;
ISBN 13: 9780387536125; or similar books such as Arnold)

S

Stefan Ram

James Kuyper said:
I still don't understand why your brought this up. What does the
distinction (or lack thereof) between classical and quantum sources of
randomness have to do with the message that you were nominally
responding to?

|in your first paragraph - were they intended to be?

Answering another question of this meta-communicative type
(why I »brought this up« with regard to »the message that« I
was »nominally responding to«) about my response to the
first one (»were they intended« to be »connected to« my
»comments in« my »first paragraph«) is too labyrinthine for
my limited brain. I am only able to write about C or physics
in a more direct way.

J

James Kuyper

Nowhere in EPR 1935 have they ï¿½tried to interpret quantum
uncertainty as being due to "hidden variables"ï¿½.

is fresher than mine, you might be correct.
variable" and "hidden parameter" quite prominently in many locations
while describing the meaning of that paper.

I should not have attempted to write that message from memory. I've
never made any use of that information in several decades, so my memory
of it is not that reliable. From the Wikipedia article it appears I've
conflated the EPR paper in 1935 with Bell's paper "On the Einstein
Podolsky Rosen paradox", nearly 30 years later. Well, they are closely
related, and I did study both papers in great detail at about the same
time, which would explain my confusion.

J

James Kuyper

Your messages may have been in response to that question, but they
didn't seem particularly responsive. For example, the following is a
simple "yes or no" question (though it invites a more detailed response):
|in your first paragraph - were they intended to be?

As far as I know, you've never answered that question clearly either
"yes" or "no". That question was intended, if the answer was "yes", to
invited a discussion about what the connection was, in your opinion. But
your response didn't clearly explain that, either.
Answering another question of this meta-communicative type

It's not "another question", it's just a restatement of the original
(why I ï¿½brought this upï¿½ with regard to ï¿½the message thatï¿½ I
was ï¿½nominally responding toï¿½) about my response to the
first one (ï¿½were they intendedï¿½ to be ï¿½connected toï¿½ my

about your first use of the phrase "real random numbers". I've only ever
been curious about the reasons for your decision to discuss that topic
in the first place. I can, if necessary, resign myself to the
possibility that I'll never understand those reasons.

G

glen herrmannsfeldt

(snip, someone wrote)
|One cannot just assume that there are »real« random numbers,
|because the statistical properties of random numbers obtain
|from real quantum random number generators are different than
|the statistical properties of random numbers obtain from real
|classical random number generators, even if both are not
|pseudo-random number generators.
(snip)

My point was that we had dices and coins even before the
20th century. There are classical sources of randomness such
as the bean machine (Galton box) or the roulette wheel, that
one really cannot predict and which deliver a certain
distribution of frequencies.

At some point, coins and dice are also quantum systems, though
at the macroscopic level. A photon has two polarization states
(once you give a basis), and a coin has two different ground
(that is, lying on the ground) states.

You put either one in a superposition of states, such that
(reference: Schroedinger's cat) when the wave function collapses
it ends up on one of the two measurable states with equal
probability.

A small difference in the ground state energy of the coin can
bias the landing. Various details can bias the polarization state
of photons.
Dices and coins usually are random enough to be deemed
sources of randomness. I will call them »classical sources«
here.
However, today we also have quantum sources of randomness,
and we know that they have different properties than
classical sources.

They all have a limit on how fast you can extract randomness.
If you try too fast with a coin, it might not flip enough, and
so be not random enough.

If you try to extract photons too fast, the polarization might
not be different enough.

It might not be so obvious, but it takes energy to lose
information. In this case, to lose the previous state of the
system such that the new state is sufficiently random.
So today, one cannot just use the term »real source«
anymore, because we have two kinds of real sources with
different properties, but both so random that they can be
used for gambling houses and lotteries, where some people
would lose a lot of money where the sources of randomness
predictable or biased in some way.

There have been attempts to predict roulette. Blackjack is known
to have less randomness under known conditions. But they are
close enough for casinos to make a profit.

-- glen

G

glen herrmannsfeldt

Obviously not all quantum systems have a finite number of
states, often the space of their states (as rays in Hilbert
space) even has an infinite number of dimensions!

Physical quantum systems with a finite energy, ones useful for
making random generators, tend to have a finite number of states.

As well as I know it, time isn't quantized, but in the usual systems,
position, momentum, and energy are quantized. At least by the time you
get to a state where you can extract randomness, they have to be in
one of a finite number of states.

-- glen

G

glen herrmannsfeldt

(snip, someone wrote)
For any value of N. If knowing the first 1e100 numbers tells
you *anything* about the 1e100+1th, then the sequence is not
"really-random". If the numbers are bits, knowing that the next bit
is 1 with a probability of 50.001% means it's not "really-random".
Do you think otherwise?

How about for really really really large N?

More specifically, how much randomness is there in the universe?

Once you have extracted it all, then there isn't any more.
(Though you should probably be outside the universe to extract it.)

-- glen

G

glen herrmannsfeldt

(snip, someone wrote)
Assume that, knowing the first N numbers, the exact algorithm, and
complete internal state, you could determine upper and lower limits on
the next number - but that it was impossible to determine which number
within that range would be generated - would you consider that a
deterministic system? I sure wouldn't.
I think you're talking about the probabilities being exactly even, not
about the selection from among those probabilities being random. Those
are two entirely distinct issues, as far as I'm concerned.

There is an algorithm to take bits with non-uniform distribution
and generate a (smaller) bit stream with uniform distribution.
I forget the details, but some years ago intel build a hardware
(noise source) random bit generator using it.

Some described in:

https://en.wikipedia.org/wiki/Hardware_random_number_generator

One that I didn't think of: exclusive OR a biased hardware random
source with an unbiased PRNG.

-- glen

S

Stefan Ram

glen herrmannsfeldt said:
Physical quantum systems with a finite energy, ones useful for
making random generators, tend to have a finite number of states.

A free particle (in quantum theory) is a counterexample to
this assertion.
As well as I know it, time isn't quantized, but in the usual systems,
position, momentum, and energy are quantized.

They can be or not: In the case of the hydrogen atom the
spectrum has both a continuous and a discrete part, the
continuous part representing the ionization.

G

glen herrmannsfeldt

A free particle (in quantum theory) is a counterexample to
this assertion.

But how free can it be? It is still inside the universe.

The universe is large, so the levels will be close together,
you might not be able to measure the levels, but that doesn't
mean that they aren't there.
They can be or not: In the case of the hydrogen atom the
spectrum has both a continuous and a discrete part, the
continuous part representing the ionization.

-- glen

S

Stefan Ram

glen herrmannsfeldt said:
But how free can it be? It is still inside the universe.

Many assertions of physics are based on simplified models.
In the case of a free particle, one often assumes the R³ as
the universe. I have not yet seen calculations based on more
realistic assumptions about the universe. It is possible
that the spectrum then might become discrete, but for all
practical purposes, a continuous spectrum is a good approximation.

D

DFS

On 2014-06-01, DFS <[email protected]> wrote:
To my uninformed eye, both ways produce well-distributed random results
within a 10 million size test loop.

Modulo doesn't do that. Suppose you have a very good source of 8 bit random
numbers in the range [0,256), and you reduce these, say, modulo 200 to the
range in the range [0, 200). The problem is that basically, this operation
chops off the values in the range [200,256) and folds them to the range
[0,56). So these values are twice as likely to occur.

Can you write a C program to demonstrate that?

Sure, like this:

Thanks!

#include <stdio.h>

int main(void)
{
int freq[200] = { 0 };
int i;

/* Sweep over a precisely even distribution of values from 0 to 255:
namely, a linear ramp. */

for (i = 0; i < 256; i++)
freq[i % 200]++;

/* Now print the frequency of the modulo 200 values: some occurred
twice. The values add up to 256, but are unevenly distributed. */

for (i = 0; i < 200; i++)
printf("freq[%d] = %d\n", i, freq);

return 0;
}

B
Replies
41
Views
1K
Malcolm McLean
M
I
Replies
0
Views
3K
Illumin Arty
I
P
Replies
25
Views
963
Ike Naar
I
J
Replies
39
Views
1K
Ken Brody
K
D
Replies
13
Views
909
glen herrmannsfeldt
G
L
Replies
0
Views
596
luser- -droog
L
T
Replies
0
Views
343
Tman508
T
D
Replies
7
Views
496
Edward A. Falk
E