+ Reply to Thread
Results 1 to 5 of 5

Formula for binomial threshold values

  1. #1
    Registered User
    Join Date
    06-04-2020
    Location
    Location
    MS-Off Ver
    365
    Posts
    3

    Formula for binomial threshold values

    I am looking for an Excel formula that solves the problem: for a given binomial distribution B(n, p) find all values for which B(n, p) < p₀ where p₀ ≤ p. The problem naturally reduces to finding only two threshold values for which B(n, p) values are the highest but no greater than p₀.

    binomial.jpg

    Here is an example of solving the problem manually. Suppose we have B(790, 0.117), i.e. the binomial distribution with 790 trials and 11.7% success probability, and p₀ = 0.02. So the goal is to find every number from 0 through 790 for which the distribution is no greater than 0.02.

    Cycling through X values from 0 through 790 with the formula =BINOM.DIST(X, 790, 0.117, FALSE), we find the threshold values 80 (on the left of the peak) and 104 (on the right). That is, for every X lesser than 80 or greater than 104 the distribution will also be no greater than 0.02.

    I failed to construct an Excel formula that can provide the same result instead of manual cycling through. If you can suggest such a formula, please test it with my example before posting answer to this question.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,858

    Re: Formula for binomial threshold values

    You haven't shared what you have tried, so I am not sure what process(es) you were trying to use. To my knowledge, there is not a convenient "inverse binomial PDF" function, though there is the BINOM.INV() function that returns the inverse of the binomial CDF.

    Are you required to come up with a formula only solution? For a function like this without a convenient inverse, I usual start by using goal seek or Solver (I usually prefer Solver because it is more robust). Set up your forward calculation (=BINOM.DIST(X, 790, 0.117, FALSE) where X refers to a cell with your best first guess at the solution), then call Solver and tell it to set the formula cell to a value of 0.02 by changing the X cell. Repeat with a different starting guess on the other side of the distribution to find the other solution.

    Will something like that work for you, or are you prohibited from using Solver/Goal Seek for this problem?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    06-04-2020
    Location
    Location
    MS-Off Ver
    365
    Posts
    3

    Re: Formula for binomial threshold values

    Using Solver for every problem of this type is even more cumbersome than my brute-force method. Suppose I have not the single problem, but dozens of problems of this type. If I will solve each one manually, I never get my work done. So I look for a formula where I can input n, p and p₀ and instantly get two numbers (or some kind of error, if these numbers can’t be computed—e.g. if p₀ > p).

    I tried to experiment with BINOM.INV(), but I never got anything even close to the right solution with this function.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,858

    Re: Formula for binomial threshold values

    I tried to experiment with BINOM.INV(), but I never got anything even close to the right solution with this function.
    As I said, that is because BINOM.INV() is inverting the cumulative distribution function, not the probability density function. If you know what your target values for the PDF translate to on the CDF, then you can easily use BINOM.INV(). I don't know how to translate the PDF to CDF in a case like this, so I don't know how doable that approach would be.

    My solution to the "I could use Solver but I don't want to use Solver" scenario is to program my own "root-finding" algorithm. I have a tutorial here: https://www.excelforum.com/tips-and-...ind-roots.html The main first question is whether to do it purely in the spreadsheet (with iteration enabled) as shown in the first several examples. The final example (post #9) shows how this might be done in a VBA user-defined function.

    How do you want to proceed?

  5. #5
    Registered User
    Join Date
    06-04-2020
    Location
    Location
    MS-Off Ver
    365
    Posts
    3

    Re: Formula for binomial threshold values

    Seems I found the solution.

    Let n be the number of trials, π₀ be the reference probability. (I denote it with π to avoid confusing with p-value that will be mentioned later.) Let p₀ be the threshold probability from my original post. Then a dynamic array of all values for which the distribution is no greater than p₀ can be generated by the formula
    Please Login or Register  to view this content.
    This works with Excel versions that support dynamic arrays and corresponding functions like FILTER and SEQUENCE.

    But finding these values was not an end in itself for me; this was in fact needed to calculate an exact binomial p-value for two-sided proportion test: k is the observed number of successes, π = k/n is the sample proportion, and the hypotheses are:

    • H₀: π = π
    • H₁: ππ

    So the p-value for this test can be calculated by the formula shown at this screenshot, and the corresponding Excel file is also attached.

    binomial_p-value.png
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Finding peak values above a certain threshold
    By Yukon-1 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-16-2019, 05:08 PM
  2. Replies: 1
    Last Post: 11-30-2016, 08:02 PM
  3. Inserting row of values for k into the binomial dist. function
    By Ernst88 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-15-2014, 11:58 AM
  4. Threshold values from graph or data
    By mondoyle in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-19-2014, 05:17 AM
  5. [SOLVED] Changing values to 0, 1, 2 or 3 based on certain threshold values
    By Baruch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2013, 11:55 PM
  6. Setting threshold to assign real values to class values
    By themoss1985 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2011, 11:50 PM
  7. [SOLVED] [SOLVED] How to Manipulate formula for Binomial Distribution
    By GH in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-22-2006, 11:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1