Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Simone1
Level III

Distributions and Curves Intersection

Dear Community I have a need to be solved (I do not found similar question in blog).

 

I have 2 set of data.

I created the 2 distributions.

I "aks to JMP" to found the better curve fit for each single distribution.

Now I need to found the intersetion point (X= ...) between the 2 curves.

In attachement you can find the example of dataset and the visualization of what I need.

Thanks in advance for your feedback.

Best Regards.

Simone

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
txnelson
Super User

Re: Distributions and Curves Intersection

Here is a crude script that will get you the values.  Not sure it will work for all comparisons...but it might.  Try it out.  The results display in the log.

Names Default To Here( 1 );
dt = Current Data Table();

// Change these values to the actual values of the 2 distributions
m1 = 203.315;
s1 = 203.33 - m1;
max1 = 203.37;
m2 = 203.345;
s2 = 203.355 - m2;
max2 = 203.4;

If( Normal Density( min(m1,m2), mu = m1, sigma = s1 ) > Normal Density( min(m1,m2), mu = m2, sigma = s2 ),
	mh = m1;
	sh = s1;
	ml = m2;
	sl = s2;
,
	mh = m2;
	sh = s2;
	ml = m1;
	sl = s1;
);

For( i = ml, i <= Min( max1, max2 ), i = i + ((Min( max1, max2 ) - ml) / 1000000),
	r = i;
	nd1 = Normal Density( r, mu = mh, sigma = sh );
	nd2 = Normal Density( r, mu = ml, sigma = sl );
	lastnd1 = nd1;
	lastnd2 = nd2;
	lasti = i;
	If( nd2 > nd1,
		x = Mean( i, lasti ); y = Mean( nd1, nd2, lastnd1, lastnd2 );
		show(x,y) ;
		Break();
	);
);
Jim

View solution in original post

Highlighted
ian_jmp
Staff

Re: Distributions and Curves Intersection

Once you have the formula columns saved (in this case for two Gaussians), you can get a long way by using the crosshair tool.

 

But if you want an 'exact' answer, you could define an auxiliary formula column and use 'Maximize Desirability' in the Profiler (see the attached table). But note that you still need to inspect the plots, and use the Response Limits column property to restrict the range of the optimization appropriately. In this example, I also used this property with the two original columns (with a weight of zero) just to allow all three columns to be profiled at the same time.

 

Before:

Screenshot 2020-04-28 at 10.36.37.png

 

After:

Screenshot 2020-04-28 at 10.36.58.png

View solution in original post

6 REPLIES 6
Highlighted

Re: Distributions and Curves Intersection

I believe that there is no direct way. That is to say, there is no platform with this capability. You could use the Minimize() function with the difference between the two probability density functions using their respective estimated distribution parameters in a script. The independent variable is the quantile.

 

Please provide data and examples in JMP files, not Excel files in the future.

Learn it once, use it forever!
Highlighted
Simone1
Level III

Re: Distributions and Curves Intersection

Dear Mark,

thank you for the feedback.

I "hoped" there was some capability to do this in JMP...

Regarding you suggestion... I will try to follow it (even if I'm not an expert in the JMP Script).

 

Have you a good day.

Best Regards,

Simone

Highlighted
ian_jmp
Staff

Re: Distributions and Curves Intersection

Once you have the formula columns saved (in this case for two Gaussians), you can get a long way by using the crosshair tool.

 

But if you want an 'exact' answer, you could define an auxiliary formula column and use 'Maximize Desirability' in the Profiler (see the attached table). But note that you still need to inspect the plots, and use the Response Limits column property to restrict the range of the optimization appropriately. In this example, I also used this property with the two original columns (with a weight of zero) just to allow all three columns to be profiled at the same time.

 

Before:

Screenshot 2020-04-28 at 10.36.37.png

 

After:

Screenshot 2020-04-28 at 10.36.58.png

View solution in original post

Highlighted
Simone1
Level III

Re: Distributions and Curves Intersection

Thanks Ian.

Appreciated your good feedback.

Best Regards,

Simone

Highlighted
txnelson
Super User

Re: Distributions and Curves Intersection

Here is a crude script that will get you the values.  Not sure it will work for all comparisons...but it might.  Try it out.  The results display in the log.

Names Default To Here( 1 );
dt = Current Data Table();

// Change these values to the actual values of the 2 distributions
m1 = 203.315;
s1 = 203.33 - m1;
max1 = 203.37;
m2 = 203.345;
s2 = 203.355 - m2;
max2 = 203.4;

If( Normal Density( min(m1,m2), mu = m1, sigma = s1 ) > Normal Density( min(m1,m2), mu = m2, sigma = s2 ),
	mh = m1;
	sh = s1;
	ml = m2;
	sl = s2;
,
	mh = m2;
	sh = s2;
	ml = m1;
	sl = s1;
);

For( i = ml, i <= Min( max1, max2 ), i = i + ((Min( max1, max2 ) - ml) / 1000000),
	r = i;
	nd1 = Normal Density( r, mu = mh, sigma = sh );
	nd2 = Normal Density( r, mu = ml, sigma = sl );
	lastnd1 = nd1;
	lastnd2 = nd2;
	lasti = i;
	If( nd2 > nd1,
		x = Mean( i, lasti ); y = Mean( nd1, nd2, lastnd1, lastnd2 );
		show(x,y) ;
		Break();
	);
);
Jim

View solution in original post

Highlighted
Simone1
Level III

Re: Distributions and Curves Intersection

Hello Jim,

thanks for the feedback.

I will apply it!

Best Regards,

Simone

Article Labels

    There are no labels assigned to this post.