On 6/26/2010 1:55 PM, P Kishor wrote: > a few days back I had asked for help creating an [x,y,z] dims piddle > where every element was a random integer between 0 and 255. A couple > of suggestions set me off to learn dummy(), and I also learned the > correct use of random() (thanks, Daniel and Chris). Today, I figured > out a way to make any dimension piddle filled with random integers > between any two integers<max> and<min>. > > $a = (( (zeroes(<dim> [,<dim> ..] ))->random * (<max> -<min> + 1 > )) +<min> )->floor > > The thing is, the above works whether I use zeroes or ones, which, I > am guessing is because internally PDL::new_from_specification is being > used to create a template for the piddle.
It will also work if you leave out the ones or zeros/zeroes and put the type and dimension arguments in random: PDL> $a = (random(5,5,3)*(1000-500+1)+500)->floor PDL> p $a [ [ [578 968 547 500 739] [773 857 745 598 550] [896 829 979 975 846] [625 693 944 817 508] [569 620 696 817 877] ] [ [654 522 908 822 835] [610 866 526 507 796] [521 518 965 626 700] [528 995 722 632 736] [642 794 980 776 691] ] [ [987 859 706 724 947] [985 908 741 886 977] [976 612 615 887 514] [720 689 984 507 920] [867 774 674 836 531] ] ] --Chris _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
