I realized that my previous mail was only sent to Cliff! > Thanks all for your answers. I had finally some time today to work on > this but I can unfortunately not make Cliff's solution to work. > > Will keep trying,
Well, I believe I got the problem. If i tell pdl: $a = random (100); and then: p nelem which($a < 0.45 | $a > 0.41) I get 100!, which is not supposed to be the elements of $a that lie between 0.45 and 0.41. On the other hand, p nelem which($a < 0.45 ) gives 51 ... So I realized that at least in my installation of PDL, "which" and "where" do not work with the double argument " ( > | < ) ". The simple one does though. Will try reinstalling. Is anyone else having this problem? Hernán > 2009/6/30 Cliff Sobchuk <[email protected]>: >> If you are looking for the histogram of R as a function of Z, could you not >> first sort the data on Z so that you now have two vectors that are sorted in >> ascending (or descending) order of Z (as Craig/Chris indicated). >> >> Then create an index of the unique zvalues >> >> $zi=$z->uniq; >> >> Now create the histograms for each zindex >> >> for (1..nelem($zi)) >> {($xv[$_-1],$rh[$_-1])=hist($r->where($z==$zi->index($_-1)))} >> >> I did a sample of sorted data (25 z coords of 1,2,3,4) and a random vector r >> (100 points) and it gives what I expected. >> >> You could use the value of $zi->index($_-1) to be the array index for the >> xValues and rHistogram counts to identify them directly as part of the >> array. Just have to remember that all of the other array values =0. >> >> Hope this helps. >> >> Cliff Sobchuk esn 361-8169, 403-262-4010 ext: 361-8169 >> Fax: 403-262-4010 ext: 361-8170 >> Nortel Core RF Field Support: All information is Nortel confidential. >> >> -----Original Message----- >> From: Craig DeForest [mailto:[email protected]] >> Sent: June 30, 2009 9:18 AM >> To: Hernán De Angelis >> Cc: perldl >> Subject: Re: [Perldl] Compute a distribution function from irregular data >> >> If you don't care about your bin size, and the values are sorted by z value, >> a straightforward way is: >> >> $n = 57; # or whatever >> >> $bounds = $z->(0:-1:$n); >> $box_z = ($bounds->(1:-1) + $bounds->(0:-2))/2; $box_freq = >> $n/($bounds->(1:-1) - $bounds->(0:-2)); >> >> >> >> >> >> >> On Jun 30, 2009, at 8:29 AM, Hernán De Angelis wrote: >> >>> Thanks, I will think about that. >>> >>> >>> Hernán >>> >>> >>> 2009/6/30 Chris Marshall <[email protected]>: >>>> If you sort the (z,r) data by z you can use the histogram counts to >>>> calculate ranges of index values corresponding to each bin. range() >>>> or other indexing operation can select the sets to calculate your >>>> desired stats. >>>> >>>> --Chris >>>> >>>> Hernán De Angelis wrote: >>>>> >>>>> Dear PDL'ers, >>>>> >>>>> I am stuck with an apparently simple problem and hoped that someone >>>>> in this list might have a clue. >>>>> >>>>> I have approx. 130000 pairs of data, z and r, which represent >>>>> observations of some function r at some coordinate z. >>>>> A sample of the data looks like this: >>>>> >>>>> z r >>>>> >>>>> 3311 311.817 >>>>> 3346 249.333 >>>>> 3238 353.368 >>>>> 3279 367.020 >>>>> 3347 324.405 >>>>> 3448 274.632 >>>>> 3161 310.469 >>>>> 3204 358.739 >>>>> ...... ...... >>>>> >>>>> These observations come from a three dimensional space, and >>>>> therefore there exists more than one r value for each value of the >>>>> coordinate z. >>>>> What I want to do is to estimate a gross distribution of r values >>>>> versus z. Simple as it seems I am having troubles to set up a PDL >>>>> code to compute it. >>>>> >>>> >>>> >>> >>> >>> >>> -- >>> >>> Hernán De Angelis >>> Linux user # 397217 >>> >>> _______________________________________________ >>> Perldl mailing list >>> [email protected] >>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >>> >> >> >> _______________________________________________ >> Perldl mailing list >> [email protected] >> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl >> > > > > -- > > Hernán De Angelis > Linux user # 397217 > -- Hernán De Angelis Linux user # 397217 _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
