Hey Nick,

I'm not sure how fast this is, but this is what I do when I need to
randomly sort things:

# Assuming you have $data already declared...
$shuffled = cat($data->random, $data)->transpose->qsortvec->(1)->flat

The call "->(1)" is a NiceSliceism; replace with a slice method call if
that's not on.

Bear in mind that PDL's random number generator is Perl's default, which is
not sufficiently random for most Monte Carlo stuff. I've never needed
anything more sophisticated for my work, but I suspect that the PDL
bindings to GSL provide random generators of higher quality.

Good luck!
David

On Thu, Aug 6, 2015 at 12:59 PM, Nick Wright <[email protected]> wrote:

> Hi everyone
>
> I need help with something that I think *should* be simple with Perl/PDL
> but I can't find the command for it.
>
> I basically just want to randomly re-order a 1-dimensional, moderately
> long (1500 entries) piddle and I can't find a simple way. I need to do this
> for the purposes of a Monte Carlo simulation, so I was hoping PDL might
> have an efficient way to do it so I can repeat is 1000s of times quickly!
>
> Thanks in advance for the help!
>
> Cheers,
>
> Nick
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general
>
>


-- 
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan
------------------------------------------------------------------------------
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to