Re: Probability Concepts & HP17BII limitations Message #23 Posted by Chris Randle (Lincoln, UK) on 25 Apr 2001, 9:13 p.m., in response to message #1 by Michael Burns
Michael,
I'm not familiar with the 17BII, but I thought about how you might solve this on the 200LX or 42S (two HPs that I do have) and it may give you some ideas.
As you rightly point out n!/(n-k)! can be expanded to n*(n-1)*(n-2)*...*(n-k+1). In your 365 and 23 example, it's 365*364*...*343. You might be able to program the calculator to perform this function and thus solve for values of n far higher than your calculator can return factorials.
I'm ignoring the fact that both calculators have a perm function that returns a permutation of k items from n items, which is what the above expression calculates. If the 17BII has one then your problem's solved. Both machines return ~4.22e58.
On the 200LX's solver, there's a SIGMA function which takes arguments thus: sigma(cv,c1,c2,s,alg) where cv is the counter variable, c1, c2 and s are begin/end/step values and alg is the expression to sum. You could use this as a sort of loop. The L function allows an assignment to be made for each iteration of the loop. Try something like:
sum=sigma(x,n,(n-k+1),-1,L(perm,if(x=n,n,perm*x)))
Set values for n & k, solve for sum and read off the value of perm.
The 42S has a handy loop construct where a register containing a number in the form bbbb.eeess (e.g. 365.34301 means begin at 365 end at 343 and step by 1 (the default)) can be incremented or decremented.
The prog below took the values N=365 and K=23 and returned the same answer as the built-in perm function, only slightly more leisurely.
The comments in line below are based on my dim understandings of the HP-41.
Hope you can adapt these ideas to the 17BII in some way.
00 { 34-Byte Prgm}
01 LBL "PERM"
02 INPUT "N"
03 INPUT "K"
04 -
05 3
06 10^X
07 / [Divide]
08 RCL "N"
09 +
10 1
11 LBL 01
12 RCL ST Y [May be RCL Y on your calc?]
13 IP [May be INT on your calc?]
14 x
15 DSE ST Y [May be DSE Y on your calc?]
16 GTO 01
17 END
|