PC Review


Reply
Thread Tools Rate Thread

What is the Biggest number I can have in Access ?

 
 
Michael Hudston
Guest
Posts: n/a
 
      11th Mar 2009
I have written this VBA Script to basically calculate the number of spares
based on the Poisson Culumative Distribution. However after a while it
breaks down as the variable FCT goes into overflow. - The number hits in the
region of 1.17E+254 I know this is a massive number but then that is
indicitive of the equation as in theory it could go to infinity

I am wondering what my next step is, and if there is a solution or not.

The Function I have written is below, and as a guide the following set of
values can be used (the first set works, the second doesnt)

1st Set

Probability = 0.9
Lambda = 156.967232876712

2nd Set

Probability = 0.9
Lambda = 131.205435114504
..

Code

Public Function InvPoisson(ByVal Probability As Double, ByVal Lambda As
Double) As Long

' This function is designed to return the number of spares required when
fed with the Availiability, and Mean.
' Written By Michael J Hudston

' Ensure all figures are reset before we start

Dim Fct As Double

Count_A = 1
Complete = 0
Prob = 0
SumProb = 0
Fct = 1
StockOutRisk = 1 - Probability
i = 0
InvPoisson = 0

' Now do the majical maths stuff

Do

' Set the Start point for the Culumative Probability Calculation for
this run.

SumProb = 0
Fct = 1

' Carry out the Culumative Probability Caculation for this run.

For i = 0 To Count_A

' Do stuff for the Factorial.

If i = 0 Then
Fct = 1
Else
Fct = Fct * i
End If

Prob = (Exp(-1 * Lambda) * Lambda ^ i) / Fct
SumProb = SumProb + Prob

Next

' If the Culumative Probability is greater than 1 - the Stock Out
Risk then you dont need to continue
' so set the complete flag

If Complete = 0 Then
If SumProb > 1 - StockOutRisk Then
InvPoisson = Count_A
Complete = 1
Else
' Otherwise add one to the spares count and run the
Culumative calculation again.
Count_A = Count_A + 1
End If

End If

Loop Until Complete = 1

' Repeat the loop until the complete flag has been set
' (Ie 1 - Stock Out Risk is less than the Culumative Probability.

End Function

 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      11th Mar 2009
On Wed, 11 Mar 2009 01:14:01 -0700, Michael Hudston
<(E-Mail Removed)> wrote:

It's in the help file, under "double data type". On the high side
approx 10^304

-Tom.
Microsoft Access MVP


>I have written this VBA Script to basically calculate the number of spares
>based on the Poisson Culumative Distribution. However after a while it
>breaks down as the variable FCT goes into overflow. - The number hits in the
>region of 1.17E+254 I know this is a massive number but then that is
>indicitive of the equation as in theory it could go to infinity
>
>I am wondering what my next step is, and if there is a solution or not.
>
>The Function I have written is below, and as a guide the following set of
>values can be used (the first set works, the second doesnt)
>
>1st Set
>
>Probability = 0.9
>Lambda = 156.967232876712
>
>2nd Set
>
>Probability = 0.9
>Lambda = 131.205435114504
>.
>
>Code
>
>Public Function InvPoisson(ByVal Probability As Double, ByVal Lambda As
>Double) As Long
>
> ' This function is designed to return the number of spares required when
>fed with the Availiability, and Mean.
> ' Written By Michael J Hudston
>
> ' Ensure all figures are reset before we start
>
> Dim Fct As Double
>
> Count_A = 1
> Complete = 0
> Prob = 0
> SumProb = 0
> Fct = 1
> StockOutRisk = 1 - Probability
> i = 0
> InvPoisson = 0
>
>' Now do the majical maths stuff
>
> Do
>
> ' Set the Start point for the Culumative Probability Calculation for
>this run.
>
> SumProb = 0
> Fct = 1
>
> ' Carry out the Culumative Probability Caculation for this run.
>
> For i = 0 To Count_A
>
> ' Do stuff for the Factorial.
>
> If i = 0 Then
> Fct = 1
> Else
> Fct = Fct * i
> End If
>
> Prob = (Exp(-1 * Lambda) * Lambda ^ i) / Fct
> SumProb = SumProb + Prob
>
> Next
>
> ' If the Culumative Probability is greater than 1 - the Stock Out
>Risk then you dont need to continue
> ' so set the complete flag
>
> If Complete = 0 Then
> If SumProb > 1 - StockOutRisk Then
> InvPoisson = Count_A
> Complete = 1
> Else
> ' Otherwise add one to the spares count and run the
>Culumative calculation again.
> Count_A = Count_A + 1
> End If
>
> End If
>
> Loop Until Complete = 1
>
> ' Repeat the loop until the complete flag has been set
> ' (Ie 1 - Stock Out Risk is less than the Culumative Probability.
>
>End Function

 
Reply With Quote
 
Stefan Hoffmann
Guest
Posts: n/a
 
      11th Mar 2009
hi Michael,

Michael Hudston wrote:
> However after a while it
> breaks down as the variable FCT goes into overflow.

The factorial should bail out with an overflow for a start value of i =
171. But beware of the inprecise data type. It is not necessarily the
mathematically correct factorial value.

> The Function I have written is below, and as a guide the following set of
> values can be used (the first set works, the second doesnt)

It doesn't compile on my system.

> Dim Fct As Double
>
> Count_A = 1
> Complete = 0
> Prob = 0
> SumProb = 0
> Fct = 1
> StockOutRisk = 1 - Probability
> i = 0
> InvPoisson = 0

Where do you declare these variables? What type do they have? Use Option
Explicit and set Variable declaration needed in Tools/Options in the VBA
IDE.



mfG
--> stefan <--
 
Reply With Quote
 
MJ HUdston
Guest
Posts: n/a
 
      12th Mar 2009
It would seem that if the Double Data Type is the largest I can have, then I
have to re-think my entire aproach.

The function doesnt seem to breakdown in Excel, and I have discovered that I
can call the function in Excel from Access, so I may have to resort to that,
but that would mean that both are running at the same time

"Michael Hudston" wrote:

> I have written this VBA Script to basically calculate the number of spares
> based on the Poisson Culumative Distribution. However after a while it
> breaks down as the variable FCT goes into overflow. - The number hits in the
> region of 1.17E+254 I know this is a massive number but then that is
> indicitive of the equation as in theory it could go to infinity
>
> I am wondering what my next step is, and if there is a solution or not.
>
> The Function I have written is below, and as a guide the following set of
> values can be used (the first set works, the second doesnt)
>
> 1st Set
>
> Probability = 0.9
> Lambda = 156.967232876712
>
> 2nd Set
>
> Probability = 0.9
> Lambda = 131.205435114504
> .
>
> Code
>
> Public Function InvPoisson(ByVal Probability As Double, ByVal Lambda As
> Double) As Long
>
> ' This function is designed to return the number of spares required when
> fed with the Availiability, and Mean.
> ' Written By Michael J Hudston
>
> ' Ensure all figures are reset before we start
>
> Dim Fct As Double
>
> Count_A = 1
> Complete = 0
> Prob = 0
> SumProb = 0
> Fct = 1
> StockOutRisk = 1 - Probability
> i = 0
> InvPoisson = 0
>
> ' Now do the majical maths stuff
>
> Do
>
> ' Set the Start point for the Culumative Probability Calculation for
> this run.
>
> SumProb = 0
> Fct = 1
>
> ' Carry out the Culumative Probability Caculation for this run.
>
> For i = 0 To Count_A
>
> ' Do stuff for the Factorial.
>
> If i = 0 Then
> Fct = 1
> Else
> Fct = Fct * i
> End If
>
> Prob = (Exp(-1 * Lambda) * Lambda ^ i) / Fct
> SumProb = SumProb + Prob
>
> Next
>
> ' If the Culumative Probability is greater than 1 - the Stock Out
> Risk then you dont need to continue
> ' so set the complete flag
>
> If Complete = 0 Then
> If SumProb > 1 - StockOutRisk Then
> InvPoisson = Count_A
> Complete = 1
> Else
> ' Otherwise add one to the spares count and run the
> Culumative calculation again.
> Count_A = Count_A + 1
> End If
>
> End If
>
> Loop Until Complete = 1
>
> ' Repeat the loop until the complete flag has been set
> ' (Ie 1 - Stock Out Risk is less than the Culumative Probability.
>
> End Function
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Location of a the second biggest number in a range Josh G Microsoft Excel Worksheet Functions 6 31st Aug 2009 10:21 PM
Finding the biggest number out of 8 variables Mojo Microsoft Excel Misc 11 7th Jun 2009 01:00 AM
Finding the biggest number out of 8 variables Mojo Microsoft Access 12 7th Jun 2009 01:00 AM
What would you say is the biggest advaantage AND biggest drawback to Exchange cached mode in Outlook? Spin Microsoft Outlook 2 14th Oct 2006 05:24 AM
Finding a name with biggest number Handyy Microsoft Excel Worksheet Functions 11 6th Feb 2006 12:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:02 AM.