#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John
 
Posts: n/a
Default solver

Find c and smallest n that satisfy the constraints

binomdist(c,n,p1,true)=1-alpha
binomdist(c,n,p2,true)<=beta

For the case p1=.001, p2=.002, alpha=.05, beta=.05, solver found the
solution

c=23, n=16288

Solver could not find the solution for the case p1=.01, p2=.05,
alpha=.05, beta=.10.

The solution, found by trial and error, is c=3, n=110.

Is this an idiosyncrasy of solver, or am I doing something wrong?

John Adams

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dana DeLouis
 
Posts: n/a
Default solver

Find c and smallest n that satisfy the constraints
c=23, n=16288


Hi John. I found this to be a hard one, even for a math program. I tried a
few optional evaluation methods, but still no luck.
Actually, I'm surprised that Solver even worked at all on a problem like
this.
Just messing around, I see that alpha & beta are the same. I tried plotting
both functions. Since .05 & .95 are far apart, I switched the first
equation around:

1 - binomdist(c,n,p1,true)<=beta
binomdist(c,n,p2,true)<=beta

With c=22, a plot showed that there is a very tiny corner that satisfies
both equations.
I show that c=22, and n = 15703 is a solution with the smallest n.
Again, this is done graphically, and not with a mathematical solution.

As a side note, the math program's function is:

CDF[BinomialDistribution[n,1/1000],c]
or...
BetaRegularized[999/1000,n-Floor[c],1+Floor[c]]

If Excel's "binomdist" function is also rounding down 'c, then this could be
the reason Solver doesn't work well. Solver doesn't work well at all if it
is using discontinuous functions.
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"John" wrote in message
ps.com...
Find c and smallest n that satisfy the constraints

binomdist(c,n,p1,true)=1-alpha
binomdist(c,n,p2,true)<=beta

For the case p1=.001, p2=.002, alpha=.05, beta=.05, solver found the
solution

c=23, n=16288

Solver could not find the solution for the case p1=.01, p2=.05,
alpha=.05, beta=.10.

The solution, found by trial and error, is c=3, n=110.

Is this an idiosyncrasy of solver, or am I doing something wrong?

John Adams



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Jerry W. Lewis
 
Posts: n/a
Default solver

c=CRITBINOM(n,p1,1-alpha)
so you only need to find the smallest n such that
binomdist(c,n,p2,true)<=beta
This is a problem that Solver can easily solve.

Jerry

"John" wrote:

Find c and smallest n that satisfy the constraints

binomdist(c,n,p1,true)=1-alpha
binomdist(c,n,p2,true)<=beta

For the case p1=.001, p2=.002, alpha=.05, beta=.05, solver found the
solution

c=23, n=16288

Solver could not find the solution for the case p1=.01, p2=.05,
alpha=.05, beta=.10.

The solution, found by trial and error, is c=3, n=110.

Is this an idiosyncrasy of solver, or am I doing something wrong?

John Adams


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John
 
Posts: n/a
Default solver

Dana,

Thank you for your helpful comments. I am looking for a solution, and a
graphical solution that works is perfectly acceptable. Do you mind
telling me what you plotted?

John Adams

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dana DeLouis
 
Posts: n/a
Default solver

Hi. I made some quick charts. However, I will not be able to post them as
the file size is about 100k.
Let me know, and I will email them to you. I put them into PDF format to
make it easier.

For the second problem:

Solver could not find the solution for the case
p1=.01, p2=.05,alpha=.05, beta=.10.
The solution, found by trial and error,
is c=3, n=110.


I show this to be an invalid solution with the second equation.
I "think" that c=3 is correct, but the valid range of n
is 132 to 137. Do you show n=110 to be correct?
Anyway, let me know and I'll be glad to send it to you.

As a side note, the reason Solver will not work with this is due to
"BINOMDIST" function being a discontinuous function.
What I mean is that for example...Solver tries n=100.1
=BINOMDIST(3, 100.1, 0.01, TRUE)
The answer is 0.9816
Next, Solver will try n=100.9

=BINOMDIST(3, 100.9, 0.01, TRUE)
The answer is the same! 0.9816

Because Solver changed n, and the output did not change, Solver does not
know how to proceed to the next guess. Solver is not very sophisticated,
and quickly gives up.

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003

"John" wrote in message
ups.com...
Dana,

Thank you for your helpful comments. I am looking for a solution, and a
graphical solution that works is perfectly acceptable. Do you mind
telling me what you plotted?

John Adams





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default solver


John wrote:
Dana,

Thank you for your helpful comments. I am looking for a solution, and a
graphical solution that works is perfectly acceptable. Do you mind
telling me what you plotted?

John Adams


Here's a simple non-graphical method of solving the problem

If you start with cguess = 0

and calculate

nguess = comp_crit_negbinomial(p2,cguess+1,beta)+cguess+1

and

cguess = comp_crit_binomial(nguess,p1,alpha)

iteratively until the new value of cguess does not change, you will
have solved the problem.


At each stage nguess is the smallest sample size such that
binomdist(cguess,nguess,p2,true) <= beta
and cguess is the smallest value such that
binomdist(cguess,nguess,p1,true) = 1 - alpha.

comp_crit_binomial(nguess,p1,alpha) is essentially
CRITBINOM(nguess,p1,1-alpha). Unfortunately, there is no critical value
function for the negative binomial in Excel.

You can find both comp_crit_negbinomial and comp_crit_binomial in the
spreadsheet http://members.aol.com/iandjmsmith/Examples.xls and the VBA
code itself can be found at
http://members.aol.com/iandjmsmith/Examples.txt should you wish to add
your own function to do this calculation. Of course, you can improve on
0 as an initial guess for c by using normal approximations...

In the two examples you give, the solutions agree with Dana's graphical
solutions. The graphical solution may still be preferable if the
purpose of the exercise is to show people how to solve the problem.

Ian Smith

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John
 
Posts: n/a
Default solver

Dana,

There was a typo in my first post. The value of p2 should have been .06
instead of .05. The solution n=110, c=3 works when p2=.06.

You can send the graphs to .

Thank you.

John Adams

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver does not work from Macros mjd918 Setting up and Configuration of Excel 1 January 6th 06 04:15 PM
Interesting Solver problem (Solver encounters an error) MrShorty Excel Discussion (Misc queries) 3 December 22nd 05 10:52 PM
Excel Solver Issue nakedbamboo Excel Discussion (Misc queries) 5 November 14th 05 01:26 AM
Trouble with Solver Wanderingspirit99 Excel Discussion (Misc queries) 0 September 12th 05 03:50 PM
Using Solver with VBA EggShell Excel Discussion (Misc queries) 2 August 22nd 05 07:06 AM


All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"