From: Peng Yu on 31 May 2010 23:45 On May 31, 10:25 pm, Jürgen Exner <jurge...(a)hotmail.com> wrote: > Peng Yu <pengyu...(a)gmail.com> wrote: > >It seems that the int(rand(10)) generate random with replacement. I'm > >wondering how to generate random number without replacement in perl. > > Could you please explain what you mean by "with/without replacement"? > A number is a number, it doesn't replace anything.... These are standard concepts in statistics. Please see the following webpage for the explanations on sampling 'with/without replacement'. http://www.ma.utexas.edu/users/parker/sampling/repl.htm
From: J�rgen Exner on 1 Jun 2010 00:31 Peng Yu <pengyu.ut(a)gmail.com> wrote: >On May 31, 10:25�pm, J�rgen Exner <jurge...(a)hotmail.com> wrote: >> Peng Yu <pengyu...(a)gmail.com> wrote: >> >It seems that the int(rand(10)) generate random with replacement. I'm >> >wondering how to generate random number without replacement in perl. >> >> Could you please explain what you mean by "with/without replacement"? >> A number is a number, it doesn't replace anything.... > >These are standard concepts in statistics. Please see the following >webpage for the explanations on sampling 'with/without replacement'. > >http://www.ma.utexas.edu/users/parker/sampling/repl.htm Ok. For those like me not familiar with this term: he means random numbers with and without repetition. jue
From: Uri Guttman on 1 Jun 2010 01:03 >>>>> "JE" == J�rgen Exner <jurgenex(a)hotmail.com> writes: JE> Peng Yu <pengyu.ut(a)gmail.com> wrote: >> On May 31, 10:25�pm, J�rgen Exner <jurge...(a)hotmail.com> wrote: >>> Peng Yu <pengyu...(a)gmail.com> wrote: >>> >It seems that the int(rand(10)) generate random with replacement. I'm >>> >wondering how to generate random number without replacement in perl. >>> >>> Could you please explain what you mean by "with/without replacement"? >>> A number is a number, it doesn't replace anything.... >> >> These are standard concepts in statistics. Please see the following >> webpage for the explanations on sampling 'with/without replacement'. >> >> http://www.ma.utexas.edu/users/parker/sampling/repl.htm JE> Ok. For those like me not familiar with this term: he means random JE> numbers with and without repetition. and i told him how to do it. i won't tell him again. it is a simple problem and hashes solve it. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Peng Yu on 1 Jun 2010 04:28 On Jun 1, 12:03 am, "Uri Guttman" <u...(a)StemSystems.com> wrote: > >>>>> "JE" == Jürgen Exner <jurge...(a)hotmail.com> writes: > > JE> Peng Yu <pengyu...(a)gmail.com> wrote: > >> On May 31, 10:25 pm, Jürgen Exner <jurge...(a)hotmail.com> wrote: > >>> Peng Yu <pengyu...(a)gmail.com> wrote: > >>> >It seems that the int(rand(10)) generate random with replacement.. I'm > >>> >wondering how to generate random number without replacement in perl. > >>> > >>> Could you please explain what you mean by "with/without replacement"? > >>> A number is a number, it doesn't replace anything.... > >> > >> These are standard concepts in statistics. Please see the following > >> webpage for the explanations on sampling 'with/without replacement'. > >> > >>http://www.ma.utexas.edu/users/parker/sampling/repl.htm > > JE> Ok. For those like me not familiar with this term: he means random > JE> numbers with and without repetition. > > and i told him how to do it. i won't tell him again. it is a simple > problem and hashes solve it. What do you mean? I didn't ask you to tell me again. But I feel sorry that perl doesn't provide such a function out of the box.
From: Uri Guttman on 1 Jun 2010 04:50 >>>>> "PY" == Peng Yu <pengyu.ut(a)gmail.com> writes: PY> On Jun 1, 12:03�am, "Uri Guttman" <u...(a)StemSystems.com> wrote: >> � JE> Ok. For those like me not familiar with this term: he means random >> � JE> numbers with and without repetition. >> >> and i told him how to do it. i won't tell him again. it is a simple >> problem and hashes solve it. PY> What do you mean? I didn't ask you to tell me again. i told you how to do it. either you didn't read it or you didn't get the solution. PY> But I feel sorry that perl doesn't provide such a function out of the PY> box. i feel sorry for you that you can't code this up in 5 minutes. it is trivial to do as i outlined. name another lang that has this built in. it isn't needed as it is easily made from a hash and a loop and calls to rand. this is about 2 lines of code and possibly 1 line. here, i will code it up on the fly and possibly even get it right. i leave making into a sub as your exercise. my %seen ; while( 1 ) { $x = int rand( 100_000_000 ) ; $seen{$x} and next ; $seen{$x} = 1; print $x } oops, it wrapped into 3 lines. was that too complex? it will print numbers until it runs out of them. no duplicates. make it a for loop to control the number of prints. can you handle that? do you feel sorry for perl now? show me another lang that could do that as easily. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: Troubles using Net::Pcap and Net::PcapUtils Next: How to take two input streams? |