Post Reply 
(12C Platinum) Statistical significance calculator
04-13-2023, 10:06 AM (This post was last modified: 04-18-2023 01:40 PM by Tritonio.)
Post: #1
(12C Platinum) Statistical significance calculator
I translated a program that I had made for a few Casios (https://community.casiocalc.org/topic/81...-3650p-ii/) to the Platinum.

Register 1 is the total number of experiments.
Register 2 is the probability of an experiment randomly succeeding.
Register 3 is the number if experiments that succeeded.
Running it with the above will tell you the your confidence that the number of successful experiments is irregular and not explained just by luck. Putting a zero on register 3 will instead find how many experiments would need to succeed so that you could be at least 99% sure that it's not by luck.

Code:
001 RCL 3
002 X=0
003 GTO 040
004 0
005 STO 0
006 STO 4
007 RCL 1
008 n!
009 RCL 0
010 n!
011 ÷
012 RCL 1
013 RCL 0
014 -
015 n!
016 ÷
017 1
018 RCL 2
019 -
020 RCL 1
021 RCL 0
022 -
023 y^x
024 ×
025 RCL 2
026 RCL 0
027 y^x
028 ×
029 STO + 4
030 1
031 STO + 0
032 RCL 0
033 +
034 RCL 3
035 x<->y
036 x<=y
037 GTO 007
038 RCL 4
039 GTO 000
040 0
041 STO 4
042 RCL 1
043 n!
044 RCL 3
045 n!
046 ÷
047 RCL 1
048 RCL 3
049 -
050 n!
051 ÷
052 1
053 RCL 2
054 -
055 RCL 1
056 RCL 3
057 -
058 y^x
059 ×
060 RCL 2
061 RCL 3
062 y^x
063 ×
064 STO + 4
065 1
066 STO + 3
067 RCL 3
068 RCL 1
069 1
070 +
071 x<=y
072 GTO 080
073 0
074 .
075 9
076 9
077 RCL 4
078 x<=y
079 GTO 042
080 RCL 3
081 RCL 1
082 1
083 +
084 x<=y
085 GTO 088
086 RCL 3
087 GTO 000
088 1
089 CHG
090 STO 3

It's my first program on the Platinum so it can probably be improved a lot. I can think of two improvements that I didn't have time to do.

First, there is a big overlap between the case where register 3 was zero and the case where it wasn't. A good chunk of the code is the same so it could probably be reused and instead keep a flag that has the initial value of register 3 to decide what to do after we go out of the big shared code chunk. If you see the program in the Casio forum you'll notice that the long formula exists almost identical in two places. That that shared code I'm talking about.

Second, I'm calculating combinations using n!. That means that the program won't support more than 69 total experiments (register 1) as the n! will overflow for that number. But if you expand the combinations formula and actually calculate the fraction with loops you can go MUCH higher than that without overflowing. But that would need much more code.
Find all posts by this user
Quote this message in a reply
05-10-2023, 11:00 PM (This post was last modified: 06-08-2023 07:19 PM by Tritonio.)
Post: #2
RE: (12C Platinum) Statistical significance calculator
Well, I rewrote it using my suggestions from my previous post.
Code:

001 RCL 1
002 STO 5
003 0
004 STO 1
005 STO 0
006 1
007 RCL 2
008 RCL 0
009 y^x
010 x
011 1
012 RCL 2
013 -
014 RCL 5
015 RCL 0
016 -
017 y^x
018 x
019 RCL 5
020 RCL 0
021 -
022 STO 4
023 x=0 
024 GTO 036
025 RCL 4
026 RCL 0
027 +
028 x<->y
029 /
030 x
031 1
032 STO - 4
033 Rdown
034 RCL 4
035 GTO 023
036 Rdown
037 STO + 1
038 1
039 STO + 0
040 RCL 3
041 x=0
042 GTO 053
043 RCL 0
044 1
045 +
046 x<=y
047 GTO 006
048 RCL 1
049 RCL 5
050 STO 1
051 Rdown
052 GTO 000
053 RCL 1
054 .
055 9
056 9
057 x<->y
058 x<=y
059 GTO 061
060 GTO 069
061 RCL 5
062 1
063 -
064 RCL 0
065 x<=y
066 GTO 006
067 CHG
068 STO / 0
069 RCL 5
070 STO 1
071 RCL 4
072 STO 3
073 GTO 000

It is probably slower than before, I think, I haven't done an actual comparison for the same input. But now it can work even with very big numbers that before would overflow the factorial. For example for 200->STO1, 11/12->STO2 and 0->STO3, it will take I think more than 30 minutes to return an answer but it will actually calculate it! It has wider range than even the original Casio BASIC program.

I am unsure if this way of calculating the nCk (combinations) is accumulating too many rounding errors for big numbers. I may do some comparisons with Wolfram Alpha when I have some time.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)