Post Reply 
[WP-34S] Chi-Square Distribution
01-14-2014, 10:07 PM
Post: #18
RE: [WP-34S] Chi-Square Distribution
The problem I fixed added a +/- at the end if p<.5
The number coming out was correct, just with the wrong sign.

Code below. The change is to add FS? F_SMALL +/- right down at the bottom.

- Pauli

Code:
qf_q_est::    LocR 003

qf_q_int_est::    ENTER[^]
        +/-
        INC X
        MIN
        STO R_MINP        // q = min(p, 1-p)
        x[!=]? L
            SF F_SMALL    // Set Flag if p < 0.5 (i.e. 1-p != q)
        Num 1/2            // pre-store 0.5 in a register for later use
        STO R_HALF
        _INT 023
        SDR 002
        RCL R_MINP
        x>? Y
            JMP qf_q_mid
        ENTER[^]        // tail estimate
        LN
        STO+ X
        +/-
        STO Z
        DEC X
        Num [pi]
        [times]
        STO+ X
        [sqrt]
        [times]
        LN
        STO+ X
        +/-
        [sqrt]
        _INT 254
        SDR 003
        RCL/ Z
        +
        STO R_ABSZ
        JMP qf_q_signfix

qf_q_mid::    Num 1/2
        RCL- Y
        Num [pi]
        STO+ X
        [sqrt]
        [times]
        ENTER[^]
        x[^3]
        _INT 006
        /
        +
        STO R_ABSZ
        _INT 004
        SDR 002
        x>? Y
            CF F_ITER        // z < 0.04 requires just one correction step
        SDR 007
        x>? Y
            SF F_EXACT        // z < 4E-9 needs no correction at all, flag for exit
qf_q_signfix::    FS? F_SMALL
            +/-
        RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [WP-34S] Chi-Square Distribution - Paul Dale - 01-14-2014 10:07 PM



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