Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 10,354 of 10,840    |
|    Jan Hyde to All    |
|    Re: Error when calculating probablity    |
|    02 Jan 07 16:41:47    |
   
   From: StellaDrinker@REMOVE.ME.uboot.com   
      
   "Lisa" 's wild thoughts were released   
   on Tue, 02 Jan 2007 16:32:19 GMT bearing the following   
   fruit:   
      
   >"Jan Hyde" wrote in message   
   >news:0a7kp2de8msi9t2oo7aorhpq6ua0ih2bpq@4ax.com...   
   >> "Lisa" 's wild thoughts were released   
   >> on Tue, 02 Jan 2007 04:42:52 GMT bearing the following   
   >> fruit:   
   >>   
   >> >In translating the formula for calculating lottery odds for various   
   >> >conditions into a Visual Basic Program, I have apparently missed   
   >something   
   >> >in that I get errors in the part of the calculation where the number of   
   >ways   
   >> >of failure (pFal) is calculated   
   >> >Both errors happen in the code section   
   >> >   
   >> > x1 = Draw - MatchesReq   
   >> > x2 = Field - Selections   
   >> > For Counter = 1 To (Draw - MatchesReq - 1)   
   >> > x1 = x1 * (Draw - MatchesReq - Counter)   
   >> > x2 = x2 * (Field - Selections - Counter)   
   >> > Next   
   >> > pFal = x2 / x1   
   >> >   
   >> >The first type of error is created when the number of matches required is   
   >> >equal to the number of balls drawn.   
   >> >This makes x1 = 0 so when it hits the calculation pFal a divide by zero   
   >> >occurs.   
   >> >   
   >> >The second type of error is created when the number of balls selected is   
   >> >equal to the field.   
   >> >This makes x1 = 0 so when it hits the calculation pFal a divide by zero   
   >> >occurs.   
   >> >   
   >> >If anyone can spot my error I would greatly appreciate it.   
   >> >Lisa   
   >>   
   >> Haven't you just identified the error? Divide by zero? If   
   >> zero is a possibility then you should always check for it in   
   >> code.   
   >>   
   >> Jan Hyde (VB MVP)   
   >>   
   >Hi Jan   
   >The problem is zero should not be a possibility and it is occurring because   
   >I have not properly converted this part of the math formula to code.   
   >I have talked to some of the math teachers but they have not a clue as to   
   >how it should be written in VB coding.   
   >This is going to take someone that is knowledgably in both probability math   
   >and VB.   
   >Thanks for the response   
   >Lisa   
   >   
      
   Then the question is where are you getting the values for   
   'Draw' and 'MatchesReq'?   
      
   Regardless, it's still wise to check for zero even if it   
   'shouldn't' happen.   
      
      
      
      
   Jan Hyde (VB MVP)   
      
   --   
   Arch Criminal: One who robs shoe stores (Stan Kegel)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca