Bobby wrote:
>
> I'm passing @nums values from an html form; so now my @nums = ($list) where
> $list = 97000,97005,98000,96100,94003 . The rand funtion now interprets $list
> as a string and not integers so the script doesn't works anymore. How do i
> convert values with that list from a string
From: ""Chris Charley""
From: "Bobby" Newsgroups: perl.beginners
Subject: rand()
Hi all,
How do I use the rand function to print out more than one random number
for an array? In the example script below i have an array @nums with a
list of numbers; how do i print out more than one random
> "peng" == peng kyo <[EMAIL PROTECTED]> writes:
peng> You may need srand before the rand function.
Not in any version of Perl released in the past 8 years or so.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/mer
On Mon, 2008-07-28 at 13:17 -0700, Bobby wrote:
> How do i convert values with that list from a string to itegers so
> that the script will work properly?
See `perldoc -f split`
--
Just my 0.0002 million dollars worth,
Shawn
"Where there's duct tape, there's hope."
"Perl is the duct tap
ist from a string to itegers so that the script will
work properly? Thanks for any suggestion.
--- On Mon, 7/28/08, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
From: Mr. Shawn H. Corey <[EMAIL PROTECTED]>
Subject: Re: rand()
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTEC
- Original Message -
From: "Bobby" <[EMAIL PROTECTED]>
Newsgroups: perl.beginners
To:
Sent: Monday, July 28, 2008 10:54 AM
Subject: rand()
Hi all,
How do I use the rand function to print out more than one random number for
an array? In the example script below i have an array @nums
Bobby wrote:
That helps but how would i just get back an X number of random numbers
because @nums could be in the hundreds of unique numbers. For instance,
i just want to randomly pickout 4 numbers from a long list of unique
numbers in @nums, how would i do that?
use List::Util qw' shuffle ';
On Mon, 2008-07-28 at 19:02 +0100, Aruna Goke wrote:
> [EMAIL PROTECTED] wrote:
> > On Mon, Jul 28, 2008 at 11:52 PM, Bobby <[EMAIL PROTECTED]> wrote:
> >> Peng,
> >>
> >>
> >>
> >> Could you give me an example code? I want to randomly select X numbers of
> >> numbers from the @nums list. For insta
[EMAIL PROTECTED] wrote:
On Mon, Jul 28, 2008 at 11:52 PM, Bobby <[EMAIL PROTECTED]> wrote:
Peng,
Could you give me an example code? I want to randomly select X numbers of
numbers from the @nums list. For instance, i want to randomly select 3
numbers from @nums i.e. 1, 10005, 14. How
rom: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Subject: Re: rand()
To: [EMAIL PROTECTED]
Cc: beginners@perl.org
Date: Monday, July 28, 2008, 9:58 AM
On Mon, Jul 28, 2008 at 11:52 PM, Bobby <[EMAIL PROTECTED]> wrote:
> Peng,
>
>
>
> Could you give me an example code? I want to rando
make test, has been 20
minutes already; is that normal? Thanks.
--- On Mon, 7/28/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Subject: Re: rand()
To: [EMAIL PROTECTED]
Cc: beginners@perl.org
Date: Monday, July 28, 2008, 9:58 AM
On Mon,
, Aruna Goke <[EMAIL PROTECTED]> wrote:
From: Aruna Goke <[EMAIL PROTECTED]>
Subject: Re: rand()
To: "Perl beginners"
Date: Monday, July 28, 2008, 9:54 AM
Bobby wrote:
> Hi all,
>
> How do I use the rand function to print out more than one random number
for an array
On Mon, Jul 28, 2008 at 11:52 PM, Bobby <[EMAIL PROTECTED]> wrote:
> Peng,
>
>
>
> Could you give me an example code? I want to randomly select X numbers of
> numbers from the @nums list. For instance, i want to randomly select 3
> numbers from @nums i.e. 1, 10005, 14. How would you use sr
Bobby wrote:
Hi all,
How do I use the rand function to print out more than one random number for an array? In the example script below i have an array @nums with a list of numbers; how do i print out more than one random numbers from that list (@nums)? Thanks.
#!/usr/bin/perl
use strict;
us
00","150");
my $randnum = $nums[rand(@nums)];
print "$randnum \n";
--- On Mon, 7/28/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Subject: Re: rand()
To: [EMAIL PROTECTED]
Cc: beginners@perl.org
Date: Monday, Jul
On Mon, Jul 28, 2008 at 10:54 PM, Bobby <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> How do I use the rand function to print out more than one random number for
> an array? In the example script below i have an array @nums with a list of
> numbers; how do i print out more than one random numbers from
Jeff Borders wrote:
Hello, (revised to include entire program, input file, and output)
Okay, that's better. :)
I've written a simple quiz program and I've run into a problem with rand
and the integer it returns. It seems that it will eventually choose
either 0 or n+1 (I'm guessing) which blows up
On Jun 20, Balint, Jess said:
>Are these -l and -n flags specific to perl 5.6? I am using 5.005 and they
>don't work as illustrated:
The -l and -n flags have been with Perl for quite some time.
>% perl -e 'while{print if(.45909592993094279021 < rand);}' db_mlb_undup.dat
Uh, you're missing some
909592993094279021 < rand);'
| head -1
%
Thanks.
~Jess
-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 19, 2002 11:34 AM
To: Balint, Jess
Cc: '[EMAIL PROTECTED]'
Subject: Re: rand < vs rand >
On Jun 19, Balint,
>
> Another way to determine how randomly the rand() function is working is to
plot
> it sorted. A bad random function might predominate in a particular area,
so
> you want to see a straight diagonal line in this case, meaning the results
are
> spread throughout the range.
(This is drifting off-
n this case, meaning the results are
spread throughout the range. Here's what it looks like with @data = sort
@data:
http://www.eskimo.com/~ghawk/temp/randplotsorted.png
Gary
> -Original Message-
> From: Wagner-David [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, January 13,
#x27;" <[EMAIL PROTECTED]>; "Gary Hawkins"
<[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, January 14, 2002 5:19 AM
Subject: RE: rand() function
> Worked just like stated. I missed that you were pushing on @data and used
@dataset when going to the img
:[EMAIL PROTECTED]]
Sent: Saturday, January 12, 2002 08:51
To: Gary Hawkins
Cc: [EMAIL PROTECTED]
Subject: Re: rand() function
You seem to have looked at Chart-Plot.
You might try
use Chart::Plot;
my $img = Chart::Plot->new(400,400);
my @data;
for (1..1) { push @data, rand() }
$
-
From: "Wagner-David" <[EMAIL PROTECTED]>
To: "'Roger C Haslock'" <[EMAIL PROTECTED]>; "Gary Hawkins"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, January 10, 2002 8:27 PM
Subject: RE: rand() function
> What P
be used in
a
> script. No offense please. My question is reasonable.
>
> > -Original Message-
> > From: Roger C Haslock [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 10, 2002 11:56 PM
> > To: Gary Hawkins
> > Subject: Re: rand() function
&g
What Perl module is needed for plot or is this under the browser or
Thanks.
Wags ;)
-Original Message-
From: Roger C Haslock [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 11:36
To: Gary Hawkins; [EMAIL PROTECTED]
Subject: Re: rand() function
My apologies: a typo
Sent: Wednesday, January 09, 2002 11:49 PM
Subject: RE: rand() function
> > to take successive pairs, and plot them on a graph. Bad generators would
> > show distinct lines after a while.
> >
> > eg
> >
> > for (0..1) {
> > plot rand(), read()
> to take successive pairs, and plot them on a graph. Bad generators would
> show distinct lines after a while.
>
> eg
>
> for (0..1) {
> plot rand(), read()
> }
>
What would it require to make that do something?
>ppm search plot
Packages available from
http://ppm.ActiveState.com/cgibin/
A simple test I discovered years ago for pseudo-random number generators was
to take successive pairs, and plot them on a graph. Bad generators would
show distinct lines after a while.
eg
for (0..1) {
plot rand(), read()
}
- Roger -
- Original Message -
From: "Robert Howard" <
> > Is there a statistically better solution for generating random numbers than
> > Perl's built in rand() function? I noticed a couple modules on CSPAN, but
> > are they any better? I haven't done a true test of the spread
> regular rand()
> > gives, but it seems to me to give numbers closer to t
Robert Howard wrote:
>
> Is there a statistically better solution for generating random numbers than
> Perl's built in rand() function? I noticed a couple modules on CSPAN, but
> are they any better? I haven't done a true test of the spread regular rand()
> gives, but it seems to me to give numbe
I did a random sampling of 10,000 random numbers in two separate groups :
for (0..1) { print rand()."\n" }
It seemed to consistently revert towards a mean of 0.50 (i.e. results(1) =
0.503; results(2) = 0.498). I also broke those into groups of 100 and
seemed to get the same results. That
32 matches
Mail list logo