hello i require assistance with this equation. it deals with the probability that *at least* k distinct runs, each of *at least* r consecutive losses, will occur in a trade sample. the equation is for normal distribution and i realise that the size of market moves are not normally distributed, however it is still interesting to have this sort of readyreckoner Prob = (C(n - k*r, k - 1) + p*C(n - k*r, k))*p^(k - 1)*q^(k*r) where C(a, b) = a!/(b!*(a - b)!) is a binomial coefficient, k is the number of runs, and n is the trade sample size. r is the number of loses in a row. p is winning prob. q is losing probability. To be clear, this is supposed to be the probability that *at least* k distinct runs, each of *at least* r consecutive losses, will occur. i took a!= to be (n-k*r)!. however when entered values (1000-2*15)!=970!, the calculator returned an error message. so, how do i calculate a,b or C(a, b) = a!/(b!*(a - b)!) ?
abaker, Not surpised, 970! is the notation for 970 factorial, commonly used in probability. That is, 970*969*968*967*966...1. I dare say your calculator emitted puffs of smoke before returning an error message. You might want oto engage some computing power from NASA or recheck your logic. All the best, bolter
The good news is that you don't need to calculate huge factorials. 970! is greater than the number of electrons in the visible universe, I think. Instead, simplify the expression. Let's take your example: n = 1,000 r = 15 k = 2 and also, let's say, p = 0.4 q = 0.6. Then P = [C(1000-2*15, 2-1) + 0.4*C(1000-2*15, 2)] * 0.4^(2-1) * 0.6^(2*15). C(970, 1) = 970! / 1!*969! = 970 and C(970, 2) = 970! / 2!*968! = 969*970 / 2 = 469,965. See how those factorials cancel out nicely? P = [970 + 0.4 * 469,965] * 0.4 * 0.6^30 = 188,956 * 0.4 * 0.000000221074 = 0.0167 = 1.67%. Incidentally, what's the source for your formula?
hi latex, thanks for helping me to see how to use the formula. a mathematician on a google group sci.math was the source of the formula. he also said that the formula was a very poor approximation for r numbers under 15. http://groups.google.co.uk/group/sc...gth+in+a+sample&rnum=1&hl=en#5fddc1770e55ccab
You could write a little computer program that calculates the probabilities directly. The simplest approach is to make a finite state machine with three states: (1) Start; (2) LastTradeWasWin; (3) LastTradeWasLoss. I cobbled up just such a program, launched it, and went to eat breakfast. When I returned it had produced the output shown below. As you can see, for the case (n=1000, r=15, k=2, p=0.4) it computes 10.69% which is different than the closed form solution provided by a previous poster. PHP: sessions n r k p(win) happened frequency ---------------------------------------------------------- 10000 1000 5 2 0.200 10000 100.000 % 10000 1000 5 2 0.300 10000 100.000 % 10000 1000 5 2 0.400 10000 100.000 % 10000 1000 5 2 0.500 10000 100.000 % 10000 1000 5 2 0.600 9899 98.990 % 10000 1000 5 2 0.700 5955 59.550 % 10000 1000 5 2 0.800 655 6.550 % 10000 1000 5 4 0.200 10000 100.000 % 10000 1000 5 4 0.300 10000 100.000 % 10000 1000 5 4 0.400 10000 100.000 % 10000 1000 5 4 0.500 9999 99.990 % 10000 1000 5 4 0.600 8964 89.640 % 10000 1000 5 4 0.700 1302 13.020 % 10000 1000 5 4 0.800 6 0.060 % 10000 1000 5 6 0.200 10000 100.000 % 10000 1000 5 6 0.300 10000 100.000 % 10000 1000 5 6 0.400 10000 100.000 % 10000 1000 5 6 0.500 9994 99.940 % 10000 1000 5 6 0.600 6402 64.020 % 10000 1000 5 6 0.700 146 1.460 % 10000 1000 5 6 0.800 0 0.000 % 10000 1000 5 8 0.200 10000 100.000 % 10000 1000 5 8 0.300 10000 100.000 % 10000 1000 5 8 0.400 10000 100.000 % 10000 1000 5 8 0.500 9948 99.480 % 10000 1000 5 8 0.600 3223 32.230 % 10000 1000 5 8 0.700 9 0.090 % 10000 1000 5 8 0.800 0 0.000 % 10000 1000 5 10 0.200 10000 100.000 % 10000 1000 5 10 0.300 10000 100.000 % 10000 1000 5 10 0.400 10000 100.000 % 10000 1000 5 10 0.500 9711 97.110 % 10000 1000 5 10 0.600 1150 11.500 % 10000 1000 5 10 0.700 0 0.000 % 10000 1000 5 10 0.800 0 0.000 % 10000 1000 10 2 0.200 10000 100.000 % 10000 1000 10 2 0.300 9992 99.920 % 10000 1000 10 2 0.400 8214 82.140 % 10000 1000 10 2 0.500 2362 23.620 % 10000 1000 10 2 0.600 236 2.360 % 10000 1000 10 2 0.700 14 0.140 % 10000 1000 10 2 0.800 0 0.000 % 10000 1000 10 4 0.200 10000 100.000 % 10000 1000 10 4 0.300 9877 98.770 % 10000 1000 10 4 0.400 3441 34.410 % 10000 1000 10 4 0.500 75 0.750 % 10000 1000 10 4 0.600 0 0.000 % 10000 1000 10 4 0.700 0 0.000 % 10000 1000 10 4 0.800 0 0.000 % 10000 1000 10 6 0.200 10000 100.000 % 10000 1000 10 6 0.300 9162 91.620 % 10000 1000 10 6 0.400 678 6.780 % 10000 1000 10 6 0.500 0 0.000 % 10000 1000 10 6 0.600 0 0.000 % 10000 1000 10 6 0.700 0 0.000 % 10000 1000 10 6 0.800 0 0.000 % 10000 1000 10 8 0.200 10000 100.000 % 10000 1000 10 8 0.300 7226 72.260 % 10000 1000 10 8 0.400 61 0.610 % 10000 1000 10 8 0.500 0 0.000 % 10000 1000 10 8 0.600 0 0.000 % 10000 1000 10 8 0.700 0 0.000 % 10000 1000 10 8 0.800 0 0.000 % 10000 1000 10 10 0.200 10000 100.000 % 10000 1000 10 10 0.300 4243 42.430 % 10000 1000 10 10 0.400 1 0.010 % 10000 1000 10 10 0.500 0 0.000 % 10000 1000 10 10 0.600 0 0.000 % 10000 1000 10 10 0.700 0 0.000 % 10000 1000 10 10 0.800 0 0.000 % 10000 1000 15 2 0.200 9997 99.970 % 10000 1000 15 2 0.300 6556 65.560 % 10000 1000 15 2 0.400 1069 10.690 % 10000 1000 15 2 0.500 82 0.820 % 10000 1000 15 2 0.600 1 0.010 % 10000 1000 15 2 0.700 0 0.000 % 10000 1000 15 2 0.800 0 0.000 % 10000 1000 15 4 0.200 9724 97.240 % 10000 1000 15 4 0.300 1293 12.930 % 10000 1000 15 4 0.400 5 0.050 % 10000 1000 15 4 0.500 0 0.000 % 10000 1000 15 4 0.600 0 0.000 % 10000 1000 15 4 0.700 0 0.000 % 10000 1000 15 4 0.800 0 0.000 % 10000 1000 15 6 0.200 8312 83.120 % 10000 1000 15 6 0.300 106 1.060 % 10000 1000 15 6 0.400 0 0.000 % 10000 1000 15 6 0.500 0 0.000 % 10000 1000 15 6 0.600 0 0.000 % 10000 1000 15 6 0.700 0 0.000 % 10000 1000 15 6 0.800 0 0.000 % 10000 1000 15 8 0.200 5232 52.320 % 10000 1000 15 8 0.300 2 0.020 % 10000 1000 15 8 0.400 0 0.000 % 10000 1000 15 8 0.500 0 0.000 % 10000 1000 15 8 0.600 0 0.000 % 10000 1000 15 8 0.700 0 0.000 % 10000 1000 15 8 0.800 0 0.000 % 10000 1000 15 10 0.200 2225 22.250 % 10000 1000 15 10 0.300 0 0.000 % 10000 1000 15 10 0.400 0 0.000 % 10000 1000 15 10 0.500 0 0.000 % 10000 1000 15 10 0.600 0 0.000 % 10000 1000 15 10 0.700 0 0.000 % 10000 1000 15 10 0.800 0 0.000 % 10000 1000 20 2 0.200 8618 86.180 % 10000 1000 20 2 0.300 1484 14.840 % 10000 1000 20 2 0.400 103 1.030 % 10000 1000 20 2 0.500 0 0.000 % 10000 1000 20 2 0.600 0 0.000 % 10000 1000 20 2 0.700 0 0.000 % 10000 1000 20 2 0.800 0 0.000 % 10000 1000 20 4 0.200 3519 35.190 % 10000 1000 20 4 0.300 17 0.170 % 10000 1000 20 4 0.400 0 0.000 % 10000 1000 20 4 0.500 0 0.000 % 10000 1000 20 4 0.600 0 0.000 % 10000 1000 20 4 0.700 0 0.000 % 10000 1000 20 4 0.800 0 0.000 % 10000 1000 20 6 0.200 593 5.930 % 10000 1000 20 6 0.300 0 0.000 % 10000 1000 20 6 0.400 0 0.000 % 10000 1000 20 6 0.500 0 0.000 % 10000 1000 20 6 0.600 0 0.000 % 10000 1000 20 6 0.700 0 0.000 % 10000 1000 20 6 0.800 0 0.000 % 10000 1000 20 8 0.200 54 0.540 % 10000 1000 20 8 0.300 0 0.000 % 10000 1000 20 8 0.400 0 0.000 % 10000 1000 20 8 0.500 0 0.000 % 10000 1000 20 8 0.600 0 0.000 % 10000 1000 20 8 0.700 0 0.000 % 10000 1000 20 8 0.800 0 0.000 % 10000 1000 20 10 0.200 2 0.020 % 10000 1000 20 10 0.300 0 0.000 % 10000 1000 20 10 0.400 0 0.000 % 10000 1000 20 10 0.500 0 0.000 % 10000 1000 20 10 0.600 0 0.000 % 10000 1000 20 10 0.700 0 0.000 % 10000 1000 20 10 0.800 0 0.000 %