In message qoteitso8ru@ruuvi.it.helsinki.fi, Jussi Piitulainen wrote:
Miles Kaufmann writes:
I'm curious what algorithm calls for random numbers on a closed
interval.
The Box-Muller transform, polar form. At least Wikipedia says so.
Doesn't seem to be necessary, if I interpret the
In message mailman.1366.1244592006.8015.python-l...@python.org, Esmail
wrote:
I'm implementing a Particle Swarm Optimizer. Depending on what paper you
read you'll see mention of required random values between 0 and 1
which is somewhat ambiguous. I came across one paper that specified
the
In message mailman.1368.1244607807.8015.python-l...@python.org, Esmail wrote:
Here is part of the specification of an algorithm I'm implementing that
shows the reason for my original query:
vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a)
xid = xid + vid (1b)
Thanks everyone, I learned more than I expected about
floats :-) and got some good explanations and ideas about
all of this.
Esmail
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote:
The docs are now... sort of correct. For some values of a and b,
uniform() can never return b. Notably, I believe uniform(0, 1) is
equivalent to random(), and will never return 1. However, uniform(1, 2)
CAN
On Jun 9, 11:28�pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 21:04:49 -0700, Mensanator wrote:
On Jun 9, 8:28 pm, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 9, 8:45 pm, Mensanator mensana...@aol.com wrote:
On Jun 9, 6:05 pm, Gabriel
On Jun 10, 1:52 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote:
Therefore, to me the most up-to-date docs (which say
that uniform(a, b) returns a float in the closed
interval [a, b]) is closer to correct than before,
John Yeung wrote:
On Jun 10, 1:52am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote:
Therefore, to me the most up-to-date docs (which say
that uniform(a, b) returns a float in the closed
interval
Miles Kaufmann writes:
[...]
I'm curious what algorithm calls for random numbers on a closed
interval.
The Box-Muller transform, polar form. At least Wikipedia says so.
--
http://mail.python.org/mailman/listinfo/python-list
On 10 Giu, 06:23, Esmail ebo...@hotmail.com wrote:
Here is part of the specification of an algorithm I'm implementing that
shows the reason for my original query:
vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a)
xid = xid + vid (1b)
where c1 and c2 are two
On Jun 10, 3:24 pm, John Yeung gallium.arsen...@gmail.com wrote:
Alex, did you bother to read what I quoted? Paul McGuire suggested an
alternative in case the OP was choosing integers in a roundabout way.
I was merely pointing out that Paul's solution can be more simply
achieved using a
On Wed, Jun 10, 2009 at 8:25 AM, John Yeunggallium.arsen...@gmail.com wrote:
That uniform(a, b) will return a random float in the semi-open
interval [a, b) for certain values of a and b; and in the closed
interval [a, b] for other values of a and b. (Swap a and b if a b.)
To me, the fact
Esmail writes:
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I am implementing an algorithm and want to stay as true to the
original design specifications as possible though I
On Jun 10, 7:25 am, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 10, 1:52 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote:
Therefore, to me the most up-to-date docs (which say
that uniform(a, b) returns a float
Esmail ebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
[...]
Here are three recipes, each more pedantic than the last. They all
assume that Python
On Jun 9, 11:23 pm, Esmail ebo...@hotmail.com wrote:
Here is part of the specification of an algorithm I'm implementing that
shows the reason for my original query:
vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a)
xid = xid + vid (1b)
where c1 and c2 are two
On Jun 10, 4:01 am, Mark Dickinson dicki...@gmail.com wrote:
On Jun 10, 7:25 am, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 10, 1:52 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote:
Therefore, to me
On Jun 10, 6:21 pm, Mensanator mensana...@aol.com wrote:
So, the 2.6.2 documentation is STILL wrong. Before it implied
it was ALWAYS a semi-open interval, and now it says it's ALWAYS
a closed interval. But neither is correct.
Exactly which bit of the 2.6.2 documentation do you think is
On Jun 10, 12:37 pm, Mark Dickinson dicki...@gmail.com wrote:
On Jun 10, 6:21 pm, Mensanator mensana...@aol.com wrote:
So, the 2.6.2 documentation is STILL wrong. Before it implied
it was ALWAYS a semi-open interval, and now it says it's ALWAYS
a closed interval. But neither is correct.
On 2009-06-09 19:27, Mensanator wrote:
On Jun 9, 6:12 pm, Robert Kernrobert.k...@gmail.com wrote:
On 2009-06-09 18:05, Mensanator wrote:
On Jun 9, 4:33 pm, Esmailebo...@hotmail.comwrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to
Mensanator wrote:
So, the 2.6.2 documentation is STILL wrong. Before it implied
it was ALWAYS a semi-open interval, and now it says it's ALWAYS
a closed interval. But neither is correct.
If a x b is true, then a = x = b is true.
But docs say that in general end point values might happen.
On Jun 10, 6:57 pm, Mensanator mensana...@aol.com wrote:
On Jun 10, 12:37 pm, Mark Dickinson dicki...@gmail.com wrote:
On Jun 10, 6:21 pm, Mensanator mensana...@aol.com wrote:
So, the 2.6.2 documentation is STILL wrong. Before it implied
it was ALWAYS a semi-open interval, and now it
On 2009-06-10 13:53, Terry Reedy wrote:
Mensanator wrote:
So, the 2.6.2 documentation is STILL wrong. Before it implied
it was ALWAYS a semi-open interval, and now it says it's ALWAYS
a closed interval. But neither is correct.
If a x b is true, then a = x = b is true.
But docs say that in
On Jun 10, 8:15 pm, Robert Kern robert.k...@gmail.com wrote:
On 2009-06-10 13:53, Terry Reedy wrote:
A full technical discussion does not below in the docs, in my opinion. A
wike article would be fine.
True. However, a brief note that Due to floating point arithmetic, for some
values of a
On 2009-06-10 14:46, Mark Dickinson wrote:
On Jun 10, 8:15 pm, Robert Kernrobert.k...@gmail.com wrote:
On 2009-06-10 13:53, Terry Reedy wrote:
A full technical discussion does not below in the docs, in my opinion. A
wike article would be fine.
True. However, a brief note that Due to floating
On 2009-06-10 15:32, Robert Kern wrote:
On 2009-06-10 14:46, Mark Dickinson wrote:
But I don't know why it would be useful to know that endpoints *are*
sometimes
included, without knowing exactly when.
That's a fair point. However, one issue that hasn't been brought up is
that it might be
Robert Kern robert.k...@gmail.com wrote:
On 2009-06-10 14:46, Mark Dickinson wrote:
On Jun 10, 8:15 pm, Robert Kernrobert.k...@gmail.com wrote:
On 2009-06-10 13:53, Terry Reedy wrote:
A full technical discussion does not below in the docs, in my opinion. A
wike article would be fine.
True.
On 2009-06-10 15:54, Mark Dickinson wrote:
Robert Kernrobert.k...@gmail.com wrote:
On 2009-06-10 14:46, Mark Dickinson wrote:
On Jun 10, 8:15 pm, Robert Kernrobert.k...@gmail.com wrote:
On 2009-06-10 13:53, Terry Reedy wrote:
A full technical discussion does not below in the docs, in my
On Jun 9, 2:33 pm, Esmail ebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I am implementing an algorithm and want to stay as true to the
original design
Robert Kern robert.k...@gmail.com wrote:
On 2009-06-10 15:54, Mark Dickinson wrote:
[...] I'm not sure I'm capable of coming up with extra wording
for the docs that won't just cause more confusion, so I'll leave that
to someone else.
I did make a concrete suggestion.
Yes, you did. Thank
On 2009-06-10 16:47, Mark Dickinson wrote:
And of course I'm wrong. I shouldn't have said *never*, above:
from random import uniform
uniform(-1e308, 1e308)
inf
:-(
Somehow this doesn't seem worth either fixing or documenting, though.
Agreed.
--
Robert Kern
I have come to believe that
On Wed, 10 Jun 2009 15:32:05 -0500, Robert Kern wrote:
That's a fair point. However, one issue that hasn't been brought up is
that it might be confusing to a user why random.random() returns values
in a half-open interval while random.uniform() claims a closed interval.
Even for reasonably
En Tue, 09 Jun 2009 18:33:39 -0300, Esmail ebo...@hotmail.com escribió:
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I think you shouldn't worry about that - the difference may be as
On Jun 9, 4:33 pm, Esmail ebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I am implementing an algorithm and want to stay as true to the
original design
On 2009-06-09 18:05, Mensanator wrote:
On Jun 9, 4:33 pm, Esmailebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I am implementing an algorithm and want to
On Jun 9, 2009, at 7:05 PM, Mensanator wrote:
On Jun 9, 4:33 pm, Esmail wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I am implementing an algorithm and want to stay as true
Gabriel Genellina wrote:
En Tue, 09 Jun 2009 18:33:39 -0300, Esmail ebo...@hotmail.com escribió:
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
I think you shouldn't worry about that -
Robert Kern wrote:
On 2009-06-09 18:05, Mensanator wrote:
On Jun 9, 4:33 pm, Esmailebo...@hotmail.com wrote:
That's wrong. Where did you get it?
http://docs.python.org/library/random
What he said :-)
(thanks Robert)
--
http://mail.python.org/mailman/listinfo/python-list
Miles Kaufmann wrote:
I'm curious what algorithm calls for random numbers on a closed interval.
I'm implementing a Particle Swarm Optimizer. Depending on what paper you
read you'll see mention of required random values between 0 and 1
which is somewhat ambiguous. I came across one paper that
On Jun 9, 6:12 pm, Robert Kern robert.k...@gmail.com wrote:
On 2009-06-09 18:05, Mensanator wrote:
On Jun 9, 4:33 pm, Esmailebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range
On Jun 9, 4:33 pm, Esmail ebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
Are you trying to generate a number in the range [0,n] by multiplying
a random
On Jun 9, 6:05 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:
En Tue, 09 Jun 2009 18:33:39 -0300, Esmail ebo...@hotmail.com escribió:
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including
On Jun 9, 8:45 pm, Mensanator mensana...@aol.com wrote:
On Jun 9, 6:05 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:
py a+(b-a)*z b # the expression used for uniform(a,b)
False
py a+(b-a)*z
11.0
What you do with the number after it's created is not
random's concern.
Mensanator,
On Jun 9, 8:39 pm, Paul McGuire pt...@austin.rr.com wrote:
Are you trying to generate a number in the
range [0,n] by multiplying a random function that
returns [0,1] * n? If so, then you want to do
this using: int(random.random()*(n+1)) This will
give equal chance of getting any number from
On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote:
The docs are now... sort of correct. For some values of a and b,
uniform() can never return b. Notably, I believe uniform(0, 1) is
equivalent to random(), and will never return 1. However, uniform(1, 2)
CAN return 2, if this is any
On Jun 10, 11:32 am, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 9, 8:39 pm, Paul McGuire pt...@austin.rr.com wrote:
Are you trying to generate a number in the
range [0,n] by multiplying a random function that
returns [0,1] * n? If so, then you want to do
this using:
On Jun 9, 8:28�pm, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 9, 8:45�pm, Mensanator mensana...@aol.com wrote:
On Jun 9, 6:05�pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:
py a+(b-a)*z b # the expression used for uniform(a,b)
False
py a+(b-a)*z
11.0
What you do
On Jun 9, 4:33 pm, Esmail ebo...@hotmail.com wrote:
Hi,
random.random() will generate a random value in the range [0, 1).
Is there an easy way to generate random values in the range [0, 1]?
I.e., including 1?
You could do random.uniform(0, 1.0002). Due to floating-
point
Here is part of the specification of an algorithm I'm implementing that
shows the reason for my original query:
vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a)
xid = xid + vid (1b)
where c1 and c2 are two positive constants,
rand() and Rand() are two random
On Tue, 09 Jun 2009 21:04:49 -0700, Mensanator wrote:
On Jun 9, 8:28�pm, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 9, 8:45�pm, Mensanator mensana...@aol.com wrote:
On Jun 9, 6:05�pm, Gabriel Genellina gagsl-...@yahoo.com.ar
wrote:
py a+(b-a)*z b # the expression used for
On Jun 9, 11:24 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote:
The docs are now... sort of correct. For some values of a and b,
uniform() can never return b. Notably, I believe uniform(0, 1) is
equivalent to random(),
On Jun 10, 12:01 am, alex23 wuwe...@gmail.com wrote:
On Jun 10, 11:32 am, John Yeung gallium.arsen...@gmail.com wrote:
On Jun 9, 8:39 pm, Paul McGuire pt...@austin.rr.com wrote:
Are you trying to generate a number in the
range [0,n] by multiplying a random function that
returns [0,1]
On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote:
On Jun 9, 11:24 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Tue, 09 Jun 2009 18:28:23 -0700, John Yeung wrote:
The docs are now... sort of correct. For some values of a and b,
uniform() can never return b.
53 matches
Mail list logo