Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Quantile of Negative Binomial and Hypergeometric distributions

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 10, 2018 2:39 AM
(3884 views)

Hi All,

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

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@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 BinomialQuantileandHypergeometric Quantilefunctions in JMP.Please notify if you know how to calculate

Quantilefor 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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@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 BinomialQuantileandHypergeometric Quantilefunctions in JMP.Please notify if you know how to calculate

Quantilefor 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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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++
);
);
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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