es.unex.sextante.tables.normalityTest
Class SWilk

java.lang.Object
  extended by es.unex.sextante.tables.normalityTest.SWilk

public class SWilk
extends java.lang.Object

Calculates the Shapiro-Wilk W test and its significance level. Ported from original FORTRAN 77 code from the journal Applied Statistics published by the Royal Statistical Society and distributed by Carnegie Mellon University at http://lib.stat.cmu.edu/apstat/. To help facilitate debugging and maintenance, this port has been changed as little as feasible from the original FORTRAN 77 code, to allow comparisons with the original. Variable names have been left alone when possible (except for capitalizing constants), and the logic flow (though translated and indented) is essentially unchanged. The original FORTRAN source for these routines has been released by the Royal Statistical Society for free public distribution, and this Java implementation is released to the public domain. This java implementation is part of the limewire project.


Constructor Summary
SWilk()
           
 
Method Summary
static void swilk(boolean[] init, double[] x, int n, int n1, int n2, double[] a, double[] w, double[] pw, int[] ifault)
          ALGORITHM AS R94 APPL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWilk

public SWilk()
Method Detail

swilk

public static void swilk(boolean[] init,
                         double[] x,
                         int n,
                         int n1,
                         int n2,
                         double[] a,
                         double[] w,
                         double[] pw,
                         int[] ifault)
ALGORITHM AS R94 APPL. STATIST. (1995) VOL.44, NO.4 Calculates Shapiro-Wilk normality test and P-value for sample sizes 3 <= n <= 5000 . Handles censored or uncensored data. Corrects AS 181, which was found to be inaccurate for n > 50. NOTE: Semi-strange porting kludge alert. FORTRAN allows subroutine arguments to be modified by the called routine (passed by reference, not value), and the original code for this routine makes use of that feature to return multiple results. To avoid changing the code any more than necessary, I've used Java arrays to simulate this pass-by-reference feature. Specifically, in the original code w, pw, and ifault are output results, not input parameters. Pass in double[1] arrays for w and pw, and an int[1] array for ifault, and extract the computed values from the [0] element on return. The argument init is both input and output; use a boolean[1] array and initialize [0] to false before the first call. The routine will update the value to true to record that initialization has been performed, to speed up subsequent calls on the same data set. Note that although the contents of a[] will be computed by the routine on the first call, the caller must still allocate the array space and pass the unfilled array in to the subroutine. The routine will set the contents but not allocate the space. As described above with the constants, the data arrays x[] and a[] are referenced with a base element of 1 (like FORTRAN) instead of 0 (like Java) to avoid screwing up the algorithm. To pass in 100 data points, declare x[101] and fill elements x[1] through x[100] with data. x[0] will be ignored. You might want to eliminate the ifault parameter completely, and throw Java exceptions instead. I didn't want to change the code that much.

Parameters:
init - Input & output; pass in boolean[1], initialize to false before first call, routine will set to true
x - Input; Data set to analyze; 100 points go in x[101] array from x[1] through x[100]
n - Input; Number of data points in x
n1 - Input; dunno
n2 - Input; dunno either
a - Output when init[0] == false, Input when init[0] == true; holds computed test coefficients
w - Output; pass in double[1], will contain result in w[0] on return
pw - Output; pass in double[1], will contain result in pw[0] on return
ifault - Output; pass in int[1], will contain error code (0 == good) in ifault[0] on return


Copyright © 2014 gvSIG Association. All Rights Reserved.