in reply to •Re: Selecting random records from an array
in thread Selecting random records from an array

my @subset = rand(75) <= 100, @input;

I think it works better with grep and the values swapped :)

my @subset = grep rand(100) < 75, @input;
Or just:
my @subset = grep rand() < .75, @input;

Perhaps I misinterpreted your code, but in that case I have no idea what it is supposed to do.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Replies are listed 'Best First'.
Re: Re: &bull;Re: Selecting random records from an array
by halley (Prior) on Jun 04, 2003 at 13:48 UTC

    He is creating a throttle or valve with the grep function, allowing only a certain stochastic percentage of @input applicants through the valve into the accepted @subset.

    Think of it as a lottery: anybody who flips a coin twice and gets a "heads" in either flip will win. That could be everyone, it could be nobody, but the odds are that about 75% of the players will win.

    --
    [ e d @ h a l l e y . c c ]

      He is creating a throttle or valve with the grep function, allowing only a certain stochastic percentage of @input applicants through the valve into the accepted @subset.

      I know. merlyn's Original post had my @subset = rand(75) <= 100, @input;, which wasn't using grep at all. Apparently he's updated the node.

      I don't include citations for you to ignore them; they're there to read :)

      Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }