[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: histogram question*From*: "Jim Pendleton" <jimpendleton(at)earthlink.net>*Date*: Thu, 09 Aug 2001 22:01:57 GMT*Newsgroups*: comp.lang.idl-pvwave*Organization*: Mr. Jim's B & B Mark II*References*: <3B719E6F.76948726@space.mit.edu> <3B71C2AA.7E91E5BA@astro.cornell.edu> <269b6343.0108090726.e32298a@posting.google.com>*Reply-To*: "Jim Pendleton" <jimpendleton(at)alumni.northwestern.edu>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:26125

"Bill B." <billb@attinet.com> wrote in message 269b6343.0108090726.e32298a@posting.google.com">news:269b6343.0108090726.e32298a@posting.google.com... > > how can you turn the former into the latter without a loop? This is > > somewhat similar to Pavel's running chunk index problem earlier in the > > year. Finding an answer is not trivial. It would apply directly to > > this problem, where the pairs are adjacent elements in the reverse > > indices vector. Any takers? > > > > I've encountered a few areas where certain logic problems cannot be > solved without a loop in IDL. Usually, this always points to the fact > that there are certain IDL functions that (logically) insist upon > scalar parameters. > > -Bill B. > Okay, here's an effort using two histograms instead of one, just to get some interest going. No visible loops, but not the sort of stuff you put in production code. With this as a head start, let's see the single-histogram approach. A = [-1,3,7,12,15,18,20,20] ;The solution must work with negative and repeating numbers NPair = N_Elements(A)/2 MaxA = Max(A, Min = MinA) D = MaxA - MinA P = Lindgen(NPair)*2 H1 = Histogram(A[P], Max = MaxA, Min = MinA, R = R1) H2 = Histogram(A[P + 1], Max = MaxA, Min = MinA, R = R2) x1 = (R1 - MaxA)[0:D] x2 = (R2 - MaxA)[0:D] C = [A, ((x1 ne x2)*(Lindgen(D + 1) + MinA) > MinA) < MaxA] C = C[Sort(C)] C = C[Uniq(C)] Print, C ; Loop version B = Indgen(NPair)*2 For I = 0L, NPair - 1 Do Print, A[B[I]] + Lindgen(A[B[I] + 1]- A[B[I]] + 1) Extra credit for minimal use of "[]" notation. Jim P.

**References**:**histogram question***From:*Gregory Y. Prigozhin

**Re: histogram question***From:*JD Smith

**Re: histogram question***From:*Bill B.

- Prev by Date:
**Re: Log IDLgrAxis** - Next by Date:
**column labels on table widgets** - Prev by thread:
**Re: histogram question** - Next by thread:
**Re: histogram question** - Index(es):