2
$\begingroup$

I am working on a computer algorithm to find the number of positive integral solutions to the equation- $$ l_1 + l_2 +l_3+ \cdots +l_m=h $$ where - $$ 1\leq l_i\leq n $$ The known approach is of binomial coefficients. But factorials exceed max data type size. I want to use probability. Suppose an n-sided dice is rolled m-times, total number of possibilities = $$n^m$$ , so probability of getting sum as h = No. of integral solutions / (n ^ m). To find probability, loop_m_times(a = a + random_1_to_n() ) run this code a large no. b times. Count no. of times a=h and divide it by b, to get probability. Will this algorithm give accurate answer to the original question ?

  • 0
    $\dbinom{20} 6 = \dfrac{20\times19\times18\times17\times16\times15}{6\times5\times4\times3\times2\times1},$ and then cancel $6\times3$ with $18$ to get $\dbinom{20} 6 = \dfrac{20\times19\times17\times16\times15}{5\times4\times2\times1},$ and $5\times4$ with $20$ to get $\dbinom{20} 6 = \dfrac{19\times17\times16\times15}{\times2\times1},$ and $2$ with $16$ to get $\dbinom{20} 6 = 19\times17\times15,$ and you don't need to find any factorials. Alternatively, you can find $$ \left(\frac{20} 6\right) \times \left( \frac{19} 5 \right) \times \cdots, $$ computing each quotient and then multiplying,2017-01-14
  • 0
    . . . rather than computing factorials.2017-01-14

1 Answers 1

0

For large (or even moderate) values of $n, m, h$ you will have # of integral solutions $\ll n^m$, so the number of runs to get a relevant precision, or even to hit an integral solution will be prohibitive.