meyerjp3 / psychometrics

A Java library for classical test theory, item response theory, factor analysis, and other measurement techniques. It provide tools commonly used in psychometrics and operational testing programs.
94 stars 46 forks source link

ArrayIndexOutOfBoundsException in AbstractPolychoricCorrelation #5

Open pereferrera opened 9 years ago

pereferrera commented 9 years ago

When this piece of code is run, invalid offsets are accessed within the x2 array:

    //Eliminate rows and columns with nonzero sums
    if(validRowcount!=nrow || validColCount!=ncol){
        double[][] x2 = new double[validRowcount][validColCount];
        int r=0;
        int c=0;
        N=0;
        for(int i=0;i<nrow;i++){
            c=0;
            for(int j=0;j<ncol;j++){
                x2[r][c] = data[goodRow[i]][goodCol[j]];
                N+=x2[r][c];
                c++;
            }
            r++;
        }
        data=x2;
        nrow = data.length;
        ncol = data[0].length;
    }

As I'm not quite sure what is supposed to happen at this point, I didn't submit a pull request.

meyerjp3 commented 9 years ago

There's more work to be done with the polychoric correlations. Would you post a test case that causes the error? Thanks.

pereferrera commented 9 years ago

Done, see: https://github.com/meyerjp3/psychometrics/pull/6