comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Number of points inside a contour curve
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Number of points inside a contour curve [message #51944] Wed, 20 December 2006 06:58 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
burkina writes:

> What I need to do is basically simple, I guess, but I can't find an
> easy way to do that.
> I have an array of two parameters, let's call them x and y, each pair a
> couple of measures taken simultaneously. I need to:
>
> -Plot them in the x and y axis (at least this one is trivial!)
>
> -Produce a density plot, i.e. divide the x-y space in discrete bins and
> assign the number of points falling in each bin to that bin (This
> should be done by hist_2D, but the results are fairly disappointing. A
> better work is done by histogram_2d. Do you have any comments?)

I note that HISTOGRAM_2D uses embedded FOR loops and that HIST_2D
is written by JD Smith. That's enough for me. :-)


> -Plot confidence contour levels on that density plot, i.e. a contour at
> the level where, say, 90% of points are contained. In other words, you
> can use the normal contour IDL procedure, but you must find a way to
> count all points lying inside this contour, in order to set the level
> for the contour plot. The procedure should be able to find the
> iso-count curve which encompass 90% of the total points.
>
> So... I'm not sure I'm doing the right/best thing for point 2
> (hist_2d/histogram_2d) and have no idea how to do point 3. However,
> this problem seems to me quite common, because it's a way to find
> statistical confidence level for a distribution of two parameters.

If you did a HISTOGRAM on the result of HIST_2D, then I should
think you could find the level where a cumulative total of
the HISTOGRAM result was 90% of the total (VALUE_LOCATE
might be handy here). I'm mostly thinking out loud. There
seem to be a few details missing here....But I think this
might be a promising direction. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Number of points inside a contour curve [message #52031 is a reply to message #51944] Thu, 21 December 2006 07:38 Go to previous messageGo to next message
burkina is currently offline  burkina
Messages: 32
Registered: February 2005
Member
On Dec 20, 3:58 pm, David Fanning <n...@dfanning.com> wrote:
> I note that HISTOGRAM_2D uses embedded FOR loops and that HIST_2D
> is written by JD Smith. That's enough for me. :-)

Ok, I'm using hist_2d. The results are similar, I was wrong...

> If you did a HISTOGRAM on the result of HIST_2D, then I should
> think you could find the level where a cumulative total of
> the HISTOGRAM result was 90% of the total (VALUE_LOCATE
> might be handy here). I'm mostly thinking out loud. There
> seem to be a few details missing here....But I think this
> might be a promising direction. :-)

Indeed, your suggestion to use histogram was good. However, I don't
need VALUE_LOCATE. This is how I solved the problem:

;density is the result from HIST_2D

maxvalue=max(density,maxpoint)
maxcoord=ARRAY_INDICES(density,maxpoint)
max_x=xmin+maxcoord[0]*xbinsize+xbinsize/2
max_y=ymin+maxcoord[1]*ybinsize+ybinsize/2
print, 'The maximum density is: ', maxvalue
print, 'It occurs at coordinates:'
print, max_x, max_y

tot_histo=total(density)
histoden=histogram(density)
n_histo=n_elements(histoden)
sum=0
k=0

while sum lt 0.9*tot_histo do begin

sum = sum + histoden[n_histo-1-k] * (maxvalue-k)
k = k+1

endwhile

maxlevel=histoden[n_histo-1-k] * (maxvalue-k)

contour, density, xabscissa,yabscissa,c_colors=fsc_color('red'),
levels=maxlevel, /overplot
xyouts, max_x, max_y, '+', /data, color=fsc_color('red')


Stefano
Re: Number of points inside a contour curve [message #52078 is a reply to message #51944] Fri, 29 December 2006 14:20 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 20 Dec 2006 07:58:37 -0700, David Fanning wrote:

> burkina writes:
>
>> What I need to do is basically simple, I guess, but I can't find an
>> easy way to do that.
>> I have an array of two parameters, let's call them x and y, each pair a
>> couple of measures taken simultaneously. I need to:
>>
>> -Plot them in the x and y axis (at least this one is trivial!)
>>
>> -Produce a density plot, i.e. divide the x-y space in discrete bins and
>> assign the number of points falling in each bin to that bin (This
>> should be done by hist_2D, but the results are fairly disappointing. A
>> better work is done by histogram_2d. Do you have any comments?)
>
> I note that HISTOGRAM_2D uses embedded FOR loops and that HIST_2D
> is written by JD Smith. That's enough for me. :-)

For the record, the one I wrote was HIST_ND for any dimension (not just
2). I use it even in 2D, since it lets me have access to reverse indices,
etc.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: New Eclipse-based IDE
Next Topic: Re: ENVI: procedure to get X, Y of pixel in displayed image

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:42:38 PDT 2025

Total time taken to generate the page: 0.00541 seconds