On 12 March 2011 23:29, Conrad Taylor conra...@gmail.com wrote:
On Sat, Mar 12, 2011 at 1:07 PM, Colin Law clan...@googlemail.com wrote:
On 12 March 2011 20:47, Michael Pavling pavl...@gmail.com wrote:
On 12 March 2011 14:23, Colin Law clan...@googlemail.com wrote:
On 12 March 2011 13:42,
I know how to generate a random number between 1 and 2 :
def random
return (1 + rand(2))
end
but let's say I would like to return 1 in 80% of the calls and 2 in
20% of the call...
which library should I use ? ( I've seen a lot at http://raa.ruby-lang.org/
)
thanks for your suggestions
--
On 12 March 2011 10:10, Erwin yves_duf...@mac.com wrote:
I know how to generate a random number between 1 and 2 :
def random
return (1 + rand(2))
end
but let's say I would like to return 1 in 80% of the calls and 2 in
20% of the call...
which library should I use ? ( I've seen a lot at
On Mar 12, 2011, at 5:37 AM, Colin Law wrote:
On 12 March 2011 10:10, Erwin yves_duf...@mac.com wrote:
I know how to generate a random number between 1 and 2 :
def random
return (1 + rand(2))
end
but let's say I would like to return 1 in 80% of the calls and 2 in
20% of the call...
which
On 12 March 2011 13:42, Rob Biedenharn r...@agileconsultingllc.com wrote:
On Mar 12, 2011, at 5:37 AM, Colin Law wrote:
On 12 March 2011 10:10, Erwin yves_duf...@mac.com wrote:
I know how to generate a random number between 1 and 2 :
def random
return (1 + rand(2))
No it doesn't
On 12 March 2011 14:23, Colin Law clan...@googlemail.com wrote:
On 12 March 2011 13:42, Rob Biedenharn r...@agileconsultingllc.com wrote:
def usually_one
rand 0.80 ? 1 : 2
end
Yes, much better. I suppose it is the old programmer in me
instinctively avoiding floating point to save on
On 12 March 2011 20:47, Michael Pavling pavl...@gmail.com wrote:
def usually_one
[1,2,2,2,2][rand(5)]
end
*ahem* of course.. this is the total opposite of what the OP asked
for, and returns 1 in 20% of the calls :-D
sorry for not paying attention oops!
--
You received this message
On 12 March 2011 20:47, Michael Pavling pavl...@gmail.com wrote:
On 12 March 2011 14:23, Colin Law clan...@googlemail.com wrote:
On 12 March 2011 13:42, Rob Biedenharn r...@agileconsultingllc.com wrote:
def usually_one
rand 0.80 ? 1 : 2
end
Yes, much better. I suppose it is the old
On 12 March 2011 21:07, Colin Law clan...@googlemail.com wrote:
Ha! Vindicated
I expected to get different times, but to keep the proportions the
same... but I get a little difference in order of speed:
begin
? t=Time.now
100.times{(rand(100) + 120)/100}
puts Time.now-t
end
1.200484
On 12 March 2011 21:36, Michael Pavling pavl...@gmail.com wrote:
On 12 March 2011 21:07, Colin Law clan...@googlemail.com wrote:
Ha! Vindicated
I expected to get different times, but to keep the proportions the
same... but I get a little difference in order of speed:
begin
? t=Time.now
On 12 March 2011 22:01, Colin Law clan...@googlemail.com wrote:
OK, I admit defeat. the benefit of your technique is even greater on 1.8.7,
taking only 0.67 secs on my machine.
Nah! Who cares if it takes half-a-second or a second to select a
million random numbers any of the methods are
On 12 March 2011 22:16, Michael Pavling pavl...@gmail.com wrote:
On 12 March 2011 22:01, Colin Law clan...@googlemail.com wrote:
OK, I admit defeat. the benefit of your technique is even greater on 1.8.7,
taking only 0.67 secs on my machine.
Nah! Who cares if it takes half-a-second or a
On Sat, Mar 12, 2011 at 1:07 PM, Colin Law clan...@googlemail.com wrote:
On 12 March 2011 20:47, Michael Pavling pavl...@gmail.com wrote:
On 12 March 2011 14:23, Colin Law clan...@googlemail.com wrote:
On 12 March 2011 13:42, Rob Biedenharn r...@agileconsultingllc.com
wrote:
def
13 matches
Mail list logo