BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
ptolomey

Community Trekker

Joined:

May 26, 2017

Quantile of Negative Binomial and Hypergeometric distributions

Hi All,

Is there way to get quantile of Negative Binomial and Hypergeometric distributions?

 

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
cwillden

Super User

Joined:

May 1, 2017

Solution

Re: Quantile of Negative Binomial and Hypergeometric distributions


@ptolomey wrote:

Hi cwillden,

Thank you for reply.

I bag your pardon for not emphasizing in previous post, that I am interested in finding Negative Binomial Quantile and Hypergeometric Quantile functions in JMP.

Please notify if you know how to calculate Quantile for these descrete distributions.

 

Thanks.


So, you want the inverse of the CDF then, correct?  You want a function where you input a quantile and the distributional parameters and the function returns a value of the random variable that corresponds to the specified quantile?  The functions I suggested are the CDF and take a value for the random variable and return the quantile.  Just want to make sure we're on the same page.

If so, I don't believe there are built-in functions in JMP, and that may be because they would be a step function if the distribution is discrete. You could write your own quantile functions using loops to find the smallest value of your random variable that is greater than the desired quantile.

 

For example:

Hypergeometric Quantile = function({quantile, N_pop, K, n_samp},
	x=0;
	condition = 0;
	while(!condition,
		If(
			Hypergeometric Distribution(N_pop, K, N_samp, x) >= quantile,
			condition = 1,
			x++
		);
	);
	x
);

Hypergeometric Quantile(0.5, 100, 20, 10); //returns the value 2

 

-- Cameron Willden
ptolomey

Community Trekker

Joined:

May 26, 2017

Solution

Re: Quantile of Negative Binomial and Hypergeometric distributions

Hi cwillden,

Thank you for elegant solution.

There is just one comment to it.

The loop provided by you will return integer random variable + 1 instead integer random variable.

The corrected loop is:

while(1,
	if(
		Hypergeometric Distribution(N_pop, K, N_samp, x) >= quantile,
		Break(),
		x++
	);
      );

 

6 REPLIES 6
cwillden

Super User

Joined:

May 1, 2017

Re: Quantile of Negative Binomial and Hypergeometric distributions

Yes!  There are functions for both of those distributions.  Check out Hypergeometric Distribution() and Neg Binomial Distribution().  For the PMF, check out Hypergeometric Probability and Neg Binomial Probability()

Example of Hypergeometric Distribution:

N_pop=100;
K=20;
n_samp = 10;
x=4;

Hypergeometric Distribution(N_pop,K,n_samp,x);

Example of Neg Binomial Distribution:

p = 0.5; //prob. of success
n = 10; //number of succeses
x = 5;

Neg Binomial Distribution(p, n, x);
-- Cameron Willden
txnelson

Super User

Joined:

Jun 22, 2012

Re: Quantile of Negative Binomial and Hypergeometric distributions

Just to add to @cwillden comment, all such functions are easily found in the Scripting Index

     Help>Scripting Index

One needs to learn to go to this documentation as the first stop for such questions.

Jim
ptolomey

Community Trekker

Joined:

May 26, 2017

Re: Quantile of Negative Binomial and Hypergeometric distributions

Hi cwillden,

Thank you for reply.

I bag your pardon for not emphasizing in previous post, that I am interested in finding Negative Binomial Quantile and Hypergeometric Quantile functions in JMP.

Please notify if you know how to calculate Quantile for these descrete distributions.

 

Thanks.

cwillden

Super User

Joined:

May 1, 2017

Solution

Re: Quantile of Negative Binomial and Hypergeometric distributions


@ptolomey wrote:

Hi cwillden,

Thank you for reply.

I bag your pardon for not emphasizing in previous post, that I am interested in finding Negative Binomial Quantile and Hypergeometric Quantile functions in JMP.

Please notify if you know how to calculate Quantile for these descrete distributions.

 

Thanks.


So, you want the inverse of the CDF then, correct?  You want a function where you input a quantile and the distributional parameters and the function returns a value of the random variable that corresponds to the specified quantile?  The functions I suggested are the CDF and take a value for the random variable and return the quantile.  Just want to make sure we're on the same page.

If so, I don't believe there are built-in functions in JMP, and that may be because they would be a step function if the distribution is discrete. You could write your own quantile functions using loops to find the smallest value of your random variable that is greater than the desired quantile.

 

For example:

Hypergeometric Quantile = function({quantile, N_pop, K, n_samp},
	x=0;
	condition = 0;
	while(!condition,
		If(
			Hypergeometric Distribution(N_pop, K, N_samp, x) >= quantile,
			condition = 1,
			x++
		);
	);
	x
);

Hypergeometric Quantile(0.5, 100, 20, 10); //returns the value 2

 

-- Cameron Willden
ptolomey

Community Trekker

Joined:

May 26, 2017

Solution

Re: Quantile of Negative Binomial and Hypergeometric distributions

Hi cwillden,

Thank you for elegant solution.

There is just one comment to it.

The loop provided by you will return integer random variable + 1 instead integer random variable.

The corrected loop is:

while(1,
	if(
		Hypergeometric Distribution(N_pop, K, N_samp, x) >= quantile,
		Break(),
		x++
	);
      );

 

cwillden

Super User

Joined:

May 1, 2017

Re: Quantile of Negative Binomial and Hypergeometric distributions

Hi @ptolomey,

I think the loops are actually equivalent.  If the condition is met, x++ is never evaluated again and the loop will break when it returns to check the While condition again.  I tested both versions and they return the same values.  Although, I think using break() in the while loop is probably preferable to what I did.

-- Cameron Willden