User:Trettels:Session 4 - 25JAN

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

Group: KKumar, Jonathan, Kai

wxMaxima output for activity 1.2

(%i3) integrate(r*exp(-r*x), x);
(%o3) -%e^(-r*x)
(%i4) integrate(r*exp(-r*x), x, 0, inf);
"Is  "r"  positive, negative, or zero?"positive;
(%o4) 1
(%i5) integrate(x*r*exp(-r*x), x, 0, inf);
"Is  "r"  positive, negative, or zero?"positive;
(%o5) 1/r


MATLAB function for counting win/loss/tie from *.PGN files

function [wlArray] = readPGN(file)
    wlArray = [0 0 0];  %white win, black win, draw
    fid1 = fopen(file);
    if(fid1<0)
        error('\Could not open file\n');
    end
    currLine = fgets(fid1);
    while(currLine~=-1)
        if(length(currLine)>3 && strcmp('[Re',currLine(1:3)))

            switch(currLine(end-3))

                case '0'
                    wlArray(1) = wlArray(1)+1;
                case '1'
                    wlArray(2) = wlArray(2)+1;
                case '2'
                    wlArray(3) = wlArray(3)+1;
                otherwise
                    printf('\Unknown result\n');
            end
        end
        currLine = fgets(fid1);
    end
    fclose(fid1);

Back to TrettelS Index