Announcement

Collapse
No announcement yet.

Looking for Reiterative Solution

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Looking for Reiterative Solution

    In a Lotto Drawing, only certain number combinations are considered.
    First, unlike a Pick game, no numbers are duplicated, so you have
    five or six unique numbers that appear as a result, depending upon
    how many balls are picked are per game. Although I know how to
    determine how many separate plays would have to be used to play all
    combinations, I wanted a program that would actually generate
    those combinations.

    I found I could do it readily enough with a series of embedded FOR
    loops, one for each ball. Unfortunately, this means writting code
    specific to either a five ball or six ball drawing. I wanted code
    that could go either way.

    It occurred to me that it might be possible to employ a reiterative
    Sub or Function to get the same results. I've played with it all
    afternoon, but it is proving more dificult than I expected. I
    thought I would post the original code here as a challenge. I'm
    sure someone will likely respond with a solution.

    Code:
    #COMPILE EXE
    #DIM ALL
    GLOBAL ns AS STRING
    GLOBAL panel AS STRING
    
    FUNCTION PBMAIN
    LOCAL a AS LONG, b AS LONG, c AS LONG, d AS LONG, e AS LONG, f AS LONG
    LOCAL g AS LONG, x AS LONG
    ns=STRING$(11,0)     'the pool of numbers to pick from
    FOR a=1 TO LEN(ns)
      MID$(ns,a)=CHR$(a) 'for convenience, numbered 1 to n in order 
    NEXT
    panel=STRING$(6,0)   'the numbers picked for one panel
    'There has to be a separate FOR loop for each pick.  Here, the pick is 6:
    FOR a=1 TO LEN(ns)
      MID$(panel,1)=MID$(ns,a,1)           'update ther first ball
      FOR b=a+1 TO LEN(ns)
        MID$(panel,2)=MID$(ns,b,1)         'update the second ball
        FOR c=b+1 TO LEN(ns)
          MID$(panel,3)=MID$(ns,c,1)       'update the third ball 
          FOR d=c+1 TO LEN(ns)
            MID$(panel,4)=MID$(ns,d,1)     'update the fourth ball 
            FOR e=d+1 TO LEN(ns)
              MID$(panel,5)=MID$(ns,e,1)   'update the fifth ball 
              FOR f=e+1 TO LEN(ns)
                MID$(panel,6)=MID$(ns,f,1) 'update the sixth ball
                INCR x
                PRINT x,                   'track number of plays
                FOR g=1 TO LEN(panel)      'show the current panel
                  PRINT FORMAT$(ASC(panel,g)," 00");
                NEXT
                PRINT
              NEXT
            NEXT
          NEXT
        NEXT
      NEXT
    NEXT
    WAITKEY$
    END FUNCTION
    ------------------
    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

    #2
    Donald,
    no promises that it works under all circumstances..

    Paul.
    Code:
    GLOBAL ns AS STRING
    GLOBAL x AS LONG
    GLOBAL pool AS LONG
    
    SUB DoIt(depth AS LONG, MaxDepth AS LONG, nxt AS LONG, panel AS STRING)
    LOCAL r AS LONG
    LOCAL g AS LONG
    
       IF depth = MaxDepth THEN
          INCR x
          PRINT x,
             FOR g=1 TO LEN(panel)      'show the current panel
                PRINT FORMAT$(ASC(panel,g)," 00");
                NEXT
                PRINT
                
       ELSE
              FOR r = nxt TO pool
                  MID$(panel,depth+1)=MID$(ns,r,1)
                  CALL DoIt(depth+1,MaxDepth,r+1,panel)
                  NEXT
                  
       END IF
           
    END SUB
    
    FUNCTION PBMAIN
    
    n&=6        'the number of balls to draw
    pool=11     'number of balls to draw from
    
    ns=STRING$(pool,0)     'the pool of numbers to pick from
    FOR a&=1 TO pool
        MID$(ns,a&)=CHR$(a&)
        NEXT
            
    CALL DoIt(0,n&,1,STRING$(n&," "))
    
    WAITKEY$
    END FUNCTION
    ------------------

    Comment


      #3
      Thanks, I'll look at it. Actually, it's easy enough to check - just
      see if it runs to the limits allowed.

      I finally thought of another approach that uses a funky way of
      incrementing by offsets in the panel. It works well, and does not
      require reiteration:

      Code:
      #COMPILE EXE
      #DIM ALL
      GLOBAL ns AS STRING
      GLOBAL panel AS STRING
      GLOBAL picks AS LONG
      GLOBAL x AS LONG
      
      FUNCTION expand()AS LONG
      LOCAL a AS LONG, b AS LONG, c AS LONG, d AS LONG, tmp AS STRING
      d=LEN(ns)
      FOR a=0 TO picks-1
        b=picks-a
        tmp=MID$(panel,b,1)
        c=INSTR(ns,tmp)
        IF c>=d-a THEN ITERATE FOR
        INCR c
        MID$(panel,b)=MID$(ns,c)
        FUNCTION=-1
        EXIT FUNCTION
      NEXT
      FUNCTION=0
      END FUNCTION
      
      FUNCTION PBMAIN
      LOCAL a AS LONG, b AS LONG, c AS LONG, d AS LONG, e AS LONG, f AS LONG
      LOCAL g AS LONG
      ns=STRING$(10,0)      'set ns to total number of numbers to pick from
      picks=6
      FOR a=1 TO LEN(ns)
        MID$(ns,a)=CHR$(a)  'assign numbers as byte values within ns
      NEXT
      panel=LEFT$(ns,picks)
      DO
        INCR x
        PRINT x,
        FOR g=1 TO LEN(panel)
          PRINT FORMAT$(ASC(panel,g)," 00");
        NEXT
        PRINT
      LOOP WHILE expand
      WAITKEY$
      END FUNCTION

      ------------------
      Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

      [This message has been edited by Donald Darden (edited January 07, 2005).]

      Comment


        #4
        Another problem is generating an abbreviated wheel from the range of
        all possible combinations. While some wheels focus on ensuring that
        every 3 of six or 4 of six combos is picked, I am more interested
        in trying to ensure that all balls selected are played an equal
        number of times, or as close as possible, over a given range of
        plays without generating any duplicate plays. I've had some
        success with several approaches, particularly with ensuring an even
        distribution, but the problem of duplicates becomes acute as the set
        of picks gets larger.

        Online research suggests that wheels that focus on improving your
        odds for getting 3 of six or 4 of six, tend to work against your
        chances at a 5 of six and 6 of six matchup. Since nobody plays on
        the expectations of just an occasional 3 or six or 4 of six win, it
        seems to make sence to avoid those particular wheels.

        There are other wheels that focus on trying to wheel with pairs
        and threes, sometimes called neighbors, keeping them together
        during the distribution. My thought on this is to code the pair
        or threes and wheel the codes in an abbreviated panel, then
        expand the panel to the picks' full size later by expanding the
        codes back to the pair or threes.

        Neighbors are believed by some to be significant, based on the
        perception that if a so-called "hot" number is due, that a ball
        adjacent to it ( a neighbor) might come up instead. It is also
        reinforced sometimes when two, possibly three adjacent balls
        come up in the same game. So you bet the hot number and maybe
        either or both neighbors. This is how you end up with a pool of
        numbers to wheel.

        There are many other theories as to what might cause a certain
        ball or set of numbers to be "due". I won't get into all that.
        But I'm disturbed that people hold that wheeling strategies are
        worth protecting and charging big bucks for. Some of those
        Wheeling programs run up to $50, and even come with wild
        promises about how much you can win and the improved odds that
        Wheeling supposedly gives you. So I'm going to mess around with
        some code, and make it available to others as I go along.

        It's been claimed that using a good strategy or lottery program
        and wheeling your pool or numbers can increase your odds of
        winning by up to twelve times. That may seem a lot, and it
        certainly means that you can leverage your number of plays as
        though it were a larger set, but the odds against winning are
        still astronomical. Still, if I were motivated to play the Lottery,
        I would want every advantage I could get. But I would not want
        anyone to think that these programs are going to result in a
        significant win, ever. Because they may only encourage you to
        try harder and play more. at an added cost to yourself, and the
        outcome is most probably going to be one of great disappointment.

        ------------------
        Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

        Comment


          #5
          Paul Dixon,

          I just tried your code. Works just fine. I was trying to use
          Globals and Local variables for control, but couldn't get it
          right. Your method of passing everything simplified all that.

          I made minor name and dimension changes to your code, just to
          make it consistent with what I wrote. But it is your code in all
          respects.

          Code:
          #COMPILE EXE
          #DIM ALL
          GLOBAL ns AS STRING
          GLOBAL x AS LONG
          GLOBAL pool AS LONG
          
          SUB DoIt(depth AS LONG, MaxDepth AS LONG, nxt AS LONG, panel AS STRING)
          LOCAL r AS LONG, g AS LONG
          
          IF depth = MaxDepth THEN
            INCR x
            PRINT x,
            FOR g=1 TO LEN(panel) 'show the current panel
              PRINT FORMAT$(ASC(panel,g)," 00");
            NEXT
            PRINT
          ELSE
            FOR r = nxt TO pool
              MID$(panel,depth+1)=MID$(ns,r,1)
              CALL DoIt(depth+1,MaxDepth,r+1,panel)
            NEXT
          END IF
          END SUB
          
          FUNCTION PBMAIN
          LOCAL picks AS LONG, a AS LONG
          picks=6 'the number of balls to draw
          pool=9 'number of balls to draw from
          ns=STRING$(pool,0) 'the pool of numbers to pick from
          FOR a=1 TO pool
            MID$(ns,a)=CHR$(a)
          NEXT
          
          CALL DoIt(0,picks,1,STRING$(picks," "))
          
          WAITKEY$
          END FUNCTION
          ------------------
          Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

          Comment


            #6
            I think you mean "recursive" rather than "reiterative".. that is, a function which calls itself.

            In the PB/DOS User's manual there is a statement about recursive code I've always liked:

            [R]ecursive programming, while seductively elegant, can be devilishly tricky to debug..
            Not really on topic, but I've always loved that statement.

            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


              #7
              It's been claimed that using a good strategy or lottery program
              and wheeling your pool or numbers can increase your odds of
              winning by up to twelve times. That may seem a lot, and it
              certainly means that you can leverage your number of plays as
              though it were a larger set, but the odds against winning are
              still astronomical.
              Lotteries are determinate systems and as such the theoretical odds against
              winning whatever strategy is used is the same for each and every one.

              There may be slight imperfections in the machines and balls used such that
              the practical odds differ to theoretical odds.

              In the UK our 'Lotto' uses 12 machines and 14 sets of balls.



              ------------------
              David Roberts

              Comment


                #8
                Back some 20 years ago, when lotteries only had 28 to 32 balls. I
                recall one lottery that repeated the same five or 6 combo between
                two consecutive drawings, and another where the same six of six
                numbers came up within five drawings of each other. Things like
                that drew harsh criticism as to mechanical imprefections that might
                cause certain balls to come up more often. I also recall some
                scandals where paint was added to some balls to give them more
                mass and make them stronger contenders for selection - they would
                bump lighter balls out of the way.

                As a result, lotteries adopted multiple ball sets, which get
                rotated on a random basis, and each ball is carefully weighed and
                inspected before each drawing, and the results are attested to by
                an independent auditoring firm.

                But still, as Gail Howard first observed, patterns seem to persist.
                Some numbers come up, others don't. Over a period of some drawings,
                the results change, but the general observation that there are
                subtle patterns involved continues to persist. Gail Howard used
                her background in programming and mathematics to track and
                exploit these patterns. She still sells her "winning" (she boasts
                that several people have used it and won big) lottory system, but
                she has also inspired many imitators, some of which have tried to
                develop far more sophisticated and agressive systems.

                To try to put a value to such systems, I refer back to the
                general observation of: "To win, you must play. If a system
                encourages you to play and you win, then who is to say that the
                system was not the cause of your success? But to not play makes
                not winning a certainty." But don't forget the fact that playing
                and not winning is almost a certainty as well, as the odds clearly
                show.

                I'm still struggling with my wheeling program. the problem is
                that there are only a finite number of ways in order that the
                picks can be organized, and if you want to avoid duplicates,
                you can only partially rely on a random process of selection.
                This is because at some point your selection process is going to
                get down to a very few unused arrangements. As the choices
                become confined, you also have a problem with whether all the
                numbers are getting equal play as all the other numbers. A
                random process exposes you to risks that each number is not
                getting equal play.


                I'm currently trying to use an elimination set, which is all the
                possible unique pick combinations in order on a series of panels.
                If I select a panel, I remove it from the elimination set, That
                in itself gets rid of duplicates. But if I am selecting just a
                subset of the elimination set, I need to ensure that each
                individual number only plays to the limit allowed by the numbers
                being pooled, the picks per panel, and the number of panels that
                I am going to play. It's a bit of a balancing act.

                ------------------
                Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                Comment


                  #9
                  Hi Michael,

                  Yes, "recursive" was the word I was trying to think of. There are
                  three problems with recursion: (1) Getting it to do what you want]
                  it to do, (2) Providing an embedded test case so that you can commense
                  to leave each recursion level at some point, and (3) ensuring that in
                  the worse case senario that you do not exceed available stack space.

                  Several sort methods make use of recursive calls, which have been
                  known to set an effective size on the arrays that they can correctly
                  sort. That is because they can exhaust available stack space.

                  Some eligant adaptations of these sort routines exist that use an
                  array to store partial results, rather than forcing them onto the
                  stack. Each recursion extends the array, and as each recursion
                  is exited, the array is contracted and the partial results
                  incorporated. This method allows the recursion to be extended
                  to the limits allowed by available array space, whether in RAM
                  or as part of an external table on a hard drive.

                  Recursion gets a bad name, mostly because either the test case
                  failed, or the stack space was inadequate. In my opinion, it is
                  just another tool to benefit the programmer, needing to be
                  understood and used appropriately, rather than condemmed outright.

                  ------------------
                  Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                  Comment


                    #10
                    Recursion is often elegant and often inefficient but, stack space should
                    rarely be an issue on modern machines... except for grossly nasty cases
                    like paint/fill algorithms. "Devilishly tricky to debug" is foolishness.
                    Recursion works or doesn't. You know what's going on in a recursive routine.

                    If you want something devilishly tricky to debug, start with the THREAD
                    statement. Conflicts between multiple threads often occur "at random" and
                    are sheer bloody murder to find and fix.

                    ------------------
                    Tom Hanlin, PowerBASIC Staff
                    Opinions expressed may not be those of my employer or myself

                    Comment


                      #11
                      "Devilishly tricky to debug" is foolishness.
                      But, but... that's what PowerBASIC Inc says!

                      (Actually that part of the statement is not nearly as sexy as "seductively elegant")


                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                        #12
                        Licked my Wheeling problem in trying to maintain an equal number
                        of plays for each number given a specific number of panels to fill.
                        However, it required a brute force method - If I find a number has
                        played too often, and another not enough, I pick a selected panel
                        that contains the first number but not the second, see if it is
                        still available, and if so, make a substitution. After all the
                        counts are adjusted, I check again, until the most selected number
                        is within one count of the least selected number.

                        First occasion I've had of using the MAT array2() = array1() as a
                        quick way of producing a duplicate numberic array. That let me
                        test results before I committed to them. The ARRAY SCAN was also
                        useful for finding out if and where a certain panel was in the
                        elimination set. Since I was looking for an exact match, I did not
                        have to resort the elimination set each time when I swapped out
                        a panel in it with one that I was trying to remove from my
                        selection.

                        Unfortunately, the MAT method of duplicating an array is only
                        applicable to a numeric array. It would be neat if it could
                        work for UDTs and String arrays as well.

                        I'm having a bit of trouble with the math involved. If you have
                        a pool of 9 balls, and six picks per panel, how many cards would
                        you have to buy to play all nine balls an equal number of times?
                        The answer is three: 1-2-3-4-5-6, 7-8-9-1-2-3, and 4-5-6-7-8-9.
                        That would be twice each. How many panels to play each number
                        just once per card? Easy again. 1,2,3,4,5,6,7,8,9 would be 9
                        cards, with random picks for the other positions on each card.
                        Now here is a tricky one. How many cards do you have to buy to
                        ensure that if any six of the nine numbers in the pool are drawn,
                        that at least 2 of that six will be found on at least one bought
                        panel?

                        If course there is no payoff for just 2 of six matches, so the
                        next question is, assuming again that all six winning numbers
                        are in the pool of nine numbers, how many panels do you need to
                        play to ensure that at least 3 of the six picks are on at least
                        one of the bought panels? Same question with 4 or six and 5 of
                        six.

                        The problem revolves around the combo() function, which can be
                        expressed as:

                        Code:
                        FUNCTION combo(n AS LONG, k AS LONG) AS EXTENDED
                        LOCAL plays AS LONG, value AS EXTENDED
                        value=1
                        FOR plays=1 TO k
                          value=value*(n-plays+1)/plays
                        NEXT
                        'PRINT k"of"n"="value
                        FUNCTION=value
                        END FUNCTION
                        If there are 53 numbered balls in a lottery, and you have six
                        picks per panel, then the total number of unique panel combos
                        that can occur are combo(53,6), or 22,957,480. If you have a
                        bonus ball as well, and say it goes up to 47, then you would
                        calculate combo(53,6)*47 as your chances of getting the grand
                        prize.

                        To guarantee that you get all 6 matches, whatever gets drawn,
                        you would have to buy up all 22,957,480 unique panels. That
                        might be a bit difficult and a little too expensive to do, so
                        you consider your next option: Buying just enough panels to
                        cover your preferred list of numbers. Your hope is that this
                        list of numbers will contain the six numbers finally drawn.

                        The same combo() function serves in this case as well. If you
                        have a pool of nine numbers, then the function combo(9,6) says
                        that you would have to buy and fill out 84 panels using unique
                        arrangements of those nine numbers, so that if those six balls
                        are found in that list, you have a panel with those six numbers
                        on it.

                        Remember, right now we are not thinking about the (53-9), or 44
                        numbers that aren't in out list. For whatever reasons, we put
                        them aside and are just focus on our pool of numbers. So you
                        should not lose track of the fact that we have to get terribly
                        lucky for even three or four of the winning numbers to end up on our
                        list.

                        So it looks like we have to try and make good on that three or
                        four that might show up. Now using the same Combo(9,3), we
                        have to play 84 panels properly numbered to ensure a 3 match.
                        Using Combo(9,4), then number jumps to 126 panels. So you
                        figure that with five of nine, then combos must be getting really
                        big, right? Actually, Combo(9,5) is also 126 panels. In fact,
                        Combo(9,6) is back down to 84 panels. The reason is that we
                        exceeded the midpoint of the pool of 9 numbers, and that means
                        that the ways of uniquely arranging that many numbers in those
                        size sets becomes restrictive. Of course if you have a larger
                        pool of numbers that you favor, the number of panels can go way
                        up.

                        Now that's the way I've worked it out so far. If anybody wants
                        to find fault with this, and can show me what really works, that
                        would be most helpful.


                        ------------------
                        Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                        Comment


                          #13
                          Donald,

                          Interesting discussion. I find no problem with the math.
                          About 20 years ago, I tinkered with the same ideas that you have.
                          I started a pool at work so we could buy more tickets (panels?) as
                          a group than we could individually. Over a period of about three
                          months, we won nothing. Finally, I decided to give it up. On that
                          last drawing, a five dollar ticket returned $7.50 for the members
                          of the pool. However, I discovered that the wheel sets I chose
                          had a greater proportion of "hits" than could be attributed to
                          chance. Unfortunately, combo(6,3) doesn't pay out. According to
                          my simulations, you really didn't start winning until you would
                          play over $10,000 per week.

                          So, what method did I use to pick the pool of numbers to wheel?
                          I took the last ninety drawings and compared each panel to every
                          other panel. The results are shown in a ninety by ninety matrix.
                          Of course you only have to display the lower half of the matrix
                          since it is symmetrical about the diagonal. Discard the diagonal
                          since it is the same panel compared to itself.

                          For each cell in the above matrix, place an "X" in the cell if the
                          two panels have at least one common number, else leave it blank.

                          Print out the matrix and observe the pattern of X's. You will see
                          that there are some long "runs" of X's, either horizontally or
                          vertically. So, if you see a long unbroken column of X's, then
                          you could concievably construct a pool of number consisting of
                          those intersections of sets of panels. Of course, you can refine
                          the matrix to show what numbers appear in the intersection.

                          So how accurate is this method? It falls into the realm of WAGs.
                          In the early days of lotteries, patterns really did exist in the
                          drawings, and people took advantage of them. Now, however, the
                          balls are carefully painted, balanced and weighed. Furthermore,
                          trays of sets of balls are randomly selected to ensure that certain
                          trays cannot be predicted.

                          My conclusion: You can't predict random numbers. If you could,
                          then those numbers are not random by definition.

                          Of course you can use statistical probabilities to describe the
                          mathematical model of a given lottery, but that knowledge doesn't
                          give you any advantage over anyone else.

                          Bottom Line:
                          ------------

                          If you have money burning a hole in your pocket, then pick your
                          numbers and stuff your money in an old sock. If your numbers
                          happen to win, pay your winnings out of the old sock. Then, a
                          year from now, empty the sock and revel in how much money you
                          would have lost if you bought tickets.

                          But what if you really hit the big one? You could kick yourself
                          around the block. But I wouldn't bet on it.

                          Better yet, invest your ticket money in the stock/bond/real-estate
                          markets. It will grow much faster (if invested wisely) than the
                          old sock. After all, Wayne Rogers, Warren Buffet and Donald Trump
                          can't all be wrong.

                          ------------------
                          Regards,
                          Bob

                          [This message has been edited by Robert DeBolt (edited January 10, 2005).]
                          Regards,
                          Bob

                          Comment


                            #14
                            Donald

                            Have you played with the Hypergeometric probability function?

                            When you write combo(n,r) I write nCr.

                            For,
                            N=population size
                            n=sample size
                            k=number of items in population labelled "success"

                            we have h(x; N, n, k) = ( kCx * (N - k)C(n - x) )/NCn ... [1]
                            where x = 0, 1, ... , n.

                            With your "If there are 53 numbered balls in a lottery, and you have six
                            picks per panel..."

                            we have N=53 and k=6

                            and with your "If you have a pool of nine numbers ..."

                            we have n=9.

                            From [1] we get,

                            h(0)=0.30748374
                            h(1)=0.42574673
                            h(2)=0.21287336
                            h(3)=0.04845897
                            h(4)=0.00519203
                            h(5)=0.00024149
                            h(6)=0.00000366

                            giving a total probabilty of 0.99999998, say, 1.0

                            It follows then for 3 or more the prob is 0.05389617
                            or 17.55 to 1 against.

                            More info on the hypergeometric probability function at Site 1 and Site 2

                            I had a battle royal with a guy who proposed a strategy based upon the second
                            law of thermodynamics, ie entropy, and the best rebuffle I saw was from a
                            mathematician who said "lottery balls don't have a memory". I had already argued
                            the case that if a coin was tossed 19 times and it came up heads on
                            each and every toss then the probabilty of a head on the 20th toss
                            was still 0.5 as the previous 19 were 'done and dusted'. The probabilty of 20 heads
                            from the outset is a different matter, ie 9.5*10^(-7), giving grounds to doubt an
                            assumption of non-bias.

                            Have fun.

                            ------------------
                            David Roberts



                            [This message has been edited by David Roberts (edited January 10, 2005).]

                            Comment


                              #15
                              One of the seductive arguments for playing Lotto is that your odds
                              of getting at least 3 of 6 to match in a drawing were about 1 in
                              7 or 1 in 8. That means if I play twice a week, and spend five
                              dollars each time, I should expect to win a free card on the average
                              of about once a week. That's not so bad.

                              But I wasn't getting anything like that as a result. In fact I was
                              having a long dry spell. In going back to several web sites, I
                              still see that claim, and one site even give me enough information
                              for me to determine the method by which they were apparently making
                              this calculation. Based on their apparent approach, the odds of 3
                              of six with a ball range of 53 worked out to be 1 in 162. Still
                              well away from the low odds that were often quoted. And the method
                              of doing these calculations was found to give totally flaky results
                              under other conditions - you don't end up with needing zero panels
                              to ensure that 1 of nine balls is played, for instance. Or having
                              to buy an infinite number of panels to ensure that 6 of 6 balls is
                              matched during the drawing.

                              The way I calculate it, is that you have one chance in 53 of
                              matching the first ball. With that one matched, the second
                              number has to match one of the remaining 52 balls. With that
                              one matched, the third ball has to match one of the remaining
                              51 balls. To state this another way, you need 1 of 53 AND 1 of
                              52 AND 1 of 51 to get a 3 ball match. To express this in a more
                              mathematical form, you calculate 1/53 * 1/52 * 1/51 =
                              0.000005801137023. Or invert that formula and find that
                              53*52*51 = 140,556. Now if you divide this by the number of balls
                              you matched, you would get 46852. Divide it by the number matched
                              less 1 (3-1=2), and you get 23426, Divide it by the number matched
                              less 2 (3-2=1), and you end up with 23,426. No need to go any
                              further. In essence, this is what Combo() does, and it gets the
                              same number: Combo(53,3)=23,426. So this says that the odds of
                              getting 3 matches in a lottery with 53 balls is only 1 in 23,426.

                              So how do these experts come up with 1 chance in 7 or 8? I don't
                              know. I suspect it has something to do with the fact that you are
                              really playing six balls per panel. So it could be not only any
                              of those six, but any combination of three of those six. One
                              could argue that this is 6!, which is 720 combinations, and
                              23,4236/720 is approximately equal to 32.5. But using Combo(6,3),
                              we get only 20, so the correct answer seems to be more like 1
                              chance in 23426/20 = 1,171.3 of getting a match off any 3 numbers
                              in a panel.

                              So if you are looking for a few small wins from time to time to
                              sustain your faith in winning, it doesn't look like you are going
                              to get much help here. On the other hand, Lotteries that add in
                              a Bonus ball will report a win if the Bonus Ball matches. If the
                              highest bonus ball number is 47, then that means that you can
                              expect a bonus ball match every 47 drawings for any given panel.
                              Bonus balls may also cause 1 number and 2 number matches to pay
                              out as well, that could result is 1 in 47 + Combo(53,1)*47 +
                              Combo(53,2)*47 = 1/47 + 1/2491 + 1/64766 = 0.021693481, or if we
                              invert the answer, about 1 in 46 chances of a panel getting
                              something of a win when a powerball is involved.

                              If you spend $5 to buy a card's worth of five panels using different
                              numbers, a single card increases your odds by five times, so now you
                              have about 1 in 9.2 chances of a small win in a powerball game.
                              That adds up to slightly less than one small win every month if
                              you buy five panels (1 card's worth) when you play twice a week.

                              So Powerballs help sustain the illusion that you are close to a
                              real win, by masking the difficulty of getting other numbers to
                              match up.

                              My wife just asked me if she needs to start budgeting a few
                              dollars each week so that I can use this information and play
                              the lottery. I sort of laughed and said that I'd hold off on that.
                              But for fun, I might start tracking how well my programs are
                              doing in conjunction to the Florida lottery. Of course there is
                              a (very very small) chance I might miss out on a big prize if I
                              don't rush right out and buy those tickets, right?

                              No, I'm sort of doing this for other members of the family - my
                              brother-in-law and stepdaughter both asked for a system to help
                              them in their weekly plays. He plays Florida, she plays the
                              PowerBall. Like I said, if you are going to play anyway, it's
                              probably better to use a system.



                              ------------------
                              Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                              Comment


                                #16
                                Hey Bob Debolt!
                                Welcome to the discussion, I'd not heard of anyone using a Matrix
                                approach with respect to drawings before. Sounds interesting. I
                                need some time to consider that.

                                You know, when I first got interested was watching a paid commercial
                                of Gail Howard's system on late night TV during an unemployment
                                period while living in Atlanta. The pitchman oozed the typical
                                sales hype, but she came across as sincere and very conservative
                                and precise in her comments. I figured she was on the level, but
                                had to be mistaken in her premise. So I put my computer to work to
                                simulate lottery results to prove her wrong. Trouble was, my
                                random number selections kept bunching up. I spent more and more
                                time trying to ensure that the random sequences were just that -
                                unpredictable. But the bunching up kept ocurring. It finally
                                dawned on me that I was observing just what Gail had claimed.
                                Patterns did emerge. Not strong patterns, and very fragile in
                                nature, but for periods of time you could see them at work. And
                                remember, this was just using computer simulations. No balls or
                                other hardware was involved.

                                There are two interesting extension of the chaos theory. where ordered
                                systems will naturally decay into randomness. One is the idea that
                                order can spontneously arrise out of chaos, and the other is that
                                any ordered system can behave chaotically if it is overdriven.

                                The fact that your matrix approach exceeded the results predicted
                                by chance is a good indicator that there was some merit in your
                                approach. Unfortunately, right now I do not have a clear idea of
                                how you approached this. You said the last 90 drawings, which in
                                my mind suggest a 90 by 6 table, already of two dimensions. How
                                is it that you converted this into a 90 x 90 Matrix? That part is
                                unclear to me.

                                David Robers, you ask: "Have you played with the Hypergeometric
                                probability function?" Nope, I haven't even heard of it before.
                                It sounds like geometry on steroids. I need to look into that.
                                What I've tried to find is the best method of determining in
                                advance the likelihood of any combination of numbers being selected
                                at random during a lottery drawing. Something that will coincide
                                with experimental results or actual drawing history. This would
                                be essential for determining if any system is giving results above
                                that which would be expected from purely random selections. It
                                always helps if someone explains the concept behind the math. At
                                least you give a formulation that can be incorporated into code.

                                More discussion is welcomed. Thanks for becoming involved. For
                                a while there, it seemed as though I were just talking to myself.

                                ------------------
                                Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                                Comment


                                  #17
                                  Hi David, I'm still looking at the information you provided. One
                                  of the interesting things about quantum mechanics seems to be that
                                  at some fundamental level there are states a particle has to have
                                  knowledge and memory. By knowledge, I think that they mean that
                                  if two particles are in some sort of co-esistence, if one goes
                                  left the other must simultaneously go right, even though they are
                                  incredible distances from each other. I don't understand this, I'm
                                  just trying to adjust to the idea. The other thing seems to be
                                  that a particle does not really exist until it is observed, at
                                  which point it is fixed as to where and when it was. I don't
                                  understand that either, and have no idea what they mean by being
                                  observed, or who the observer is, but taking it at face value, it
                                  would seem that on one hand it had to have immediate knowledge of
                                  the state of the other partical, and it has to have knowledge of
                                  being observed and a memory of it to perpetuate itself forward.

                                  Of course I know that I am talking nonsence, but if any part of
                                  this is true, then it would suggest that in some fundamental way,
                                  memory can persist in ways we cannot understand when it comes to
                                  such matters as the flip of a coin. Whether it would make a
                                  difference is another question.

                                  I once wrote a program to have an asterick begin in the center of
                                  the screen and begin to walk down the scrolling screen one line at
                                  a time, varying its movement side to side from line to line on the
                                  results of a random process. Immediately the asterick begin to
                                  drift to one side more than the other. I varied the random
                                  process in many ways, but always a pronounced drift to one side
                                  would occur within a few lines. The movement would be so
                                  pronounced that I had to add a scale across the screen to show
                                  how far it wandered away from the center. It was apparent after
                                  thousands of lines that the asterick was under no compulsion to
                                  move back to the center of the screen. it would wander back and
                                  forth, but the drift was in no way converging on the center of
                                  the screen again.

                                  That made me realize that while the chances of a coin toss may be
                                  50/50, that the times when the history of the coin toss is going
                                  to be exactly 50/50 is going to be virtually never. Even if the
                                  asterick reached the center of the screen again, it would soon
                                  move on to favor the left side or the right side again, regardless
                                  of which side it had favored before.

                                  If that is true of just a two-choice event, then what happens
                                  when you have multiple choices, such as deciding which of 53
                                  balls is likely to turn up in a drawing? All I can see is that
                                  there will probably never be a time when all 53 balls will have
                                  been drawn an equal number of times - during any part of the
                                  drawing history, some numbers are going to occur more often than
                                  others. That is the fundamental nature of how these things work.
                                  So regardless of how similar the balls may be, or whether your
                                  drawing is done by virtual balls, some favoritism (for lack of
                                  a better word) towards some balls over others is a natural
                                  occurance. It's just a question of whether that insight helps
                                  in any significant way or not.

                                  ------------------
                                  Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                                  Comment


                                    #18
                                    Hey David, thanks for the formula. Turns out it was the inversion
                                    of the formula that I found employed on one of the lottery sites.
                                    So I guess it is valid, I just have to learn how to use it.

                                    But now here is my problem: In your post, you said this:

                                    > h(0)=0.30748374
                                    > h(1)=0.42574673
                                    > h(2)=0.21287336
                                    > h(3)=0.04845897
                                    > h(4)=0.00519203
                                    > h(5)=0.00024149
                                    > h(6)=0.00000366

                                    > giving a total probabilty of 0.99999998, say, 1.0

                                    > It follows then for 3 or more the prob is 0.05389617
                                    > or 17.55 to 1 against.

                                    I don't follow that last statement at all. Where did you come
                                    up with the probability of 0.05389617? I think somehow that it
                                    is based on the h(x). but I don't see how. Can you enlighten me?
                                    In addition, what does h(0) represent? The chance of one ball
                                    matching out of the nine pooled when choosing from 53 balls?
                                    But isn't that dependent on how many panels (cards) I elect to
                                    by and the manner in which the pool is distributed? I'm sorry,
                                    but I'm having trouble getting this into some type of focus.

                                    ------------------
                                    Old Navy Chief, Systems Engineer, Systems Analyst, now semi-retired

                                    Comment


                                      #19
                                      You know, when I first got interested was watching a paid commercial
                                      of Gail Howard's system on late night TV during an unemployment
                                      period while living in Atlanta. The pitchman oozed the typical
                                      sales hype, but she came across as sincere and very conservative
                                      and precise in her comments. I figured she was on the level ...
                                      I don't want to disrespect Ms. Howard, but great showmanship is
                                      predicated on telling people what they want to hear. I would wager
                                      that Ms. Howard made her millions selling books rather than on playing
                                      the lottery.

                                      ... Gail Howard's are the only lottery systems that have actually won millions
                                      of dollars for dozens of people. See why 74 first prize lotto jackpots worth $97 million
                                      were won with the Gail Howard lottery books and lotto software.
                                      http://www.lots0cash.com/directory/links/detail/81
                                      http://lottery.merseyworld.com/Links...ws/Rev177.html
                                      Consider that in my State of Ohio, about 47% of the money taken in is
                                      actually paid out in prizes. In statistics, a "fair" game is defined
                                      to mean that if you wager the same amount for each trial, then over a
                                      sufficiently large series of trials, you should "break even."

                                      Under this definition, the lottery can never be "fair."

                                      http://www.bbc.co.uk/education/asguru/maths/14statistics/02discret erandomvariables/5expectedgain/index.shtml
                                      http://www.bbc.co.uk/education/asgur...ce/index.shtml

                                      Further consider that if the outcome of a lottery drawing could be
                                      predicted consistently, and you published your "system," then most
                                      everyone who plays the "system" would be winners and the lottteries
                                      would go broke. So far as I know, this has never happened. I would
                                      think that the lotteries have statisticians or consultants reviewing
                                      drawing results, and if they observe that a significant number of
                                      players are winning more than the theoretical predictions (probability
                                      distributions), then they would suspect some sort of equipment
                                      malfunction.

                                      I remember reading, a few years ago, about a Canadian lottery player
                                      who kept track of the winning numbers in the Canadian game (Keno, I
                                      think). Over a period of time he observed that the drawing sequence
                                      was repeating itself. So, naturally, he consulted the sequence and
                                      put money down on the next drawing. He won the Jackpot! Big celebration
                                      and cheers and the expected advertising on TV.

                                      Ah, the following week, the lottery officials were somewhat cool toward
                                      him, and pointed out that, theoretically, his odds of winning two weeks
                                      in a row were astronomical and coincidental.

                                      After the third week of winning, the officials took him aside and, with
                                      appropriate means of coercion, got him to disclose his "system."

                                      Apparently, the lottery program was using a PRNG (Pseudo-Random Number
                                      Generator). In his book, "Art of Computer Programming," (I don't
                                      remember which volume (1 of three)), Donald E. Knuth has a very detailed
                                      discussion on PRNGs and how to determine if the output string of numbers
                                      are truly random. PRNGs are notorious for eventually repeating the random
                                      sequences.

                                      http://www.abaa.org/detailindex.php?recnr=147081871&membernr=1370&booknr=570004& source=froogle

                                      Needless to say, that programmer didn't win again (I think).

                                      Isn't there a fable about the goose who layed golden eggs?

                                      It finally dawned on me that I was observing just what
                                      Gail had claimed. Patterns did emerge.
                                      You know, I think it is human nature to want to try to make sense
                                      out of chaos. For example, the "face" on Mars. Further analysis
                                      of photographs revealed it to be a rocky outcropping. Google on
                                      "Face on Mars" for some interesting links. I see hideously ugly
                                      and distorted images of faces on the ceramic panels of my shower
                                      stall. No, its not dirt, but random designs imbedded into the
                                      ceramic by the manufacturer.

                                      Not strong patterns, and very fragile in nature, but for
                                      periods of time you could see them at work. And remember, this was
                                      just using computer simulations. No balls or other hardware was involved.
                                      However, as is well known, face-like images sometimes appear
                                      in clouds, profiles of mountains, and various other random or visually
                                      noisy scenes. Moreover, humans have a tendency to perceive order, even
                                      in the midst of chaos.
                                      http://www.metaresearch.org/solar%20...iles/proof.asp
                                      The fact that your matrix approach exceeded the results predicted
                                      by chance is a good indicator that there was some merit in your
                                      approach. Unfortunately, right now I do not have a clear idea of
                                      how you approached this. You said the last 90 drawings, which in
                                      my mind suggest a 90 by 6 table, already of two dimensions. How
                                      is it that you converted this into a 90 x 90 Matrix? That part is
                                      unclear to me.
                                      Take the most recent 90 drawings (or less) and number then from 1 to 90
                                      consecutively with 1 being the oldest and 90 being the most recent drawing.

                                      You will probably also construct a 90 x 6 matrix of integers, where each
                                      row consists of the 6 winning numbers for that particular drawing. This is
                                      the source matrix.

                                      Construct a 90 x 90 matrix of one-character cells. Draw a line through
                                      the main diagonal and disregard the upper half of the matrix above the
                                      diagonal. Number the rows down the left-hand side from 1 to 90, and the
                                      columns across the top from 1 to 90. This is the target matrix.

                                      Each row of the target matrix represents the comparison of that drawing's winning
                                      numbers. Each column also represents a winning panel and is a repeat of the row.

                                      Now go to row #2. Under column #1, where it intersects row #2, compare the
                                      contents of drawing #1 to the contents of drawing #2 in the source matrix.
                                      You will have anywhere from zero to six hits. You can then enter either the
                                      digits 1 thru 6, or simply enter a non-blank character into that cell (2,1)
                                      of the target matrix. If the number of hits is zero then leave that cell blank.

                                      Now go to row #3. Under column #1, where it intersects row #3, compare the
                                      contents of drawing #1 to the contents of drawing #3. Alter cell (3,1) as
                                      described above. Then under column #2, where it intersects row #3, compare the
                                      contents of drawing #2 to the contents of drawing #3. Alter cell (3,2) as
                                      described above.

                                      Now proceed down the matrix, working from top to bottom and left to right.

                                      I chose a 90 x 90 matrix because it fit well on a couple of sheets of paper
                                      on my dot-matrix printer using the smallest type font.

                                      Now, examine your printout. Where there are columns of unbroken sequences,
                                      it suggests that there are drawings that are "related." That is, they share
                                      common integers. An unbroken column of arbitrary length would indicate a
                                      trend in that set of drawings. How long should a sequence be to be significant?
                                      That's your arbitrary decision. Of course you only want to consider "runs"
                                      which intersect the row of the most recent drawing.

                                      Now take the union of the drawings indicated by the "runs" described above, and
                                      that becomes your wheeling set.

                                      Of course I wrote the programs about 20 years ago using C in DOS and the Borland
                                      3.2 C compiler.

                                      <U>Disclaimer:</U> I will accept no liability for claims arising from these procedures.
                                      Any damage or loss which results from using these procedures are entirely your own
                                      responsibility.


                                      In other words, if it doesn't work, don't blame me.


                                      ------------------
                                      Regards,
                                      Bob

                                      [This message has been edited by Robert DeBolt (edited January 11, 2005).]
                                      Regards,
                                      Bob

                                      Comment


                                        #20
                                        Hi Donald,

                                        I've applied the formula assuming that 6 balls are selected from 53 and
                                        and we are using a pool of 9 giving 9C6 = 84 panels.

                                        h(0) means not one of those panels covers any of the 6 selected ie a 'white wash'.

                                        h(1) means only one of the six selected is 'picked up' by our pool of 9.
                                        8C5 panels ( from (9-1)C(6-1) ) = 56 such panels which have that one number.

                                        blah, blah, blah

                                        h(6) means all six selected are 'picked up' by our pool of 9.
                                        3C0 panels ( from (9-6)C(6-6) ) = 1 such panel will have the six selected.

                                        h(7) to h(9) will have probability zero.

                                        The 0.05389617 is got from h(3)+h(4)+h(5)+h(6) ie 3 or more.

                                        If a payout does not start until <U>at least</U> three matches then we can say
                                        that with a 'pool of nine' strategy, 5.4% of the time we will get a payout.

                                        Going back to h(0), 30.7% of the time a 'pool of nine' strategy will be a
                                        'white wash'.

                                        ----------------------------

                                        < ... the odds of getting 3 matches in a lottery with 53 balls ...>

                                        Just use the hypergeometric probabilty function again but with
                                        N=53, n=6 and k=6 ie a pool of 6 (n=6) instead of a pool of 9.

                                        Now we get,

                                        h(0)=0.46771566
                                        h(1)=0.40089914
                                        h(2)=0.11654045
                                        h(3)=0.01412611
                                        h(4)=0.00070631
                                        h(5)=0.00001228
                                        h(6)=0.00000004

                                        giving a total of 0.99999999, say, 1.0

                                        In particular, the chance of 3 matches is 0.01412611 ie 1 in 70.8.

                                        --------------------

                                        The point to bear in mind with quantum mechanics is that if an event is not
                                        prohibited then it is compulsory.

                                        If you are in a sealed room and told that there is a 70/30 chance of rain
                                        outside then it is <U>both</U> raining and dry outside at the same time
                                        and in the proportion 70/30.

                                        If a door is opened so that we can see outside the probability function
                                        collapses and only one of the two events obtains.

                                        If it is raining we cannot say it must have been raining before we opened
                                        door as this prohibits the dry, giving then a dry probabilty of zero. This
                                        contradicts the 70/30 chance, therefore it could not have been raining only.

                                        That may sound double dutch but it is the way we have to think in the
                                        quantum world. Folks who can 'think' in that logic space have solved some
                                        problems to an amazing accuracy and close on the heels of problems
                                        solved using relativity.

                                        I don't buy the co-existence theory at great distances. If something is 'right'
                                        because something else is 'left, the 'right' something doesn't need to know the
                                        'left' something exits, all it needs to know is that it cannot be 'left', ie
                                        prohibited, and therefore it must be 'right'.

                                        If light strikes a pain of glass of a certain thickness then 95% passes through
                                        and 5% is reflected. That is, on average, 95 out of 100 photons pass through
                                        and, on average, 5 out of 100 photons bounce back. A photon is a photon is a
                                        photon but 95% are prohibited from bouncing back so they pass through. 5% are
                                        prohibited from passing through so they bounce back. Simple really.




                                        ------------------
                                        David Roberts

                                        Comment

                                        Working...
                                        X
                                        😀
                                        🥰
                                        🤢
                                        😎
                                        😡
                                        👍
                                        👎