• Jeff Moden (3/14/2010)


    Holy Moly! The distribution of "R" and "T" suck with my method! I don't quite understand it because the distribution of "C" is nearly flat as you would expect with random numbers.

    Nice UNPIVOT there Jeff 🙂

    About the distribution:

    C takes a random integer value between 3 and 19. The average value of C is S(3...19) / 16 = 11

    R can now be any random integer value between 3 and (19-C).

    Using the average value of 11 for C, the range of R is (3...11) on average. S(3...11) / 9 = 7

    T ranges from 3 to (25 - R - C) => (25 - 7 - 11) => 7. The range of T is therefore (3...7) on average, and it has an average value of 5.

    Running your test rig over the first million integers (1...1000000), the averages, as reported by the AVG aggregate are:

    C = 10

    R = 6

    T = 7

    Paul