I've got some complex calculations to perform that require a loop process. My prototype was built in MS Access and handled the functionality with very few performance issues. I'm trying to implement in DataStage using a server job and routine.
I pass my routine two arguments (ExpectedUsage and SOH) and my code is:
Code: Select all
Ans = 0
**** Determine the starting probability distribution based on zero SOH.
ProbDist = Exp(-ExpectedUsage)
**** Set the initial loop counter to zero.
LoopCounter = 0
**** Climb the cumulative probability distribution curve until the SOH value is reached OR the result exceeds 1 (i.e. 100%).
LOOP UNTIL (LoopCounter >= SOH) OR (ProbDist >= 1)
**** Increment the Loop Counter by one. Set the Factorial value to one.
LoopCounter = LoopCounter + 1
**** This section determines the Factorial of the LoopCounter. Factorial is used in the ProbDist equation.
**** The Factorial function does not exist in vBasic, so this code has been developed.
Factorial = 1
FOR FactCounter = 1 To LoopCounter
Factorial = FactCounter * Factorial
NEXT
**** The ProbDist equation is "ProbDist + (Exp(-ExpectedUsage) * Pwr(ExpectedUsage,LoopCounter)) / Factorial".
**** The following section works out the components and then determines the overall ProbDist.
**** Because ProbDist occurs within a loop, the value is increased each time with the new value for the LoopCounter.
**** Calculate the result of base 'e' raised to the power designated by the value of ExpectedUsage. ExpectedUsage is set as negative.
ExpectedUsageExp = Exp(-ExpectedUsage)
**** Calculate the value of ExpectedUsage when raised to the (power of the) LoopCounter value.
ExpectedUsagePwr = Pwr(ExpectedUsage,LoopCounter)
**** Determine the probability distribution for ExpectedUsage.
ProbDist = ProbDist + (ExpectedUsageExp * ExpectedUsagePwr) / Factorial
REPEAT
**** When the loop is exited, the ProbDist result is adjusted to 1 (i.e. 100%). The confidence level can not be greater then 100%.
IF ProbDist > 1 THEN
ProbDist = 1
END
Ans = ProbDist
Any help?
Thanks,
Zac