cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-528892%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E8%A8%88%E7%AE%97%E7%89%B9%E5%AE%9A%E6%95%B8%E5%AD%97%E7%9A%84%E5%88%97%E7%99%BE%E5%88%86%E4%BD%8D%E6%95%B8%E7%9A%84%E5%87%BD%E6%95%B8%E6%98%AF%E4%BB%80%E9%BA%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-528892%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%EF%BC%8C%3C%2FP%3E%3CP%3E%E4%BE%8B%E5%A6%82%EF%BC%8C%E6%88%91%E6%9C%89%E4%B8%80%E5%80%8B%E8%B3%87%E6%96%99%E8%A1%A8%EF%BC%8C%E5%85%B6%E4%B8%AD%E3%80%8CX%E3%80%8D%E5%88%97%E7%9A%84%E5%80%BC%E7%82%BA%E3%80%8C1%2C2%2C3%2C....13%2C14%2C15%E3%80%8D%E3%80%82%3C%2FP%3E%3CP%3E%E6%93%9A%E6%88%91%E6%89%80%E7%9F%A5%EF%BC%8C%E4%BD%BF%E7%94%A8%E5%87%BD%E6%95%B8%20Col%20Quantile(%3AX%2C%200.2)%20%3D%203.2%20%E5%8F%AF%E4%BB%A5%E8%BC%95%E9%AC%86%E8%A8%88%E7%AE%97%2020%25%20%E5%88%86%E4%BD%8D%E6%95%B8%E3%80%82%3C%2FP%3E%3CP%3E%E6%98%AF%E5%90%A6%E6%9C%89%E5%87%BD%E6%95%B8%E5%8F%AF%E4%BB%A5%E8%A8%88%E7%AE%97%E3%80%8CX%E3%80%8D%E5%88%97%E4%B8%AD%E6%95%B8%E5%AD%97%E7%9A%84%E7%99%BE%E5%88%86%E4%BD%8D%E6%95%B8%EF%BC%8C%E4%BE%8B%E5%A6%82%203%EF%BC%9F%3C%2FP%3E%3CP%3E%E5%A6%82%E6%9E%9C%E6%98%AF%E9%80%99%E6%A8%A3%EF%BC%8C%E6%9C%89%E6%B2%92%E6%9C%89%E8%BE%A6%E6%B3%95%E5%9C%A8%E3%80%8C%E8%A1%A8%E6%A0%BC%E6%91%98%E8%A6%81%E3%80%8D%E4%B8%AD%E8%A8%88%E7%AE%97%E5%A4%9A%E5%88%97%EF%BC%9F%3C%2FP%3E%3CP%3E%E8%AC%9D%E8%AC%9D%E4%BD%A0%EF%BC%81%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-528892%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%E9%80%B2%E9%9A%8E%E7%B5%B1%E8%A8%88%E5%BB%BA%E6%A8%A1%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E6%95%B8%E6%93%9A%E6%8E%A2%E7%B4%A2%E5%92%8C%E8%A6%96%E8%A6%BA%E5%8C%96%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3E%E5%A4%A7%E8%A6%8F%E6%A8%A1%E5%AE%A2%E8%A3%BD%E5%8C%96%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-529132%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E8%A8%88%E7%AE%97%E7%89%B9%E5%AE%9A%E6%95%B8%E5%AD%97%E7%9A%84%E5%88%97%E7%99%BE%E5%88%86%E4%BD%8D%E6%95%B8%E7%9A%84%E5%87%BD%E6%95%B8%E6%98%AF%E4%BB%80%E9%BA%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-529132%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%93%B4%E5%B1%95%E6%96%BC%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F14366%22%20target%3D%22_blank%22%3E%40jthi%3C%2FA%3E%E6%83%B3%E6%B3%95%EF%BC%8C%E9%80%99%E6%98%AF%E4%B8%80%E5%80%8B%E6%9C%89%E6%95%88%E7%9A%84%E5%87%BD%E6%95%B8%E3%80%82%E8%AB%8B%E8%A8%98%E4%BD%8F%EF%BC%8C%E5%82%B3%E5%9B%9E%E7%9A%84%E5%80%BC%E9%83%A8%E5%88%86%E7%94%B1%E7%9B%B8%E9%84%B0%E7%B4%AF%E7%A9%8D%E6%A9%9F%E7%8E%87%E4%B9%8B%E9%96%93%E7%9A%84%E7%B7%9A%E6%80%A7%E6%8F%92%E5%80%BC%E7%B5%84%E6%88%90%E3%80%82%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20%0A%2F%2F%20Open%20Data%20Table%3A%20big%20class.jmp%0A%2F%2F%20%E2%86%92%20Data%20Table(%20%22big%20class%22%20)%0AOpen(%20%22%24SAMPLE_DATA%2Fbig%20class.jmp%22%20)%3B%0A%0Aquantile%20Distribution%20%3D%20Function(%20%7Bcol%2C%20value%7D%2C%0A%20%7Bdefaultlocal%7D%2C%20%0A%20%7Bquant%2C%20cumprob%7D%20%3D%20CDF(%20Column(%20col%20)%20%26lt%3B%26lt%3B%20get%20values%20)%3B%0A%20result%20%3D%20Interpolate(%20value%2C%20quant%2C%20cumprob%20)%3B%0A%20Return(%20result%20)%3B%0A)%3B%0A%0Ares%20%3D%20quantile%20distribution(%20%22height%22%2C%2053%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-529101%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E8%A8%88%E7%AE%97%E7%89%B9%E5%AE%9A%E6%95%B8%E5%AD%97%E7%9A%84%E5%88%97%E7%99%BE%E5%88%86%E4%BD%8D%E6%95%B8%E7%9A%84%E5%87%BD%E6%95%B8%E6%98%AF%E4%BB%80%E9%BA%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-529101%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%96%E8%A8%B1%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ECol%20Rank(%3AX)%20%2F%20Col%20Number(%3AX)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E6%88%96%E8%80%85%E4%B9%9F%E8%A8%B1%E4%BD%A0%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%20CDF()%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-529088%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E8%A8%88%E7%AE%97%E7%89%B9%E5%AE%9A%E6%95%B8%E5%AD%97%E7%9A%84%E5%88%97%E7%99%BE%E5%88%86%E4%BD%8D%E6%95%B8%E7%9A%84%E5%87%BD%E6%95%B8%E6%98%AF%E4%BB%80%E9%BA%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-529088%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%97%A8%EF%BC%8C%E7%89%B9%E5%85%8B%E6%96%AF%E5%B0%BC%E7%88%BE%E6%A3%AE%EF%BC%9A%3C%2FP%3E%3CP%3E%E6%84%9F%E8%AC%9D%E6%82%A8%E7%9A%84%E5%9B%9E%E8%A6%86%EF%BC%81%3C%2FP%3E%3CP%3E%E6%88%91%E4%B8%8D%E6%98%AF%E7%B5%B1%E8%A8%88%E5%AD%B8%E5%AE%B6%EF%BC%8C%E4%BD%86%E6%83%B3%E7%9F%A5%E9%81%93%E6%98%AF%E5%90%A6%E6%9C%89%E6%96%B9%E6%B3%95%E5%8F%AF%E4%BB%A5%E8%A8%88%E7%AE%97%E4%B8%8D%E9%99%90%E6%96%BC%E5%B8%B8%E6%85%8B%E5%88%86%E4%BD%88%E7%9A%84%E8%B3%87%E6%96%99%E3%80%82%3C%2FP%3E%3CP%3E%E6%88%91%E7%9C%9F%E6%AD%A3%E6%83%B3%E8%A6%81%E7%9A%84%E6%98%AF%E4%B8%80%E5%80%8B%E5%B0%8D%E3%80%8CCol%20Quantile%20(%3AX%2C%200.2)--%26gt%3B%203.2%E3%80%8D%E9%80%B2%E8%A1%8C%E5%8F%8D%E5%90%91%E8%A8%88%E7%AE%97%E7%9A%84%E5%87%BD%E6%95%B8%EF%BC%8C%E6%84%8F%E6%80%9D%E6%98%AF%20f(%3AX%2C%203.2)--%26gt%3B%2020%25%E3%80%82%20%E6%88%96%E6%95%B8%E5%AD%B8%E4%B8%8A%20N%20%E8%A1%8C%EF%BC%88%E5%85%B6%E4%B8%AD%20(%3AX%26lt%3B0.32)%20%EF%BC%89%2FN%20%E8%A1%8C(%3AX)%E3%80%82%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-528942%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E8%A6%86%EF%BC%9A%E8%A8%88%E7%AE%97%E7%89%B9%E5%AE%9A%E6%95%B8%E5%AD%97%E7%9A%84%E5%88%97%E7%99%BE%E5%88%86%E4%BD%8D%E6%95%B8%E7%9A%84%E5%87%BD%E6%95%B8%E6%98%AF%E4%BB%80%E9%BA%BC%EF%BC%9F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-528942%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E4%BB%A5%E4%B8%8B%E6%98%AF%E5%B8%B8%E6%85%8B%E5%88%86%E4%BD%88%E5%87%BD%E6%95%B8%E8%85%B3%E6%9C%AC%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84%E6%A2%9D%E7%9B%AE%EF%BC%8C%E8%A9%B2%E5%87%BD%E6%95%B8%E5%82%B3%E5%9B%9E%E7%B5%A6%E5%AE%9A%E5%80%BC%EF%BC%88%E5%85%B7%E6%9C%89%E7%B5%A6%E5%AE%9A%20mu%20%E5%92%8C%20sigma%EF%BC%89%E7%9A%84%E6%A9%9F%E7%8E%87%E3%80%82%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22txnelson_0-1659372520553.png%22%20style%3D%22width%3A%20635px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22txnelson_0-1659372520553.png%22%20style%3D%22width%3A%20635px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22txnelson_0-1659372520553.png%22%20style%3D%22width%3A%20635px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F44445iBB3C06BF15E5A720%2Fimage-dimensions%2F635x560%3Fv%3Dv2%22%20width%3D%22635%22%20height%3D%22560%22%20role%3D%22button%22%20title%3D%22txnelson_0-1659372520553.png%22%20alt%3D%22txnelson_0-1659372520553.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E6%89%80%E4%BB%A5%E5%A6%82%E6%9E%9C%E6%88%91%E6%AD%A3%E7%A2%BA%E7%90%86%E8%A7%A3%E4%BD%A0%E7%9A%84%E5%95%8F%E9%A1%8C%EF%BC%8C%E4%BD%A0%E6%9C%83%E6%8C%87%E5%AE%9A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ep%3Dnormal%20distribution(3%2C%20col%20mean(%3Ax)%2C%20col%20stddev(%3Ax)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar

What is the function to calculate the column percentile of a specific number?

Hi,

As an example, I have a data table with column "X" with values "1,2,3,....13, 14, 15". 

I understand it is easy to calculate the 20% quantile using function: Col Quantile(:X, 0.2) = 3.2.

Is there a function to calculate the percentile of a number in this column "X", for example 3?

If so, is there a way to calculate it in the "Table Summary" for multiple columns?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: What is the function to calculate the column percentile of a specific number?

Expanding on @jthi idea, here is a function that works.  Remember, the value returned is partially made up from a linear interpolation between the adjacent cumulative probabilities.

Names Default To Here( 1 );
dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );

quantile Distribution = Function( {col, value},
	{defaultlocal}, 
	{quant, cumprob} = CDF( Column( col ) << get values );
	result = Interpolate( value, quant, cumprob );
	Return( result );
);

res = quantile distribution( "height", 53 );
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: What is the function to calculate the column percentile of a specific number?

Here is the entry from the Scripting Index for the Normal Distribution function which returns the probability for a given value, with a given mu and sigma.

txnelson_0-1659372520553.png

So if I am understanding your question correctly, you would specify

p=normal distribution(3, col mean(:x), col stddev(:x) );
Jim

Re: What is the function to calculate the column percentile of a specific number?

Hi, txnelson:

Thanks for your reply!

I am not a statistician, but wonder if there is way to calculate it for data which is not limited to normal distribution.

What I was really looking for is a function doing the reverse calculation of "Col Quantile (:X, 0.2)--> 3.2", meaning f(:X, 3.2)--> 20%. Or mathematically N rows ( where (:X<0.32) ) / N rows(:X).     

jthi
Super User

Re: What is the function to calculate the column percentile of a specific number?

Maybe

Col Rank(:X) / Col Number(:X)

or maybe you could use CDF()

-Jarmo
txnelson
Super User

Re: What is the function to calculate the column percentile of a specific number?

Expanding on @jthi idea, here is a function that works.  Remember, the value returned is partially made up from a linear interpolation between the adjacent cumulative probabilities.

Names Default To Here( 1 );
dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );

quantile Distribution = Function( {col, value},
	{defaultlocal}, 
	{quant, cumprob} = CDF( Column( col ) << get values );
	result = Interpolate( value, quant, cumprob );
	Return( result );
);

res = quantile distribution( "height", 53 );
Jim

Recommended Articles