@@ -0,0 +1,95 @@
/*
Methods used here:
- Polynomial
- Descriptive.frequencies for getting the distinct values,
- some Mat methods (sum, multiply)
- Find
- Cast
In some cases, the methods showcased here are suboptimal to other existing methods.
but are used anyway for illustrative purposes.
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

// create a few different types of data points
int ln = 50;
// create a y matrix, consisting of 4 rows
float[] y0 = new float[ln];
float[] x = new float[ln];

float[] coeffs = new float[] {
1.2, 0, 5
};
for (int i=0; i<ln; i++) {
x[i] = i+1;
y0[i] = round(random(-10, 10));
}
// y = 1.2x^2 + 5
float[] y1 = Polynomial.polyval(x, new float[] {1.2, 0, 5});

// sum the first and second rows
float[] y2 = Mat.sum(y0, y1);
// multiply x and y0
float[] y3 = Mat.multiply(x, y0);


/*
Get the distinct value in y0 and their corresponding frequencies.
This requires a sorted y0, hence the Mat.copyThenSort call.
Using sort directly will sort the original y0 which we don't want.
After getting the distinct values and their frequencies, we cast them
to float and int arrays. This is mainly to show how to use the Cast class
*/

ArrayList yDistinct = new ArrayList(); ArrayList frequencies = new ArrayList();
// call the function
Descriptive.frequencies(Mat.copyThenSort(y0),yDistinct,frequencies);
/*
Cast yDistinct and frequencies to float and int arrays
float[] yTemp = new float[yDistinct.size()]; yDistinct.toArray(yTemp);
will give you a class cast exception since floats and ints are primitives.
*/

y3 = Cast.arrayListToFloat(yDistinct);
int[] freq = Cast.arrayListToInt(frequencies);
// print results to screen. set this to false here if you don't care to see this.
boolean printToScreen = true;
if(printToScreen){
println("There are "+y3.length+" distinct values in y0. Their values and corresponding frequencies are:");
for(int i=0; i<y3.length; i++){
println("Value: "+ y3[i]+", Frequency: "+freq[i]);
}
}



/*
Find class: returns -1 if the element is not found
*/
// index of the first element in y0 containing 5.
int idxFirst = Find.indexOf(y0,5);
// index of the alst element in y0 containing 5
int idxLast = Find.lastIndexOf(y0,5);
// the number of times 5 is repeated in y0
int numRepeats = Find.numRepeats(y0,5);
// all the indices in y0 containing 5
int[] indices = Find.indicesWith(y0,5);

// print results to screen. set this to false here if you don't care to see this.
printToScreen = true;
if(printToScreen){
println("\n\nFind class examples:\n\tFirst index of y0 containing 5: "+idxFirst);
println("\tLast index of y0 containing 5: "+idxLast);
println("\tNumber of times 5 is repeated: "+numRepeats);
print("\tIndices of y0 containing 5: ");
for(int i=0; i<indices.length-1; i++){
print(indices[i]+", ");
} print(indices[indices.length-1]);
}



@@ -0,0 +1,180 @@
import papaya.*;

/* Using the Comparisons class for checking the "freshman-15".
Here, we focus on just the MannWhitney method, but the
signTest and TTest can be used as well.
See also the OneWayAnova class for one-way anovas.
*/

// --------------------- Sketch-wide variables ----------------------
PFont titleFont, mediumFont, smallFont;

float[] BMI_April, BMI_Sept, WT_April, WT_Sept;
// create a "Sex" class that takes in the input csv file and organizes the data
// by sex
Sex M = new Sex();
Sex F = new Sex();
float[] pValue = new float[4];

// ------------------------ Initialisation --------------------------

// Initialise the data
void setup()
{
size(800, 600);
smooth();
noLoop();

titleFont = createFont("Helvetica", 20, true);
mediumFont = createFont("Helvetica", 13, true);
smallFont = createFont("Helvetica", 11, true);
textFont(smallFont);

//Read in the data
String lines[] = loadStrings("FRESHMAN15.csv");
int ln = lines.length-1;
// store everything in the M and F classes
for (int i=0; i<ln; i++) {
String[] pieces = splitTokens(lines[i+1], ",") ;
if (pieces[0].equals("M") ) {
M.addElement(pieces);
}
else {
F.addElement(pieces);
}
}

/* Perform the Mann-Whitney test on male and female Weights and BMIs.
before and after */
M.MannWhitneyTest();
F.MannWhitneyTest();
// get the MannWhitney pvalues.
pValue = new float[]{F.Wt_p,M.Wt_p,F.BMI_p,M.BMI_p};


// Print everything out in the console to see what's going on with these here freshmen...
println("Females:\np-value for BMI is "+F.BMI_p+", p-value for Weight is "+F.Wt_p);
println("Males:\np-value for BMI is "+M.BMI_p+", p-value for Weight is "+M.Wt_p);
println("Changes are insignificant...\n\nWhat about the differences between males and females?");

// combine the April and September data since we've already seen that there's minimal difference.
float[] allWt_F = Mat.concat(F.Wt_Sept,F.Wt_Apr); float[] allWt_M = Mat.concat(M.Wt_Sept,M.Wt_Apr);

// compute the Mann-Whitney test statistic and p-valu
float[] allWt = Comparison.mannWhitney(allWt_F,allWt_M);
println("p-value for Weight difference between males and females: "+allWt[1]);

// doing the same thing for BMI is simple enough. First we combine the data
float[] allBMI_F = Mat.concat(F.BMI_Sept,F.BMI_Apr); float[] allBMI_M = Mat.concat(M.BMI_Sept,M.BMI_Apr);
// then we compute the Mann-Whitney test statistic & p-value
float[] allBMI = Comparison.mannWhitney(allBMI_F,allBMI_M);

println("p-value for BMI difference between males and females: "+allBMI[1]);
println("Aha! so, guys are in general heavier, but, since the BMI comparisons show insignificant differences\n"+
"we can attribute the weight differences to guys being generally taller.");
}


//Visuals. How to use the subplot class.
// specify the colors for the different groups.
color fSept = color(50, 80, 200, 100);
color fApr = color(50, 80, 200, 200);
color mSept = color(200, 50, 80, 100);
color mApr = color(200, 50, 80, 200);
String[][] plotTitles = { { "Weight: Females(kg)", "BMI: Females(kg/m^2)" } , { "Weight: Males(kg)", "BMI: Males(kg/m^2)"}};

void draw() {
background(255);
// create the subplot.
SubPlot splot = new SubPlot(this, 110, 100, 600, 400, 2, 2);

for (int i=0; i<2; i++) {

splot.setDataExtremes(0, F.ln+1, 40, 120,i,0);
splot.setDataExtremes(0, F.ln+1, 10, 50,i,1);
for (int j=0; j<2; j++) {
textAlign(LEFT,TOP);
splot.writeTitle(mediumFont,plotTitles[i][j],i,j);
splot.yLabels(4,i,j);
}
}

// x values for the scatter plot with each x value corresponding
// to a subject.
float[] fX = new float[F.ln];
float[] mX = new float[M.ln];
for (int i=0; i<F.ln; i++) {
fX[i] = i+1;
}
for (int i=0; i<M.ln; i++) {
mX[i] = i+1;
}

// draw the scatter plots
// input it (xdata, ydata, color, subplot x number, subplot y number).
splot.drawScatterPlot(fX, F.Wt_Sept, fSept, 0, 0);
splot.drawScatterPlot(fX, F.Wt_Apr, fApr, 0, 0);

splot.drawScatterPlot(mX, M.Wt_Sept, mSept, 1, 0);
splot.drawScatterPlot(mX, M.Wt_Apr, mApr, 1, 0);

splot.drawScatterPlot(fX, F.BMI_Sept, fSept, 0, 1);
splot.drawScatterPlot(fX, F.BMI_Apr, fApr, 0, 1);

splot.drawScatterPlot(mX, M.BMI_Sept, mSept, 1, 1);
splot.drawScatterPlot(mX, M.BMI_Apr, mApr, 1, 1);

// legend
splot.legendHoriz("bottom", new int[]{fSept,fApr,mSept,mApr}, new String[]{"Females, Before","Females, After","Males, Before","Males, After"});
// write the pvalues to the screen as well.
textAlign(LEFT,TOP); textFont(smallFont);
text("pValue: "+ nfc(pValue[0],4),splot.xLefts[0][0]+5,splot.yTops[0][0]+20);
text("pValue: "+ nfc(pValue[1],4),splot.xLefts[1][0]+5,splot.yTops[1][0]+20);
text("pValue: "+ nfc(pValue[2],4),splot.xLefts[0][1]+5,splot.yTops[0][1]+20);
text("pValue: "+ nfc(pValue[3],4),splot.xLefts[1][1]+5,splot.yTops[1][1]+20);

// plot title
textFont(titleFont);
text("Does the Freshman-15 exist?",splot.getLeft() - splot.s[0][0].leftBound,splot.getTop()-50);
}




// convenience class ----------------------------------------------------------------
class Sex {
float[] BMI_Apr = new float[0];
float[] BMI_Sept = new float[0];
float[] Wt_Apr = new float[0];
float[] Wt_Sept= new float[0];
int ln = 0;

// for the MannWhitney test, by Sex
float BMI_p;
float Wt_p;

Sex() {
}

/*
Update the data. This is *not* the best way to do things (that would
be to use an arraylist and then cast that to a float.
But this eliminates a few steps in the code so bear with me :)
*/
void addElement(String[] s) {
Wt_Sept = append(Wt_Sept, Float.parseFloat(s[1]) );
Wt_Apr = append(Wt_Apr, Float.parseFloat(s[2]) );
BMI_Sept = append(BMI_Sept, Float.parseFloat(s[3]) );
BMI_Apr = append(BMI_Apr, Float.parseFloat(s[4]) );
ln = BMI_Apr.length;
}

/** compares the BMIs and Weights before and after */
void MannWhitneyTest() {
// get the pvalue which corresponds to the second value returned
BMI_p = Comparison.mannWhitney(BMI_Apr, BMI_Sept)[1];
// get the pvalue which corresponds to the second value returned
Wt_p = Comparison.mannWhitney(Wt_Apr,Wt_Sept)[1];
}
}

@@ -0,0 +1 @@
SEX,WTSEP,WTAPR,BMISP,BMIAP,,,,,,,,,,,,,,,,M,72,59,22.02,18.14,,,,,,,,,,,,,,,,M,97,86,19.7,17.44,,,,,,,,,,,,,,,,M,74,69,24.09,22.43,,,,,,,,,,,,,,,,M,93,88,26.97,25.57,,,,,,,,,,,,,,,,F,68,64,21.51,20.1,,,,,,,,,,,,,,,,M,59,55,18.69,17.4,,,,,,,,,,,,,,,,F,64,60,24.24,22.88,,,,,,,,,,,,,,,,F,56,53,21.23,20.23,,,,,,,,,,,,,,,,F,70,68,30.26,29.24,,,,,,,,,,,,,,,,F,58,56,21.88,21.02,,,,,,,,,,,,,,,,F,50,47,17.63,16.89,,,,,,,,,,,,,,,,M,71,69,24.57,23.85,,,,,,,,,,,,,,,,M,67,66,20.68,20.15,,,,,,,,,,,,,,,,F,56,55,20.97,20.36,,,,,,,,,,,,,,,,F,70,68,27.3,26.73,,,,,,,,,,,,,,,,F,61,60,23.3,22.88,,,,,,,,,,,,,,,,F,53,52,19.48,19.24,,,,,,,,,,,,,,,,M,92,92,24.74,24.69,,,,,,,,,,,,,,,,F,57,58,20.69,20.79,,,,,,,,,,,,,,,,M,67,67,20.49,20.6,,,,,,,,,,,,,,,,F,58,58,21.09,21.24,,,,,,,,,,,,,,,,F,49,50,18.37,18.53,,,,,,,,,,,,,,,,M,68,68,22.4,22.61,,,,,,,,,,,,,,,,F,69,69,28.17,28.43,,,,,,,,,,,,,,,,M,87,88,23.6,23.81,,,,,,,,,,,,,,,,M,81,82,26.52,26.78,,,,,,,,,,,,,,,,M,60,61,18.89,19.27,,,,,,,,,,,,,,,,F,52,53,19.31,19.75,,,,,,,,,,,,,,,,M,70,71,20.96,21.32,,,,,,,,,,,,,,,,F,63,64,21.78,22.22,,,,,,,,,,,,,,,,F,56,57,19.78,20.23,,,,,,,,,,,,,,,,M,68,69,22.4,22.82,,,,,,,,,,,,,,,,M,68,69,22.76,23.19,,,,,,,,,,,,,,,,F,54,56,20.15,20.69,,,,,,,,,,,,,,,,M,80,82,22.14,22.57,,,,,,,,,,,,,,,,M,64,66,20.27,20.76,,,,,,,,,,,,,,,,F,57,59,22.15,22.93,,,,,,,,,,,,,,,,F,63,65,23.87,24.67,,,,,,,,,,,,,,,,F,54,56,18.61,19.34,,,,,,,,,,,,,,,,F,56,58,21.73,22.58,,,,,,,,,,,,,,,,M,54,56,18.93,19.72,,,,,,,,,,,,,,,,M,73,75,25.88,26.72,,,,,,,,,,,,,,,,M,77,79,28.59,29.53,,,,,,,,,,,,,,,,F,63,66,21.89,22.79,,,,,,,,,,,,,,,,F,51,54,18.31,19.28,,,,,,,,,,,,,,,,F,59,62,19.64,20.63,,,,,,,,,,,,,,,,F,65,68,23.02,24.1,,,,,,,,,,,,,,,,F,53,56,20.63,21.91,,,,,,,,,,,,,,,,F,62,65,22.61,23.81,,,,,,,,,,,,,,,,F,55,58,22.03,23.42,,,,,,,,,,,,,,,,M,74,77,20.31,21.34,,,,,,,,,,,,,,,,M,74,78,20.31,21.36,,,,,,,,,,,,,,,,M,64,68,19.59,20.77,,,,,,,,,,,,,,,,M,64,68,21.05,22.31,,,,,,,,,,,,,,,,F,57,61,23.47,25.11,,,,,,,,,,,,,,,,F,64,68,22.84,24.29,,,,,,,,,,,,,,,,F,60,64,19.5,20.9,,,,,,,,,,,,,,,,M,64,68,18.51,19.83,,,,,,,,,,,,,,,,M,66,71,21.4,22.97,,,,,,,,,,,,,,,,F,52,57,17.72,19.42,,,,,,,,,,,,,,,,M,71,77,22.26,23.87,,,,,,,,,,,,,,,,F,55,60,21.64,23.81,,,,,,,,,,,,,,,,M,65,71,22.51,24.45,,,,,,,,,,,,,,,,M,75,82,23.69,25.8,,,,,,,,,,,,,,,,F,42,49,15.08,17.74,,,,,,,,,,,,,,,,M,74,82,22.64,25.33,,,,,,,,,,,,,,,,M,94,105,36.57,40.86,,,,,,,,,,,,,,,,
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,121 @@
/*
Example showing how to use some of the methods in the Correlation class.
The dataset consists of Garbage collected from a number of different households.
To load the file into R, use something similar to
garbage<-read.csv("/Users/adilapapaya/Desktop/Downloads/TrioloDatasets/GARBAGE.csv",header=TRUE,sep=",")
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

String[] columnTitles;
int numColumns, numObs; // number of columns, and number of observations for each column
float[][] data;// data by household size
float[][] indivTrash; // data normalized by the household size.
CorrelationPlot cPlot; //Initialize the correlation plot

void setup() {
size(500, 500);
noLoop();

parseData("GARBAGE.csv");
int numDecimals =4;
// get the covariance matrix and print the results to screen
float[][] covMatrix = Correlation.cov(data, true);
println("\n\nCovariance Matrix");
Mat.print(covMatrix,columnTitles,columnTitles,numDecimals);

// get the correlation matrix and print the results to screen
float[][] corrMatrix = Correlation.linear(data, true);
println("\n\nCorrelation Matrix");
Mat.print(corrMatrix,columnTitles,columnTitles,numDecimals);

// get the spearman correlation matrix
float[][] spearmanCorrMatrix =Correlation.spearman(data, true);
println("\n\nSpearman Correlation Matrix");
Mat.print(spearmanCorrMatrix,columnTitles,columnTitles,numDecimals);


/* For a weighted analysis, lets make the weight[i] = 1/householdsize[i].
(i.e. look at things on an individual basis).*/
float[] HHSize = Mat.column(data,0);
float[] weights = Mat.inverse(HHSize,0); // if HHSize[i]==0, weights[i] = 0;

// get the weighted covariance matrix,
float[][] weightedCovMatrix = Correlation.Weighted.cov(data, weights, true);
println("\n\nWeighted Covariance Matrix");
Mat.print(weightedCovMatrix,columnTitles,columnTitles,numDecimals);


// get the weighted correlation matrix
float[][] weightedCorrMatrix =Correlation.Weighted.corr(data, weights, true);
println("\n\nWeighted Correlation Matrix");
Mat.print(weightedCorrMatrix,columnTitles,columnTitles,numDecimals);
println();

noLoop();
}

// Drawing --------------------------------------------------
float xLeft = 40, yTop = 40, xWidth = 420, yHeight = 420;
color steelblue = 0xff1f77b4;
color orange = 0xffff7f0e;
color backgroundColor = color(250);
// font
PFont titleFont = createFont("Helvetica", 15, true);
PFont smallFont = createFont("Helvetica", 12, true);
PFont tinyFont = createFont("Helvetica", 9, true);

// Display all the data. The top left displays the raw data, the
// bottom right displays data normalized by household size.
// Interesting to see if the data distribution matches the correlation coefficients given in the
// corr and weighted correlation matrices.
void draw(){
background(0);
cPlot = new CorrelationPlot(this, xLeft,yTop,xWidth,yHeight);
// draws the border & writes the labels. do this BEFORE drawing the data or you'll
// cover it up.
textFont(smallFont); // setting up the font prior to plotting.
cPlot.drawBorderAndLabels(columnTitles, backgroundColor);
// Labeling --------------------------

textFont(titleFont); fill(240); textAlign(RIGHT,BOTTOM);
text("Household Trash", xLeft + xWidth, yTop -5);
textAlign(LEFT,TOP);
text("Household Trash Normalized by Household Size",xLeft, yTop + yHeight + 5);

// draw the correlation plot
// syntax: drawPlot(data, topRight(0) or bottomLeft(1), color of the dots, backgroundcolor;
// raw data
cPlot.drawPlot(data,0,steelblue);
// data normalized by household size
cPlot.drawPlot(indivTrash,1,orange);

saveFrame("CorrelationMatrix.png");
}

// parses the input file and organize the data
public void parseData(String fileName){
// HHSIZE METAL PAPER PLAS GLASS FOOD YARD, TEXT OTHER TOTAL
String[] s= loadStrings(fileName);
columnTitles = splitTokens(s[0], ",");
numObs = s.length-1;
numColumns = columnTitles.length;
data = new float[numObs][ numColumns];
indivTrash = new float[numObs][ numColumns]; // excludes the hhsize column
// read in the rest of the data
for (int i=0; i<numObs; i++) {
String[] pieces = splitTokens(s[i+1], ",");
data[i][0] = Float.parseFloat(pieces[0]); //HHSize
data[i][numColumns-1] = Float.parseFloat(pieces[numColumns-1]); // total trash
indivTrash[i][0] = data[i][0];// don't normalize the HHSize
for (int j=1; j<numColumns; j++) {
// the raw data
data[i][j] = Float.parseFloat(pieces[j]);
// the data normalized by the household size.
indivTrash[i][j] = data[i][j]/data[i][0];
}
}
}

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1 @@
HHSize,Metal,Paper,Plastic,Glass,Food,Yard,Text,Other,Total2,1.09,2.41,0.27,0.86,1.04,0.38,0.05,4.66,10.763,1.04,7.57,1.41,3.46,3.68,0,0.46,2.34,19.963,2.57,9.55,2.19,4.52,4.43,0.24,0.5,3.6,27.66,3.02,8.82,2.83,4.92,2.98,0.63,2.26,12.65,38.114,1.5,8.72,2.19,6.31,6.3,0.15,0.55,2.18,27.92,2.1,6.96,1.81,2.49,1.46,4.58,0.36,2.14,21.91,1.93,6.83,0.85,0.51,8.82,0.07,0.6,2.22,21.835,3.57,11.42,3.05,5.81,9.62,4.76,0.21,10.83,49.276,2.32,16.08,3.42,1.96,4.41,0.13,0.81,4.14,33.274,1.89,6.38,2.1,17.67,2.73,3.86,0.66,0.25,35.544,3.26,13.05,2.93,3.21,9.31,0.7,0.37,11.61,44.447,3.99,11.36,2.44,4.94,3.59,13.45,4.25,1.15,45.173,2.04,15.09,2.17,3.1,5.36,0.74,0.42,4.15,33.075,0.99,2.8,1.41,1.39,1.47,0.82,0.44,1.03,10.356,2.96,6.44,2,5.21,7.06,6.14,0.2,14.43,44.442,1.5,5.86,0.93,2.03,2.52,1.37,0.27,9.65,24.134,2.43,11.08,2.97,1.74,1.75,14.7,0.39,2.54,37.64,2.97,12.43,2.04,3.99,5.64,0.22,2.47,9.2,38.963,1.42,6.05,0.65,6.26,1.93,0,0.86,0,17.173,3.6,13.61,2.13,3.52,6.46,0,0.96,1.32,31.62,4.48,6.98,0.63,2.01,6.72,2,0.11,0.18,23.112,1.36,14.33,1.53,2.21,5.76,0.58,0.17,1.62,27.564,2.11,13.31,4.69,0.25,9.72,0.02,0.46,0.4,30.961,0.41,0.27,0.15,0.09,0.16,0,0,0,1.084,2.02,6.67,1.45,6.85,5.52,0,0.68,0.03,23.226,3.27,17.65,2.68,2.33,11.92,0.83,0.28,4.03,42.9911,4.95,12.73,3.53,5.45,4.68,0,0.67,19.89,51.93,1,9.83,1.49,2.04,4.76,0.42,0.54,0.12,20.24,1.55,16.39,2.31,4.98,7.85,2.04,0.2,1.48,36.83,1.41,6.33,0.92,3.54,2.9,3.85,0.03,0.04,19.022,1.05,9.19,0.89,1.06,2.87,0.33,0.01,0.03,15.432,1.31,9.41,0.8,2.7,5.09,0.64,0.05,0.71,20.712,2.5,9.45,0.72,1.14,3.17,0,0.02,0.01,17.014,2.35,12.32,2.66,12.24,2.4,7.87,4.73,0.78,45.356,3.69,20.12,4.37,5.67,13.2,0,1.15,1.17,49.372,3.61,7.72,0.92,2.43,2.07,0.68,0.63,0,18.062,1.49,6.16,1.4,4.02,4,0.3,0.04,0,17.412,1.36,7.98,1.45,6.45,4.27,0.02,0.12,2.02,23.672,1.73,9.64,1.68,1.89,1.87,0.01,1.73,0.58,19.132,0.94,8.08,1.53,1.78,8.13,0.36,0.12,0.05,20.993,1.33,10.99,1.44,2.93,3.51,0,0.39,0.59,21.183,2.62,13.11,1.44,1.82,4.21,4.73,0.64,0.49,29.062,1.25,3.26,1.36,2.89,3.34,2.69,0,0.16,14.952,0.26,1.65,0.38,0.99,0.77,0.34,0.04,0,4.433,4.41,10,1.74,1.93,1.14,0.92,0.08,4.6,24.826,3.22,8.96,2.35,3.61,1.45,0,0.09,1.12,20.84,1.86,9.46,2.3,2.53,6.54,0,0.65,2.45,25.794,1.76,5.88,1.14,3.76,0.92,1.12,0,0.04,14.623,2.83,8.26,2.88,1.32,5.14,5.6,0.35,2.03,28.413,2.74,12.45,2.13,2.64,4.59,1.07,0.41,1.14,27.1710,4.63,10.58,5.28,12.33,2.94,0.12,2.94,15.65,54.473,1.7,5.87,1.48,1.79,1.42,0,0.27,0.59,13.126,3.29,8.78,3.36,3.99,10.44,0.9,1.71,13.3,45.775,1.22,11.03,2.83,4.44,3,4.3,1.95,6.02,34.794,3.2,12.29,2.87,9.25,5.91,1.32,1.87,0.55,37.267,3.09,20.58,2.96,4.02,16.81,0.47,1.52,2.13,51.585,2.58,12.56,1.61,1.38,5.01,0,0.21,1.46,24.814,1.67,9.92,1.58,1.59,9.96,0.13,0.2,1.13,26.182,0.85,3.45,1.15,0.85,3.89,0,0.02,1.04,11.254,1.52,9.09,1.28,8.87,4.83,0,0.95,1.61,28.152,1.37,3.69,0.58,3.64,1.78,0.08,0,0,11.142,1.32,2.61,0.74,3.03,3.37,0.17,0,0.46,11.7
@@ -0,0 +1,184 @@
/*
Example showing how to apply some of the matrix decomposition methods.
The dataset consists of Bear Measurements (why not, right?).
the matrix analyzed is the covariance matrix which is both square and symmetric.
Feel free to switch things up with a non-square matrix, or an asymmetric one.
To load the file into R, use something along the lines of
garbage<-read.csv("/Users/adilapapaya/Desktop/Downloads/TrioloDatasets/BEARS.csv",header=TRUE,sep=",")
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

String[] columnTitles;
int numColumns, numObs, numM, numF; // number of columns, and number of observations for each column
float[][] data, dataM, dataF;// bear data
CorrelationPlot cPlot; //Initialize the correlation plot

void setup() {
size(500, 500);
noLoop();

parseData("BEARS.csv");
int numDecimals =4;
// get the covariance matrix. we'll use this as the core matrix
// in the matrix decompositions methods to follow.
float[][] covMatrix = Correlation.cov(data, true);
println("\n\nCovariance Matrix");
Mat.print(covMatrix,columnTitles,columnTitles,numDecimals);

// now the fun starts. :)

// 1. Eigenvalues ---------------------------------------------------
//-------------------------------------------------------------------
Eigenvalue eigen = new Eigenvalue(covMatrix);
// cast the eigenvector matrix to a float array for printing to screen
float[][] V = Cast.doubleToFloat(eigen.getV());
println("\nEigenvector Matrix");
Mat.print(V,numDecimals);
float[][] D = Cast.doubleToFloat(eigen.getD());
println("\nBlock Diagonal Eigenvalue Matrix.");
Mat.print(D,numDecimals);
// check if covMatrix*v = lambda*v, where v is an eigenvector.
float[] v = Mat.column(V,0); float lambda = D[0][0];
float[] cv = Mat.multiply(covMatrix,v); float[] lambdav = Mat.multiply(v,lambda);
println("\nCovarianceMatrix * v - Lambda * v");
Mat.print(Mat.subtract(cv,lambdav),4);

// 2. SVD Decomposition ---------------------------------------------
//-------------------------------------------------------------------
SVD svd = new SVD(covMatrix);
// covMatrix = U * S * transpose(V)
int rank = svd.rank();
float cond = (float)svd.cond();
println("\nSVD Decomposition:\nRank is "+rank+", Condition Number is "+cond);
float[][] U = Cast.doubleToFloat(svd.getU());
println("\nU");
Mat.print(U,numDecimals);
float[][] S = Cast.doubleToFloat(svd.getS());
println("\nS");
Mat.print(S,numDecimals);
float[][] VTrans = Mat.transpose( Cast.doubleToFloat(svd.getV()) );
println("\nTranspose(V)");
Mat.print(VTrans,numDecimals);
println("\nNotice that, since the input matrix is symmetric, U = V via the Spectral Decomposition Theorem. :)");

// 3. LU Decomposition ---------------------------------------------
//-------------------------------------------------------------------
LU lu = new LU(covMatrix);
// covMatrix * pivotArray = L*U
float det = (float)lu.det();
println("\nLU Decomposition:\nDeterminant is "+det +" (=the product of singular values or eigenvalues)" );
float[][] L = Cast.doubleToFloat(lu.getL());
println("\nL");
Mat.print(L,numDecimals);
U = Cast.doubleToFloat(lu.getU());
println("\nU");
Mat.print(U,numDecimals);

// 4. QR Decomposition ---------------------------------------------
//------------------------------------------------------------------
QR qr = new QR(covMatrix);
// covMatrix = Q*R
println("\nQR Decomposition");
float[][] Q = Cast.doubleToFloat(qr.getQ());
println("\nQ");
Mat.print(Q,numDecimals);
float[][] R = Cast.doubleToFloat(qr.getR());
println("\nR");
Mat.print(R,numDecimals);

// Solving a system of linear equations --------------------
// Using QR: Least squares solution of A*X = B
// where A and B both have the same number of rows

float[][] A = new float[][]{{1,5,9},{2,4,6},{1,6,3}};
float[][] B = new float[][]{{2,3,-1},{9,3,1},{3,2,8}};
//float[] B = new float[]{2,9,-1}; // if you want to try the case where B is an array
float[][] X = Cast.doubleToFloat( new QR(A).solve(B) );
println("\nQR Least squares solution X, to A*X = B");
Mat.print(X,numDecimals);
//Mat.print(Mat.multiply(A,X),numDecimals); // should equal B


// Using LU: Best for solving square matrices so we take just the upper 2x2 part of x
X = Cast.doubleToFloat( new LU(A).solve(B) );
println("\nLU solution X, to A*X = B");
Mat.print(X,numDecimals);
//Mat.print(Mat.multiply(A,X),numDecimals); // should equal B
}

// Drawing --------------------------------------------------
float xLeft = 40, yTop = 40, xWidth = 420, yHeight = 420;
color b =color(50,80,250,150); // blue
color g=color(50,200,100,200); // green
color backgroundColor = color(250);
// font
PFont titleFont = createFont("Helvetica", 15, true);
PFont smallFont = createFont("Helvetica", 12, true);
PFont tinyFont = createFont("Helvetica", 9, true);
String[] sex = {"Female Bears","Male Bears"};
// Display all the data. The top left displays the raw data, the
// bottom right displays data normalized by household size.
// Interesting to see if the data distribution matches the correlation coefficients given in the
// corr and weighted correlation matrices.
void draw(){
background(255);
cPlot = new CorrelationPlot(this, xLeft,yTop,xWidth,yHeight);
// draws the border & writes the labels. do this BEFORE drawing the data or you'll
// cover it up.
textFont(smallFont); fill(240);// setting up the font prior to plotting.
cPlot.drawBorderAndLabels(columnTitles, backgroundColor);
// Labeling --------------------------

textFont(titleFont); fill(100); textAlign(RIGHT,BOTTOM);
text("All Bears", xLeft + xWidth, yTop -5);
textAlign(LEFT,TOP);
text(sex[sexIndex%2],xLeft, yTop + yHeight + 5);

// draw the correlation plot
// syntax: drawPlot(data, topRight(0) or bottomLeft(1), color of the dots, backgroundcolor;
// raw data
cPlot.drawPlot(data,0,b);
// data normalized by household size
if(sexIndex%2==0) cPlot.drawPlot(dataF,1,g);
else cPlot.drawPlot(dataM,1,g);
}

// parses the input file and organize the data

public void parseData(String fileName){
// SEX AGE HEADLEN HEADWTH NECK LENGTH CHEST WEIGHT
String[] s= loadStrings(fileName);
columnTitles = splitTokens(s[0], ",");
columnTitles = subset(columnTitles,1,columnTitles.length-1); // remove the column containing the sex
numObs = s.length-1;
numM = 35; numF = numObs - numM;
numColumns = columnTitles.length;
data = new float[numObs][numColumns];
dataM = new float[numM][numColumns];
dataF = new float[numF][numColumns];
// indivTrash = new float[numObs][ numColumns]; // excludes the hhsize column
// read in the rest of the data
for (int i=0; i<numObs; i++) {
String[] pieces = splitTokens(s[i+1], ",");
for (int j=1; j<=numColumns; j++) {
// the raw data
data[i][j-1] = Float.parseFloat(pieces[j]);
// I've cheated a little and checked the input file: first 35 are males, 36 through 54 are females
if(i<numM) dataM[i][j-1] = data[i][j-1];
else dataF[i-numM][j-1] = data[i][j-1];
}
}
}

int sexIndex = 0;
void keyPressed(){
if(keyCode==TAB){
sexIndex++;
redraw();
}
}

@@ -0,0 +1 @@
Sex,Age,HeadLn,HeadWd,Neck,Length,Chest,Weight1,19,11,5.5,16,53,26,801,55,16.5,9,28,67.5,45,3441,81,15.5,8,31,72,54,4161,115,17,10,31.5,72,49,3481,56,15,7.5,26.5,73.5,41,2621,51,13.5,8,27,68.5,49,3601,68,16,9,29,73,44,3321,8,9,4.5,13,37,19,341,32,14,5,21.5,67,37,1801,32,13,8,21.5,59,33,1661,45,13.5,7,24,64,39,2041,21,13,6,19,59,30,1201,177,16,9.5,30,72,48,4361,21,13,5,17,54,28,901,9,10,4,13,40,23,401,45,16,6,24,63,42,2201,9,10,4,13.5,43,23,461,33,13.5,6,22,66.5,34,1541,21,14.5,5.5,20,61,34,1501,10,9.5,4.5,16,40,26,651,10,11,5,17,49,29,941,10,11.5,5,17,47,29.5,861,34,13,7,21,59,35,1501,34,16.5,6.5,27,72,44.5,2701,34,14,5.5,24,65,39,2021,58,15.5,7,28,70.5,50,3651,11,11.5,6,16.5,48,31,791,23,12,6.5,19,50,38,1481,70,15.5,7,28,76.5,55,4461,35,13.5,8.5,23,63.5,44,2121,16,10,4,15.5,48,26,601,16,10,5,15,41,26,641,17,11.5,5,17,53,30.5,1141,83,15.5,8,30.5,75,54,5141,18,12.5,8.5,18,57.3,32.8,1402,104,15.5,6.5,22,62,35,1662,100,13,7,21,70,41,2202,57,13.5,7,20,64,38,2042,53,12.5,6,18,58,31,1442,44,12.5,4.5,10.5,63,32,1402,20,11.5,5,17.5,52,29,1052,9,9,4.5,12,36,19,262,57,12.5,5,19,57.5,32,1252,81,13,5,20,61,33,1322,57,13,5.5,17.5,60.5,31,1162,45,13,6.5,21,60,34.5,1822,82,13.5,6.5,28,64,48,3562,70,14.5,6.5,26,65,48,3162,58,13.5,6.5,21.5,63,40,2022,11,9,5,15,46,27,622,83,14.5,7,23,61.5,44,2362,17,11.5,5,15,52.5,28,762,17,11,4.5,13,46,23,482,8,10,4.5,10,43.5,24,29
@@ -0,0 +1,121 @@
import papaya.*;

// Simple linear correlation example studying the fascinating relationship
// between tree volume and tree height

// --------------------- Sketch-wide variables ----------------------
PFont titleFont, smallFont;


float r; // correlation coefficient
float pValCorr; // correlation coefficient p-value
// Margin of error for the regression line
float slope, intercept;
String summary;

float[] treeGirth, treeHt, treeVol;
int minHt,maxHt,minVol,maxVol;

// ------------------------ Initialisation --------------------------

// Initialise the data
void setup()
{
size(800, 400);
smooth();
noLoop();

titleFont = createFont("Helvetica", 22, true);
smallFont = createFont("Helvetica", 11, true);
textFont(smallFont);

//Read in the data
// A data frame with 31 observations on 3 variables.
// Girth; Tree diameter in inches
// Height: Tree height in ft.
// Column: Volume of timber in cubic ft.
String lines[] = loadStrings("Trees.txt");

int ln = lines.length-1;
treeGirth = new float[ln];
treeHt = new float[ln];
treeVol = new float[ln];
for (int i=0; i<ln; i++) {
String[] pieces = splitTokens(lines[i+1], " ") ;
treeGirth[i] =Float.parseFloat( pieces[1]);
treeHt[i] = Float.parseFloat( pieces[2] );
treeVol[i] = Float.parseFloat( pieces[3] );
}

// construct the linear model.
float[] coeff = Linear.bestFit(treeHt,treeVol);
slope = coeff[0]; intercept = coeff[1];
r = Correlation.linear(treeHt,treeVol,false); // linear correlation coefficient
pValCorr = Correlation.Significance.linear(r,ln); // the p-value of r

// std error of the residual, slope and intercept.
float[] residuals = Linear.residuals(treeHt,treeVol,slope,intercept);
// df = n-2 since neither slope nor intercept was specified.
float residualErr = Linear.StdErr.residual(residuals,ln-2);
float slopeErr = Linear.StdErr.slope(treeHt,residualErr);
float interceptErr = Linear.StdErr.intercept(treeHt,residualErr);


// create a string containing the relevant statistics.
summary = "Correlation Coefficient, r = "+nfc(r, 2)+"\np-value: "+nfc(pValCorr,4);
summary = summary +",\nStandard Error in the residual: "+nfc(residualErr,1) +
"\nSlope: +/-"+nfc(slopeErr,3) +", Intercept: +/-"+nfc(interceptErr,3);
}

// ------------------ Processing draw --------------------

// Draws the graph in the sketch.
void draw()
{
background(255);

// draw the scatter plot of the data --------------------------
// (1): Setup your plot area.
LinearModelPlot lmPlot = new LinearModelPlot(this,60f,60f,width-120f,height-120f);
// (1): Once you've done this, you can set the plot parameters
// such as whether you want to draw the bounding rectangle,
// the background color, whether you want to draw the axes, etc.
// All variables have been left as "public" so you can edit them
// directly. Not exactly the best programming practice, but I figured
// better you behind the wheel rather than me. :)

// (2): Set the minimum/maximum values on the x and y axis to nice numbers.
// e.g. 60 instead of 63, 90 instead of 87, etc.
minHt = floor(min(treeHt)/10)*10; maxHt = ceil(max(treeHt)/10)*10;
minVol = floor(min(treeVol)/10-1)*10; maxVol = ceil(max(treeVol)/10+1)*10;
lmPlot.setDataExtremes(minHt,maxHt,minVol,maxVol);
lmPlot.bgColor=255;
// Draw the raw data
lmPlot.drawXY(treeHt,treeVol,color(50,80,200,150));
// Draw the best fit linear line.
float meanHt = Descriptive.mean(treeHt), meanVol = Descriptive.mean(treeVol);
lmPlot.drawBestFitLine(new float[]{slope,intercept}, new float[]{meanHt,meanVol},.15);

// write the x and y labels. Setting the first two elements to <0
// makes it default to writing the labels from the
// plot left to the plot right, and plot top to the bottom.
lmPlot.xLabels(-1f, -1f, minHt, maxHt, 6);
lmPlot.yLabels(-1f, -1f, minVol, maxVol, 5);

// labeling
textAlign(LEFT,TOP);
fill(120);
textFont(titleFont);
text("Tree Volume (cubic ft) vs. Tree Height (ft)", 70, 50);
float textHeight = 1.4*textAscent();
fill(200, 100, 100);
textFont(smallFont);
text(summary, 72, 50+textHeight);
}

void mousePressed() {
if (mousePressed) {
println(mouseX+","+mouseY);
}
}

@@ -0,0 +1,149 @@
/**
* Plots <code>x</code> vs <code>y</code> data and the best-fit linear
* line for that data.
* @author Adila Faruk
*/
public class LinearModelPlot extends Visuals {
private PApplet myParent;
boolean drawRectangle = true, drawAxes = true;

public float leftBound = 40, rightBound=20;
public float topBound = 20, bottomBound=20;

float minX, minY, maxX, maxY; // plot min/max
float minXDat, minYDat, maxXDat, maxYDat; // data min/max
boolean dataExtremesHaveBeenSet = false;

// best fit line
int sColor = color(200, 100, 100); // stroke color for the best fit line
float sWeight = 1; // stroke weight for the best fit line
boolean writeLineEquation = true;

/**Constructor */
public LinearModelPlot(PApplet _theParent, float _plotLeft, float _plotTop, float _plotWidth, float _plotHeight) {
super(_theParent, _plotLeft, _plotTop, _plotWidth, _plotHeight);
myParent = _theParent;
bgColor = super.bgColor;
}

/* Set the minimum/maximum values on the x and y axis to nice numbers.
E.g. 60 instead of 63.183628, 90 instead of 87.1, etc. */
public void setDataExtremes(float _minXDat, float _maxXDat, float _minYDat, float _maxYDat) {
minXDat = _minXDat;
maxXDat = _maxXDat;
minYDat = _minYDat;
maxYDat = _maxYDat;
dataExtremesHaveBeenSet = true;
}

/* Plots the scatter plot of the data.
x,y the x-y dataset of interest.
_fColor the color of the ellipses corresponding to each x-y pair
*/
public void drawXY( float[] x, float[] y, int _fColor) {
if (drawRectangle) {
drawRect(plotLeft-leftBound, plotTop-topBound, plotWidth+leftBound+rightBound, plotHeight+topBound+bottomBound, bgColor);
}
if (drawAxes) {
drawAxes(50, .5f);
}
// Check if the data extemes have been set.
if (!dataExtremesHaveBeenSet) {
throw new IllegalStateException("Set the data extremes first.");
}

// map the data.
float[] xDatMapped = Mat.map(x, minXDat, maxXDat, plotLeft, plotLeft+plotWidth);
float[] yDatMapped = Mat.map(y, minYDat, maxYDat, plotTop+plotHeight, plotTop);
minX = Descriptive.min(xDatMapped);
maxX = Descriptive.max(xDatMapped);
minY = Descriptive.min(yDatMapped);
maxY = Descriptive.max(yDatMapped);
myParent.fill(_fColor);
myParent.noStroke();
myParent.smooth();
for (int i=0; i<xDatMapped.length; i++) {
myParent.ellipse(xDatMapped[i], yDatMapped[i], 4, 4);
}
}

/*
* function that plots the best fit linear line going from <code>x1,y1</code> to <code>x2,y2</code>.
*
* The multiplier <code>c</code> ( 0 <= c<= 0.5 ) is chosen such that
* the points (x1,y1) and (x2,y2) are in the rectangle with corners
*
* (meanX-c*rangeX/2, meanY+c*rangeY/2) (meanX+c*rangeX/2, meanY+c*rangeY/2)
*
* (meanX-c*rangeX/2, meanY-c*rangeY/2) (meanX+c*rangeX/2, meanY-c*rangeY/2)
*
* where
* rangeX = _maxX - _minX
* and
* rangeY = _maxY - _minY.
* This is done in the most inefficient way possible in the universe... :)
* @param coeff, the slope and intercept where coeff[0] = slope, coeff[1] = intercept
* @param meanVals = float[]{mean(x),mean(y)}}
* @param multiplier corresponds to <code>c</code> above and is the multiplier to use when plotting
* the line. A smaller c value results in a longer line. The default it set to .15, and will be used if a
* value of c<= 0 or c >=.50 is entered.
*/
public void drawBestFitLine(float[] coeff, float[] meanVals, float multiplier) {
// Check if the data extemes have been set.
if (!dataExtremesHaveBeenSet) {
throw new IllegalStateException("Set the data extremes first.");
}

float meanX = meanVals[0];
float meanY = meanVals[1];
float x1, y1, x2, y2;
float slope = coeff[0];
float intercept = coeff[1];
float mult;
if (multiplier<0 || multiplier>=.5) {
mult = .15f;
}
else mult = 1-multiplier;

x1 = (meanX+mult*(minXDat-meanX));
y1= slope*(x1)+intercept;
x2 = (meanX+mult*(maxXDat-meanX));
y2= slope*(x2)+intercept;
if (slope!=0) {
// if the intercept b is less than the minimum y value
// update the left-most point
if (y1<meanY+mult*(minYDat-meanY)) {
y1 = meanY+mult*(minYDat-meanY);
x1 = (y1-intercept)/slope;
}
// Rightmost point:
// if the y point exceeds the maximum value,
// update the x and y coordinates
if (y2>meanY+mult*(maxYDat-meanY)) {
y2 = meanY+mult*(maxYDat-meanY);
x2 = (y2-intercept)/slope;
}
}

// map to the plot parameters
float[] xFit = Mat.map(new float[] {x1, x2}, minXDat, maxXDat, minX, maxX);
float[] yFit = Mat.map(new float[] {y1, y2}, minYDat, maxYDat, maxY, minY);
// draw the line
line(xFit[0], yFit[0], xFit[1], yFit[1], sColor, sWeight);

// draw an ellipse at the mean value.
meanX = Mat.map(meanX, minXDat, maxXDat, minX, maxX);
meanY = Mat.map(meanY, minYDat, maxYDat, maxY, minY);
myParent.fill(sColor);
myParent.noStroke();
myParent.ellipse(meanX, meanY, 6, 6);

if (writeLineEquation) {
if (yFit[1]<yFit[0]) myParent.textAlign(CENTER, BOTTOM);
else myParent.textAlign(CENTER, TOP);
String label = "y = "+myParent.nfc(slope, 2)+"x + ( "+myParent.nfc(intercept, 2)+" )";
writeLabels(label, xFit[1], yFit[1]);
}
}
}

@@ -0,0 +1,32 @@
Trees Girth Height Volume
1 8.3 70 10.3
2 8.6 65 10.3
3 8.8 63 10.2
4 10.5 72 16.4
5 10.7 81 18.8
6 10.8 83 19.7
7 11.0 66 15.6
8 11.0 75 18.2
9 11.1 80 22.6
10 11.2 75 19.9
11 11.3 79 24.2
12 11.4 76 21.0
13 11.4 76 21.4
14 11.7 69 21.3
15 12.0 75 19.1
16 12.9 74 22.2
17 12.9 85 33.8
18 13.3 86 27.4
19 13.7 71 25.7
20 13.8 64 24.9
21 14.0 78 34.5
22 14.2 80 31.7
23 14.5 74 36.3
24 16.0 72 38.3
25 16.3 77 42.6
26 17.3 81 55.4
27 17.5 82 55.7
28 17.9 80 58.3
29 18.0 80 51.5
30 18.0 80 51.0
31 20.6 87 77.0
@@ -0,0 +1,60 @@
/** (very rudimentary!) class for drawing a heatmap representring the distance matrix.
No permuting of rows/columns to reveal structure or anything like that.
Just takes in a matrix and plots the values as colors.*/

public class HeatMap extends Visuals{

public float wEach = 0; public float hEach = 0;
/** Constructor */
public HeatMap(PApplet parent, float xLeft, float yTop, float xWidth, float yHeight){
super(parent,xLeft,yTop,xWidth,yHeight);
}

// input the data and specify the min and max values for the color mapping
void drawHeatMap(float[][] input, float minVal, float maxVal){
int numRows = input.length;
int numColumns = input[0].length;
wEach = xWidth/numColumns; hEach = yHeight/numRows;

// transform the distance matrix into a matrix of colors with darker colors
// corresponding to larger distances. To do this, we call the 'mapToColorScale' function
// Note: This is actually a bad use of color. The scaling should
// vary with the cube-root of the value!
int[][] colors = mapToColorScale(input,minVal,maxVal);

// label the rows
textFont(tinyFont);
textAlign(CENTER,CENTER);
for(int i=0; i<numRows; i++){
fill(100);
text(i, xLeft-10, yTop+(i+.5)*hEach);
}
for(int j=0; j<numColumns; j++) {
text(j+1, xLeft + (j+.5)*wEach, yTop+yHeight+5);
}

for(int i=0; i<numRows; i++){
for(int j=0; j<numColumns; j++){
fill(colors[i][j]); noStroke();
rect(xLeft + j*wEach, yTop+i*hEach,wEach,hEach);
}
}
}
}

// maps the input data from 0 to the specified maximum and returns an array of ints corresponding to the colors
int[][] mapToColorScale(float[][] input, float minVal, float maxVal){
int[] blues = new int[]{0xfff7fbff,0xffdeebf7,0xffc6dbef,0xff9ecae1,0xff6baed6,0xff4292c6,0xff2171b5,0xff08519c,0xff08306b};
blues = reverse(blues); // darker = smaller
int numRows = input.length; int numColumns = input[0].length;
int[][] output = new int[numRows][numColumns];
for(int i=0; i<numRows; i++){
for(int j=0; j<numColumns; j++){

int idx = floor(map(input[i][j],minVal,maxVal,0,7));
output[i][j] = blues[idx];
}

}
return output;
}
@@ -0,0 +1,126 @@
/*
Example showing how to compute Distance matrices using the Distance
method, and then apply them using the MDS class.
The dataset consists of Bear Measurements (why not, right?).
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

String[] columnTitles;
int numColumns, numObs, numM, numF; // number of columns, and number of observations for each column
float[][] data; float[] age;// bear data



void setup() {
size(800, 630);
noLoop();

parseData("BEARS.csv");
int numDecimals =4;
// Euclidian distance matrix.
float[][] euclidean = Distance.euclidean(data);
println("\n\nFirst 10 elements of the Euclidian distance Matrix");
Mat.print(Mat.subMatrix(euclidean, 0, 9, 0, 9), numDecimals);

// Standardized Euclidian distance matrix.
float[][] seuclidian = Distance.seuclidean(data);
println("\n\nFirst 10 elements of the standardized Euclidian distance Matrix");
Mat.print(Mat.subMatrix(seuclidian, 0, 9, 0, 9), numDecimals);

// Cityblock or Manhattan distance matrix
float[][] cityblock = Distance.cityblock(data);
println("\n\nFirst 10 elements of the Cityblock distance Matrix");
Mat.print(Mat.subMatrix(cityblock, 0, 9, 0, 9), numDecimals);
// other options: minkowski, mahalanobis, correlation, spearman, chebychev
float[][] chebychev = Distance.chebychev(data);
float[][] correlation = Distance.correlation(data);
float[][] mahalanobis = Distance.mahalanobis(data);
float[][] minkowski = Distance.minkowski(data,3); // cubic
float[][] spearman = Distance.spearman(data);
println("\n\nFirst 10 elements of the Spearlman distance Matrix");
Mat.print(Mat.subMatrix(spearman, 0, 9, 0, 9), numDecimals);
// use Mat.print to print the results out.
}

// Drawing --------------------------------------------------
float xLeft = 60, yTop = 90, xWidth = 700, yHeight = 630-140;
color r=color(200, 50, 80, 200); // green
color b =color(50, 80, 250, 150); // blue
color g=color(50, 200, 100, 200); // green
color backgroundColor = color(250);
// font
PFont titleFont = createFont("Helvetica", 15, true);
PFont smallFont = createFont("Helvetica", 12, true);
PFont tinyFont = createFont("Helvetica", 10, true);


void draw() {
background(255);
// draws a heat map of the data with darker colors indicating closer distances,
HeatMap h = new HeatMap(this, xLeft, yTop, xWidth, yHeight);
// use the euclidean distance matrix. You can also try out one of the other
// distance matrices, but make sure to update the min/max values or the
// colors won't come out right.
float[][] distanceMat = Distance.euclidean(data);
h.drawHeatMap(distanceMat,0f,Descriptive.max(distanceMat));
// Those two bands you see correspond to male and female bands. The
// smaller grouping within them is because I've sorted the data by age
// --> same-age bears are more similar.

// NOTE:
// You can also use the MDS.classical scaling method to find the x-y configuration
// of points which capture most of the variation in the distances.
// Since the input distance matrix is euclidean,
// the output coordinates are exactly the first p principal coordinate components.
// Set p = 2 to plot the results in a plane.
/*
float[][] cmdscale = MDS.classical(euclidean, 2,false);
x = new float[cmdscale.length]; y = new float[cmdscale.length];
x = Mat.column(cmdscale,0); y = Mat.column(cmdscale,1);
//and then plot x vs y //
*/

// Labeling --------------------------
textFont(titleFont);
fill(50,90,200);
textAlign(LEFT,BOTTOM); smooth();
text("Euclidian Distance Metrics Between Bears." , xLeft, yTop-40);
textAlign(LEFT, TOP);
textFont(smallFont);
text("Darker colors indicate closer distances showing bears which are more 'similar'.\n"+
"(Try sorting the csv file by something other than weight to see if you can find other patterns.)",
xLeft,yTop-35);
}

// parses the input file and organize the data
public void parseData(String fileName) {
// SEX AGE HEADLEN HEADWTH NECK LENGTH CHEST WEIGHT
String[] s= loadStrings(fileName);
columnTitles = splitTokens(s[0], ",");
columnTitles = subset(columnTitles, 1, columnTitles.length-1); // remove the column containing the sex
numObs = s.length-1;
numM = 35;
numF = numObs - numM;
numColumns = columnTitles.length;
data = new float[numObs][numColumns];
age = new float[numObs];
// read in the rest of the data
for (int i=0; i<numObs; i++) {
String[] pieces = splitTokens(s[i+1], ",");
age[i] = Float.parseFloat(pieces[1]);
for (int j=0; j<numColumns; j++) {
// the raw data
data[i][j] = Float.parseFloat(pieces[j+1]);
}
}

float[] means = Descriptive.Mean.columnMean(data);
float[] stds = Descriptive.std(data,false); // division by n
data = Descriptive.zScore(data,means,stds);
}



@@ -0,0 +1 @@
Sex,Age,HeadLn,HeadWd,Neck,Length,Chest,Weight1,8,9,4.5,13,37,19,341,9,10,4,13,40,23,401,9,10,4,13.5,43,23,461,10,9.5,4.5,16,40,26,651,10,11.5,5,17,47,29.5,861,10,11,5,17,49,29,941,11,11.5,6,16.5,48,31,791,16,10,4,15.5,48,26,601,16,10,5,15,41,26,641,17,11.5,5,17,53,30.5,1141,18,12.5,8.5,18,57.3,32.8,1401,19,11,5.5,16,53,26,801,21,13,5,17,54,28,901,21,13,6,19,59,30,1201,21,14.5,5.5,20,61,34,1501,23,12,6.5,19,50,38,1481,32,13,8,21.5,59,33,1661,32,14,5,21.5,67,37,1801,33,13.5,6,22,66.5,34,1541,34,13,7,21,59,35,1501,34,14,5.5,24,65,39,2021,34,16.5,6.5,27,72,44.5,2701,35,13.5,8.5,23,63.5,44,2121,45,13.5,7,24,64,39,2041,45,16,6,24,63,42,2201,51,13.5,8,27,68.5,49,3601,55,16.5,9,28,67.5,45,3441,56,15,7.5,26.5,73.5,41,2621,58,15.5,7,28,70.5,50,3651,68,16,9,29,73,44,3321,70,15.5,7,28,76.5,55,4461,81,15.5,8,31,72,54,4161,83,15.5,8,30.5,75,54,5141,115,17,10,31.5,72,49,3481,177,16,9.5,30,72,48,4362,8,10,4.5,10,43.5,24,292,9,9,4.5,12,36,19,262,11,9,5,15,46,27,622,17,11,4.5,13,46,23,482,17,11.5,5,15,52.5,28,762,20,11.5,5,17.5,52,29,1052,44,12.5,4.5,10.5,63,32,1402,45,13,6.5,21,60,34.5,1822,53,12.5,6,18,58,31,1442,57,13,5.5,17.5,60.5,31,1162,57,12.5,5,19,57.5,32,1252,57,13.5,7,20,64,38,2042,58,13.5,6.5,21.5,63,40,2022,70,14.5,6.5,26,65,48,3162,81,13,5,20,61,33,1322,82,13.5,6.5,28,64,48,3562,83,14.5,7,23,61.5,44,2362,100,13,7,21,70,41,2202,104,15.5,6.5,22,62,35,166
@@ -0,0 +1,111 @@
/*
Example showing how to use Anova
-------------------------------------------------------
File/Data: 3Stooges (Similar to SAS's three_stooges.sas)
study design:
college freshmen were asked to specify their
favorite member of the three stooges, they also
completed two questionniares, one measuring the
amount of brain damage and the other, the
amount of stupidity. (This is (honest to God), an actual
dataset I found online. Awesome, huh?) :)
garbage<-read.csv("/Users/adilapapaya/Desktop/Downloads/TrioloDatasets/GARBAGE.csv",header=TRUE,sep=",")
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

String[] columnTitles;
int numColumns, numObs; // number of columns, and number of observations for each column
String[] sNames = new String[]{"Moe","Larry","Curly"};
Stooge[] stooge = new Stooge[3];

void setup() {
size(500, 500);
noLoop();
float[][] data = parseData("3Stooges.csv");
// create the tree stooge classes
for(int i:new int[]{0,1,2}){
stooge[i] = new Stooge(sNames[i], data, 25*i, 25);
}

// create an array list with each element corresponding to a float array
ArrayList<float[]>BD = new ArrayList<float[]>(); // brain damage
ArrayList<float[]>SI = new ArrayList<float[]>(); // stupidity index
for(int i=0; i<3; i++){
BD.add(stooge[i].bDamage);
SI.add(stooge[i].sIndex);
}
// cast the ArrayList to the "Collection" interface.
OneWayAnova anovaBD = new OneWayAnova((Collection<float[]>)BD);
OneWayAnova anovaSI = new OneWayAnova((Collection<float[]>)SI);
println("p-value for testing the null hypothesis of no difference in brain damage: "+ anovaBD.pValue());
println("p-value for testing the null hypothesis of no difference in stupidity index: "+ anovaSI.pValue());
}


// Drawing --------------------------------------------------
float xLeft = 40, yTop = 40, xWidth = 420, yHeight = 420;
color b =color(50,80,250,150); // blue
color g= color(50,200,100,200); // green
color r= color(200,100,100,200); // red
int[] stoogeColor = new int[]{r,g,b};
color backgroundColor = color(250);
// font
PFont titleFont = createFont("Helvetica", 15, true);
PFont smallFont = createFont("Helvetica", 12, true);

void draw(){
background(255);
ScatterPlot s = new ScatterPlot(this,xLeft,yTop,xWidth,yHeight);
s.setDataExtremes(0,70,0,70);
s.drawRectangle=false;
smooth();
for(int i=0; i<3; i++){
s.drawScatterPlot(stooge[i].bDamage,stooge[i].sIndex,0,stoogeColor[i]);
}
textFont(smallFont); fill(100);
text("Leaving the labeling in your hands...",50,60);
}

// create a "stooge" class to store the brain damage and stupidity index, by stooge.

public class Stooge{
float[] bDamage, sIndex;
String name;
int ln; // number of observations in that group

// get the data from idxStart(inclusive) to idxEnd
public Stooge(String name, float[][] data, int iStart,int ln){
this.ln = ln;
this.name = name;
this.bDamage = new float[ln]; this.sIndex = new float[ln];
for(int i=0; i<ln; i++){
int idx = iStart+i; // get the index corresponding to that stooge
bDamage[i] = data[idx][0]; sIndex[i] = data[idx][1];
}
}

}

// parses the input file and organize the data
public float[][] parseData(String fileName){
String[] s= loadStrings(fileName);
columnTitles = splitTokens(s[0], ",");
numObs = s.length-1;
numColumns = columnTitles.length;
float[][] data = new float[numObs][ numColumns-1];
// read in the rest of the data
for (int i=0; i<numObs; i++) {
String[] pieces = splitTokens(s[i+1], ",");
for (int j=1; j<numColumns; j++) {
// the raw data
data[i][j-1] = Float.parseFloat(pieces[j]);
}
}
return data;
}

@@ -0,0 +1 @@
Favorite,Brain Damage,Stupidity IndexMoe,27,21Moe,29,41Moe,47,48Moe,28,15Moe,22,26Moe,42,31Moe,25,15Moe,27,30Moe,23,26Moe,24,31Moe,21,23Moe,50,47Moe,22,26Moe,39,22Moe,9,28Moe,30,17Moe,22,33Moe,45,43Moe,34,39Moe,30,32Moe,19,20Moe,36,27Moe,32,19Moe,32,25Moe,27,19Larry,31,21Larry,48,42Larry,25,43Larry,23,11Larry,10,8Larry,26,27Larry,18,20Larry,32,39Larry,13,0Larry,39,24Larry,22,15Larry,28,27Larry,29,35Larry,13,23Larry,32,31Larry,21,28Larry,10,9Larry,41,36Larry,13,15Larry,40,37Larry,37,37Larry,9,14Larry,24,7Larry,32,8Larry,21,12Curly,39,43Curly,28,36Curly,26,31Curly,16,18Curly,23,29Curly,40,37Curly,38,38Curly,42,46Curly,23,28Curly,22,21Curly,38,35Curly,31,26Curly,29,43Curly,45,51Curly,44,47Curly,26,18Curly,30,30Curly,31,35Curly,20,26Curly,27,44Curly,34,34Curly,38,28Curly,23,32Curly,28,26Curly,47,64
@@ -0,0 +1,44 @@
/*
Getting the rank of the elements of an array using various strategies
for the tied values.
Adila Faruk, 2012.
*/
// import the library
import papaya.*;

// create a few different types of data points
int ln = 50;
// create a y matrix, consisting of 4 rows
float[] y = new float[ln];
float[] x = new float[ln];


for (int i=0; i<ln; i++) {
x[i] = i+1;
y[i] = round(random(-10, 10)); // so we'll get whole numbers
}

/*
Rank the elements of y[0] in ascending order.
*/
//Tied values are assigned the average of the applicable ranks
float[] rankTiesAveraged = Rank.rank(y, 0);
//Tied values are assigned the minimum applicable rank ( = the rank of the first appearance)
float[] rankTiesSetToMin = Rank.rank(y, 1);
//Tied values are assigned the maximum applicable rank ( = the rank of the last appearance)
float[] rankTiesSetToMax = Rank.rank(y, 2);
//Tied values are assigned ranks in order of occurrence in the original array
float[] rankTiesSetToSequential = Rank.rank(y, 3);

// print the results to the screen
println("\n\nRanks of the elements of y[0] (smaller elements are ranked lower):\n");
for(int i=0; i<ln; i++){
println("y["+i+"] = " +y[i]);
println("Rank method: Averages, rank["+i+"] = " + rankTiesAveraged[i]);
println("Rank method: Minimum, rank["+i+"] = " + rankTiesSetToMin[i]);
println("Rank method: Maximum, rank["+i+"] = " + rankTiesSetToMax[i]);
println("Rank method: Sequential, rank["+i+"] = " + rankTiesSetToSequential[i]+"\n");
}

@@ -0,0 +1,75 @@
/*Simple example showing the ScatterPlot functions
*/
// import the library
import papaya.*;

// define a "Stats" variable


// create a few different types of data points
int ln = 100;
float[] yDat = new float[ln];
float[] xDat = new float[ln];

// font
PFont font = createFont("Helvetica", 12, true);

void setup() {
size(500, 200);
smooth();
noLoop();
}

// plot parameters
float plotLeft = 60, plotTop = 90;
float plotWidth = 400;
color meanColor = color(100, 100, 200);
color medianColor = color(200, 100, 100);

void draw() {
background(color(255));
textFont(font, 12);
fill(50);
smooth();
textAlign(LEFT, TOP);
text("Randomly Generated Data. Press any key to Regenerate.", 20, 10);

for (int i=0; i<ln; i++) {
xDat[i] = i+1;
yDat[i] = i+1 + random(-50, 50); // yData is unmapped
}

// define the scatter plot dimensions
ScatterPlot scatter = new ScatterPlot(this, plotLeft, plotTop, plotWidth, 50f);
// some setup stuff before we do the drawing.
// you can also set these to false now, and then
// call the drawRectangle and drawAxes functions directly
// after you're done plotting the data if you want
// more control over the parameters.
scatter.drawRectangle=true; // draw the bounding rectangle
scatter.drawAxes=true; // draw the axes

scatter.setDataExtremes(-10f, ln+10f, -100f, ln+50f);
scatter.asConnectedLines = true;
scatter.asEllipses = false;
scatter.drawScatterPlot(xDat, yDat, 1, color(200, 100, 0, 100));
textFont(font,12);
scatter.writeTitle("y = x + random(-50,50)",font);

// x and y labels.
// The first two variables (left,width), (top,height)
// are set to negative values to invoke the default
// (plotLeft,plotWidth), (plotTop,plotHeight)
scatter.xLabels(-1f, -1f, -10f, ln+10f, 5);
scatter.yLabels(-1f, -1f, -100f, ln+50f, 5);
}

void keyPressed() {
if (keyPressed) {
// don't redraw when the Apple/Command key is pressed though.
if (keyCode!=157) {
redraw();
}
}
}

@@ -0,0 +1,42 @@
/*
Illustrative example showing how to sort multiple arrays while preserving the order
of the original arrays by using the Sorting.indices method.
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

// create a few different types of data points
int ln = 50;
float[] x = new float[ln];
float[] y = new float[ln];

for (int i=0; i<ln; i++) {
x[i] = i+1;
y[i] = round(random(-10, 10)); // so we'll get whole numbers
}
// yPoly = 1.2x^2 + 5
float[] yPoly = Polynomial.polyval(x, new float[] {1.2, 0, 5});



/*
Sort yPoly according to y sorted in ascending order.
To do this, we get the indices corresponding to the sorted y0
and apply them to the remaining arrays.
*/
int[] indices = Sorting.indices(y,true); // true = sorted ascending, false = sorted descending.
// print the results to screen.
println("\n\ny and yPoly, in y's ascending order:\n");
for(int i=0; i<ln; i++){
print("y[indices["+i+"]] = " +y[indices[i]]);
print(", \t yPoly[indices["+i+"]] = " + yPoly[indices[i]]+"\n");
}





@@ -0,0 +1,149 @@
/*
Example showing how to use the Unique class
The dataset consists of Garbage collected from a number of different households.
To load the file into R, use
garbage<-read.csv("/Users/adilapapaya/Desktop/Downloads/TrioloDatasets/GARBAGE.csv",header=TRUE,sep=",")
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

// font
PFont titleFont = createFont("Helvetica", 15, true);
PFont smallFont = createFont("Helvetica", 12, true);
PFont tinyFont = createFont("Helvetica", 9, true);

String[] columnTitles;
int numColumns, numObs; // number of columns, and number of observations for each column
float[][] data; // data by household size
float[][] indivTrash; // data normalized by the household size.
float[][] pctTotal; // individual trash production, as a % of total individual trash.
float[] maxVal;
Unique u; //Initialize the Unique class

void setup() {
size(500, (int)yTop+(int)yHeight+60);
noLoop();
parseData("GARBAGE.csv");
// Get the unique (or distinct) household sizes and their frequencies.
// Since we want to store the indices, set the "storeIndices" to true.
u = new Unique(Mat.column(data,0),true);
}


// Drawing --------------------------------------------------
int currentTrash = 1; // the type of trash to visualize
float xLeft = 40, yTop = 90, xWidth = 420, yHeight = 560;
color low =color(50,80,250,150); color high =color(250,50,100,200);


void draw(){
background(255);
// Create a visuals class for convenient x and y labeling, tick marks, etc
Visuals v = new Visuals(this,xLeft,yTop,xWidth,yHeight);
v.drawRect();
int uSize = u.values.size();
float xPos;
noStroke(); smooth();
float cutoff = (maxVal[currentTrash]*.75); // cutoff for whether to highlight the value or not.

for(int i=0; i<uSize; i++){
xPos = 50*(i+1);
for(int j=0; j< u.frequencies.get(i); j++){
// access the values of the individual matrices by household
// size by using the stored indices.
int idx = u.idx[i][j]; // idx corresponding to a household of size values.get(i).
float value = indivTrash[idx][currentTrash]; // the numeric value
float pct = pctTotal[idx][currentTrash]; // the value expressed as a pct of the total trash produced by the individuel
pct = map(pct,0,.5,yTop+yHeight,yTop);
if (value > cutoff){
fill(50); textFont(tinyFont); textAlign(LEFT,CENTER);
text(nfc(value,1)+" kg", xPos + 3, pct);
fill(high);
}
else {
fill(low);
}
ellipse(xPos,pct,4,4);
}
}

// Labeling. Messy. Feel free to ignore.
String[] xLabels = new String[uSize];
for(int i=0; i<uSize; i++){
xLabels[i] = str(u.values.get(i));
}
v.xLabels(xLeft+10, xWidth-20,xLabels );
v.yLabels(yTop+5,yHeight-10, 0, 50, 10);

textFont(titleFont); fill(100); smooth();
textAlign(LEFT,TOP);
text("Is Individual Trash Production* Influenced by Household Size?", xLeft ,20);

String category = "Category: "+ columnTitles[currentTrash+1];
textAlign(CENTER,BOTTOM); textFont(titleFont); fill(50,80,200);
text( "Category: "+ columnTitles[currentTrash+1],xLeft+xWidth/2,yTop-5);

textFont(tinyFont); textAlign(LEFT,TOP); fill(100);
String explanation = "*Indiv. trash production computed as (household trash) / (household size)."+
"\n Pct.Total expressed as a pct. of the total trash produced by an indiv."+
"\n in a household of specified size."+
"\n Trash amounts within 75% of the maximum value of "+nfc(maxVal[currentTrash],1)+" kgs are highlighted";
text(explanation, xLeft+10,yTop+10);
text("(PressUP/DOWN to change category.)", xLeft, 40);

// x and y labels
textAlign(CENTER,TOP);
textFont(smallFont);
text("Household Size", xLeft + xWidth/2, yTop + yHeight+20);
text("% Total", xLeft, yTop-15);
}

void keyPressed(){
if(keyCode==UP){
// exclude "TOTAL" since that goes waaaay out of the plot limits.
if(currentTrash<numColumns-3){
currentTrash++;
redraw();
}
}
if(keyCode==DOWN){
if(currentTrash>0){
currentTrash--;
redraw();
}
}
}

// parses the input file
public void parseData(String fileName){
// HHSIZE METAL PAPER PLAS GLASS FOOD YARD, TEXT OTHER TOTAL
String[] s= loadStrings(fileName);
columnTitles = splitTokens(s[0], ",");
numObs = s.length-1;
numColumns = columnTitles.length;
data = new float[numObs][ numColumns];
indivTrash = new float[numObs][ numColumns-1]; // excludes the hhsize column
pctTotal = new float[numObs][numColumns-1]; // excludes the hhsize column
// read in the rest of the data
for (int i=0; i<numObs; i++) {
String[] pieces = splitTokens(s[i+1], ",");
data[i][0] = Float.parseFloat(pieces[0]); //HHSize
data[i][numColumns-1] = Float.parseFloat(pieces[numColumns-1]); // total trash
for (int j=1; j<numColumns-1; j++) {
// the raw data
data[i][j] = Float.parseFloat(pieces[j]);
// the data normalized by the household size.
indivTrash[i][j-1] = data[i][j]/data[i][0];
pctTotal[i][j-1] = indivTrash[i][j-1] / data[i][numColumns-1];
}
}

// store the max value of each column
maxVal = new float[numColumns-1];
for(int i=0; i<numColumns-1; i++){
maxVal[i] = Descriptive.max(Mat.column(indivTrash,i));
}
}

@@ -0,0 +1 @@
HHSize,Metal,Paper,Plastic,Glass,Food,Yard,Text,Other,Total2,1.09,2.41,0.27,0.86,1.04,0.38,0.05,4.66,10.763,1.04,7.57,1.41,3.46,3.68,0,0.46,2.34,19.963,2.57,9.55,2.19,4.52,4.43,0.24,0.5,3.6,27.66,3.02,8.82,2.83,4.92,2.98,0.63,2.26,12.65,38.114,1.5,8.72,2.19,6.31,6.3,0.15,0.55,2.18,27.92,2.1,6.96,1.81,2.49,1.46,4.58,0.36,2.14,21.91,1.93,6.83,0.85,0.51,8.82,0.07,0.6,2.22,21.835,3.57,11.42,3.05,5.81,9.62,4.76,0.21,10.83,49.276,2.32,16.08,3.42,1.96,4.41,0.13,0.81,4.14,33.274,1.89,6.38,2.1,17.67,2.73,3.86,0.66,0.25,35.544,3.26,13.05,2.93,3.21,9.31,0.7,0.37,11.61,44.447,3.99,11.36,2.44,4.94,3.59,13.45,4.25,1.15,45.173,2.04,15.09,2.17,3.1,5.36,0.74,0.42,4.15,33.075,0.99,2.8,1.41,1.39,1.47,0.82,0.44,1.03,10.356,2.96,6.44,2,5.21,7.06,6.14,0.2,14.43,44.442,1.5,5.86,0.93,2.03,2.52,1.37,0.27,9.65,24.134,2.43,11.08,2.97,1.74,1.75,14.7,0.39,2.54,37.64,2.97,12.43,2.04,3.99,5.64,0.22,2.47,9.2,38.963,1.42,6.05,0.65,6.26,1.93,0,0.86,0,17.173,3.6,13.61,2.13,3.52,6.46,0,0.96,1.32,31.62,4.48,6.98,0.63,2.01,6.72,2,0.11,0.18,23.112,1.36,14.33,1.53,2.21,5.76,0.58,0.17,1.62,27.564,2.11,13.31,4.69,0.25,9.72,0.02,0.46,0.4,30.961,0.41,0.27,0.15,0.09,0.16,0,0,0,1.084,2.02,6.67,1.45,6.85,5.52,0,0.68,0.03,23.226,3.27,17.65,2.68,2.33,11.92,0.83,0.28,4.03,42.9911,4.95,12.73,3.53,5.45,4.68,0,0.67,19.89,51.93,1,9.83,1.49,2.04,4.76,0.42,0.54,0.12,20.24,1.55,16.39,2.31,4.98,7.85,2.04,0.2,1.48,36.83,1.41,6.33,0.92,3.54,2.9,3.85,0.03,0.04,19.022,1.05,9.19,0.89,1.06,2.87,0.33,0.01,0.03,15.432,1.31,9.41,0.8,2.7,5.09,0.64,0.05,0.71,20.712,2.5,9.45,0.72,1.14,3.17,0,0.02,0.01,17.014,2.35,12.32,2.66,12.24,2.4,7.87,4.73,0.78,45.356,3.69,20.12,4.37,5.67,13.2,0,1.15,1.17,49.372,3.61,7.72,0.92,2.43,2.07,0.68,0.63,0,18.062,1.49,6.16,1.4,4.02,4,0.3,0.04,0,17.412,1.36,7.98,1.45,6.45,4.27,0.02,0.12,2.02,23.672,1.73,9.64,1.68,1.89,1.87,0.01,1.73,0.58,19.132,0.94,8.08,1.53,1.78,8.13,0.36,0.12,0.05,20.993,1.33,10.99,1.44,2.93,3.51,0,0.39,0.59,21.183,2.62,13.11,1.44,1.82,4.21,4.73,0.64,0.49,29.062,1.25,3.26,1.36,2.89,3.34,2.69,0,0.16,14.952,0.26,1.65,0.38,0.99,0.77,0.34,0.04,0,4.433,4.41,10,1.74,1.93,1.14,0.92,0.08,4.6,24.826,3.22,8.96,2.35,3.61,1.45,0,0.09,1.12,20.84,1.86,9.46,2.3,2.53,6.54,0,0.65,2.45,25.794,1.76,5.88,1.14,3.76,0.92,1.12,0,0.04,14.623,2.83,8.26,2.88,1.32,5.14,5.6,0.35,2.03,28.413,2.74,12.45,2.13,2.64,4.59,1.07,0.41,1.14,27.1710,4.63,10.58,5.28,12.33,2.94,0.12,2.94,15.65,54.473,1.7,5.87,1.48,1.79,1.42,0,0.27,0.59,13.126,3.29,8.78,3.36,3.99,10.44,0.9,1.71,13.3,45.775,1.22,11.03,2.83,4.44,3,4.3,1.95,6.02,34.794,3.2,12.29,2.87,9.25,5.91,1.32,1.87,0.55,37.267,3.09,20.58,2.96,4.02,16.81,0.47,1.52,2.13,51.585,2.58,12.56,1.61,1.38,5.01,0,0.21,1.46,24.814,1.67,9.92,1.58,1.59,9.96,0.13,0.2,1.13,26.182,0.85,3.45,1.15,0.85,3.89,0,0.02,1.04,11.254,1.52,9.09,1.28,8.87,4.83,0,0.95,1.61,28.152,1.37,3.69,0.58,3.64,1.78,0.08,0,0,11.142,1.32,2.61,0.74,3.03,3.37,0.17,0,0.46,11.7
@@ -0,0 +1,88 @@
/*
Shows how to use the various probability distribution functions in the
papaya.Probability class.
*/

import papaya.*;
// ------------------------------------------------------------------------
double x = 0.90; // corresponds to the point on the distribution curve.

// beta, betaComplemented and betaInverse
double beta_a = random(0,10), beta_b = random(0,10);
/* Area from zero to x under the beta density function. */
double beta = Probability.betacdf(x,beta_a,beta_b);
/* Area from x to infinity under the beta density function. */
double betaComplemented = Probability.betacdfComplemented(x,beta_a,beta_b);
/* Find x such that Probability.beta(a, b, x) = y; y here corresponds to beta */
double betaInverse = Probability.betainv(beta,beta_a,beta_b);

/* Print the results to screen */
println("Beta probability distribution (x = " +(float)x+", a =" +(float)beta_a+" and b = "+(float)beta_b+")");
println("Probability.betacdf(x,a,b): "+(float)beta+", "+"Probability.betacdfComplemented(x,a,b): "+(float)betaComplemented);
println("x, computed using the betainv function: "+(float)betaInverse);


// ------------------------------------------------------------------------
// chi2cdf, chi2cdfComplemented.
/* Note: Probability.chi2cdf is equivalent to the pchisq function in R*/

int df = floor(random(0,50));
/* Area from 0 to x of the Chi square probability density function with df degrees of freedom. */
double chiSquare = Probability.chi2cdf(x,df);
/* Area from x to infinity under the chi square probability density function with df degrees of freedom. */
double chiSquareComplemented = Probability.chi2cdfComplemented(x,df);

/* Print the results to screen */
println("\nChi square probability distribution (x = " +(float)x+", with "+df+" degrees of freedom)");
println("Probability.chiSquare(x,df): "+(float)chiSquare+", "+"Probability.chiSquareComplemented(x,df): "+(float)chiSquareComplemented);
//println("x, computed using the betaInverse function: "+betaInverse);

// ------------------------------------------------------------------------
// F, FComplemented, FInverse.
/* Note: Probability.fcdf(x) is equivalent to pf in R
Probability.finv(x) is equivalent to qf in R */
int df1 = floor(random(1,20)); int df2 = floor(random(1,20));
/* Area from 0 to x of the F probability density function with degrees of freedom df1 and df2 */
double FDistr = Probability.fcdf(x,10,5);
/* Area from x to infinity under the F probability density function with df degrees of freedom. */
double FComplemented = Probability.fcdfComplemented(x,df1, df2);
/* Find x such that Probability.F(df1, df2, x) = y; y here corresponds to FDistr */
double FInverse = Probability.finv(FComplemented,df1,df2);

/* Print the results to screen */
println("\nF probability distribution (x =" +(float)x+" df1 = "+df1+" and df2 = "+df2+")");
println("Probability.F(x,df1,df2): "+FDistr+", "+"Probability.FComplemented(x,df1,df2): "+(float)FComplemented);
println("x, computed using the FInverse function: "+(float)FInverse);


// ------------------------------------------------------------------------
// normcdf, norminv.
/* Note: Probability.norm(x) is equivalent to pnorm in R
Probability.norminv(x) is equivalent to qnorm in R */
/* Area from 0 to x of the *standard* normal probability density function (mean 0, variance 1)*/
double normalDistr = Probability.normcdf(x);
/* Find x such that Probability.normal(x) = y; */
double normalInverse = Probability.norminv(normalDistr);

/* Print the results to screen */
println("\nStandard Normal distribution (x = " +(float)x+")");
println("Probability.normcdf(x): "+(float)normalDistr);
println("x, computed using the norminv function: "+(float)normalInverse);

// ------------------------------------------------------------------------
// tcdf, tinv for the student-T distribution
/* Note: Probability.tcdf(x) is equivalent to pt in R
Probability.tinv(x) is equivalent to qt in R */
/* Area from 0 to x of the *standard* normal probability density function (mean 0, variance 1)*/
double t = Probability.tcdf(x,df);
/* Find x such that Probability.normal(x) = y; */
double tInverse = Probability.tinv(t,df);

/* Print the results to screen */
println("\nstudent-T distribution (x = " +(float)x+", with "+df+" degrees of freedom)");
println("Probability.tcdf(x,df): "+(float)t);
println("x, computed using the tinv function: "+(float)tInverse);

if(keyPressed){
redraw();
}
@@ -0,0 +1,95 @@
/*
autoCorr example
Adila Faruk, 2012.
*/

// import the library
import papaya.*;

// font
PFont titleFont = createFont("Helvetica", 14, true);
PFont smallFont = createFont("Helvetica", 12, true);

int ln = 100;
float[] sinx = new float[ln]; float[] x = new float[ln];
int[] lag = new int[ln];
float[] autoCorr = new float[ln];
float meanY, varianceY;

float minX, maxX;

void setup() {

size(450, 500);
noLoop();
for (int i=0; i<ln; i++) {
// x = rnorm(100) + sin(2*pi*1:100/10)
// http://en.wikipedia.org/wiki/File:Acf_new.svg
// from a wikipedia search on 'autoCorr'
lag[i] = i;
sinx[i] = random(-1, 1) + sin(TWO_PI*i/10); // max = -2, min = 2
x[i] = xLeft + 3*i;
}
// get the mean and variance
meanY = Descriptive.mean(sinx);
varianceY = Descriptive.var(sinx,false); // division by n
// compute the autoCorr for each lag value
for (int i=0; i<ln; i++) {
autoCorr[i] = Correlation.auto(sinx, lag[i], meanY, varianceY);
}
}

// plotting variables
float xLeft = 70; float xWidth = 300;
color steelblue = 0xff358cab;
float yPos1 = 200; float yPos2 = 380;

void draw() {
background(255);
stroke(100);

// create a Visuals class to help with the drawing
// This is all just for the plotting. nothing to do with the data
Visuals v = new Visuals(this, xLeft-5, 100, xWidth+40, 200);
fill(255);
rect(xLeft-10,yPos1-100,320,200);
rect(xLeft-10,yPos2-60,320,120); // rectangle around the autoCorr plot.
line(xLeft-5, yPos1, xLeft+xWidth+5, yPos1);
line(xLeft-5, yPos2, xLeft+xWidth+5, yPos2);
v.yLabels(yPos1-100, 200, -2, 2, 5);
v.yLabels(yPos2-45, 90, -1, 1, 5);
v.xLabels(xLeft, xWidth,0, 99, 5);

// draw the raw data
noFill(); stroke(steelblue);
beginShape();
for (int i=0; i<ln; i++) {
vertex(x[i], yPos1-50*sinx[i]);
}
endShape();

// autoCorr
for (int i=0; i<ln; i++) {
// autoCorr line
line(x[i], yPos2 - 45*autoCorr[i], x[i], yPos2);
}


// labels
fill(steelblue); textFont(titleFont); textAlign(LEFT,TOP);
text("100 random numbers with a 'hidden' sine function (wavelength every 10 units) "+
"and an autocorrelation (correlogram) of the series on the bottom.",xLeft-30, 20, width-2*xLeft+60, 70);
fill(100);textFont(smallFont); textAlign(LEFT,BOTTOM);
//raw data label:
text("The data: y = random(-1, 1) + sin(2pi*i/10)", xLeft, 95); ;
//raw data label:
text("Autocorrelation plot for lag = 0,1,...,99", xLeft, yPos2+75); ;
}

void keyPressed(){
if(keyPressed){
redraw();
}
}

@@ -0,0 +1,8 @@
name = papaya
authorList = [Adila Faruk](http://adilapapaya.com)
url = http://adilapapaya.com/papayastatistics/
category = Statistics, Math, Utilities
sentence = A collection of utilities for Statistics and Matrix-related manipulations
#paragraph =
version = 1.1.0
prettyVersion = 1.1.0
Binary file not shown.
@@ -0,0 +1,109 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Thu Jul 24 08:22:49 PDT 2014 -->
<TITLE>
All Classes (Javadocs: papaya)
</TITLE>

<META NAME="date" CONTENT="2014-07-24">

<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">


</HEAD>

<BODY BGCOLOR="white">
<FONT size="+1" CLASS="FrameHeadingFont">
<B>All Classes</B></FONT>
<BR>

<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="papaya/BoxPlot.html" title="class in papaya" target="classFrame">BoxPlot</A>
<BR>
<A HREF="papaya/Cast.html" title="class in papaya" target="classFrame">Cast</A>
<BR>
<A HREF="papaya/Comparison.html" title="class in papaya" target="classFrame">Comparison</A>
<BR>
<A HREF="papaya/Comparison.TTest.html" title="class in papaya" target="classFrame">Comparison.TTest</A>
<BR>
<A HREF="papaya/Correlation.html" title="class in papaya" target="classFrame">Correlation</A>
<BR>
<A HREF="papaya/Correlation.Significance.html" title="class in papaya" target="classFrame">Correlation.Significance</A>
<BR>
<A HREF="papaya/Correlation.Weighted.html" title="class in papaya" target="classFrame">Correlation.Weighted</A>
<BR>
<A HREF="papaya/CorrelationPlot.html" title="class in papaya" target="classFrame">CorrelationPlot</A>
<BR>
<A HREF="papaya/Descriptive.html" title="class in papaya" target="classFrame">Descriptive</A>
<BR>
<A HREF="papaya/Descriptive.Mean.html" title="class in papaya" target="classFrame">Descriptive.Mean</A>
<BR>
<A HREF="papaya/Descriptive.Pooled.html" title="class in papaya" target="classFrame">Descriptive.Pooled</A>
<BR>
<A HREF="papaya/Descriptive.Sum.html" title="class in papaya" target="classFrame">Descriptive.Sum</A>
<BR>
<A HREF="papaya/Descriptive.Weighted.html" title="class in papaya" target="classFrame">Descriptive.Weighted</A>
<BR>
<A HREF="papaya/Distance.html" title="class in papaya" target="classFrame">Distance</A>
<BR>
<A HREF="papaya/Eigenvalue.html" title="class in papaya" target="classFrame">Eigenvalue</A>
<BR>
<A HREF="papaya/Find.html" title="class in papaya" target="classFrame">Find</A>
<BR>
<A HREF="papaya/Frequency.html" title="class in papaya" target="classFrame">Frequency</A>
<BR>
<A HREF="papaya/Gamma.html" title="class in papaya" target="classFrame">Gamma</A>
<BR>
<A HREF="papaya/Linear.html" title="class in papaya" target="classFrame">Linear</A>
<BR>
<A HREF="papaya/Linear.BoxCox.html" title="class in papaya" target="classFrame">Linear.BoxCox</A>
<BR>
<A HREF="papaya/Linear.Significance.html" title="class in papaya" target="classFrame">Linear.Significance</A>
<BR>
<A HREF="papaya/Linear.StdErr.html" title="class in papaya" target="classFrame">Linear.StdErr</A>
<BR>
<A HREF="papaya/LU.html" title="class in papaya" target="classFrame">LU</A>
<BR>
<A HREF="papaya/Mat.html" title="class in papaya" target="classFrame">Mat</A>
<BR>
<A HREF="papaya/MDS.html" title="class in papaya" target="classFrame">MDS</A>
<BR>
<A HREF="papaya/NaNs.html" title="class in papaya" target="classFrame">NaNs</A>
<BR>
<A HREF="papaya/Normality.html" title="class in papaya" target="classFrame">Normality</A>
<BR>
<A HREF="papaya/Normality.Dago.html" title="class in papaya" target="classFrame">Normality.Dago</A>
<BR>
<A HREF="papaya/OneWayAnova.html" title="class in papaya" target="classFrame">OneWayAnova</A>
<BR>
<A HREF="papaya/PapayaConstants.html" title="interface in papaya" target="classFrame"><I>PapayaConstants</I></A>
<BR>
<A HREF="papaya/Polynomial.html" title="class in papaya" target="classFrame">Polynomial</A>
<BR>
<A HREF="papaya/Probability.html" title="class in papaya" target="classFrame">Probability</A>
<BR>
<A HREF="papaya/QR.html" title="class in papaya" target="classFrame">QR</A>
<BR>
<A HREF="papaya/Rank.html" title="class in papaya" target="classFrame">Rank</A>
<BR>
<A HREF="papaya/ScatterPlot.html" title="class in papaya" target="classFrame">ScatterPlot</A>
<BR>
<A HREF="papaya/Sorting.html" title="class in papaya" target="classFrame">Sorting</A>
<BR>
<A HREF="papaya/SubPlot.html" title="class in papaya" target="classFrame">SubPlot</A>
<BR>
<A HREF="papaya/SVD.html" title="class in papaya" target="classFrame">SVD</A>
<BR>
<A HREF="papaya/Unique.html" title="class in papaya" target="classFrame">Unique</A>
<BR>
<A HREF="papaya/Visuals.html" title="class in papaya" target="classFrame">Visuals</A>
<BR>
</FONT></TD>
</TR>
</TABLE>

</BODY>
</HTML>
@@ -0,0 +1,109 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Thu Jul 24 08:22:49 PDT 2014 -->
<TITLE>
All Classes (Javadocs: papaya)
</TITLE>

<META NAME="date" CONTENT="2014-07-24">

<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">


</HEAD>

<BODY BGCOLOR="white">
<FONT size="+1" CLASS="FrameHeadingFont">
<B>All Classes</B></FONT>
<BR>

<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
<TR>
<TD NOWRAP><FONT CLASS="FrameItemFont"><A HREF="papaya/BoxPlot.html" title="class in papaya">BoxPlot</A>
<BR>
<A HREF="papaya/Cast.html" title="class in papaya">Cast</A>
<BR>
<A HREF="papaya/Comparison.html" title="class in papaya">Comparison</A>
<BR>
<A HREF="papaya/Comparison.TTest.html" title="class in papaya">Comparison.TTest</A>
<BR>
<A HREF="papaya/Correlation.html" title="class in papaya">Correlation</A>
<BR>
<A HREF="papaya/Correlation.Significance.html" title="class in papaya">Correlation.Significance</A>
<BR>
<A HREF="papaya/Correlation.Weighted.html" title="class in papaya">Correlation.Weighted</A>
<BR>
<A HREF="papaya/CorrelationPlot.html" title="class in papaya">CorrelationPlot</A>
<BR>
<A HREF="papaya/Descriptive.html" title="class in papaya">Descriptive</A>
<BR>
<A HREF="papaya/Descriptive.Mean.html" title="class in papaya">Descriptive.Mean</A>
<BR>
<A HREF="papaya/Descriptive.Pooled.html" title="class in papaya">Descriptive.Pooled</A>
<BR>
<A HREF="papaya/Descriptive.Sum.html" title="class in papaya">Descriptive.Sum</A>
<BR>
<A HREF="papaya/Descriptive.Weighted.html" title="class in papaya">Descriptive.Weighted</A>
<BR>
<A HREF="papaya/Distance.html" title="class in papaya">Distance</A>
<BR>
<A HREF="papaya/Eigenvalue.html" title="class in papaya">Eigenvalue</A>
<BR>
<A HREF="papaya/Find.html" title="class in papaya">Find</A>
<BR>
<A HREF="papaya/Frequency.html" title="class in papaya">Frequency</A>
<BR>
<A HREF="papaya/Gamma.html" title="class in papaya">Gamma</A>
<BR>
<A HREF="papaya/Linear.html" title="class in papaya">Linear</A>
<BR>
<A HREF="papaya/Linear.BoxCox.html" title="class in papaya">Linear.BoxCox</A>
<BR>
<A HREF="papaya/Linear.Significance.html" title="class in papaya">Linear.Significance</A>
<BR>
<A HREF="papaya/Linear.StdErr.html" title="class in papaya">Linear.StdErr</A>
<BR>
<A HREF="papaya/LU.html" title="class in papaya">LU</A>
<BR>
<A HREF="papaya/Mat.html" title="class in papaya">Mat</A>
<BR>
<A HREF="papaya/MDS.html" title="class in papaya">MDS</A>
<BR>
<A HREF="papaya/NaNs.html" title="class in papaya">NaNs</A>
<BR>
<A HREF="papaya/Normality.html" title="class in papaya">Normality</A>
<BR>
<A HREF="papaya/Normality.Dago.html" title="class in papaya">Normality.Dago</A>
<BR>
<A HREF="papaya/OneWayAnova.html" title="class in papaya">OneWayAnova</A>
<BR>
<A HREF="papaya/PapayaConstants.html" title="interface in papaya"><I>PapayaConstants</I></A>
<BR>
<A HREF="papaya/Polynomial.html" title="class in papaya">Polynomial</A>
<BR>
<A HREF="papaya/Probability.html" title="class in papaya">Probability</A>
<BR>
<A HREF="papaya/QR.html" title="class in papaya">QR</A>
<BR>
<A HREF="papaya/Rank.html" title="class in papaya">Rank</A>
<BR>
<A HREF="papaya/ScatterPlot.html" title="class in papaya">ScatterPlot</A>
<BR>
<A HREF="papaya/Sorting.html" title="class in papaya">Sorting</A>
<BR>
<A HREF="papaya/SubPlot.html" title="class in papaya">SubPlot</A>
<BR>
<A HREF="papaya/SVD.html" title="class in papaya">SVD</A>
<BR>
<A HREF="papaya/Unique.html" title="class in papaya">Unique</A>
<BR>
<A HREF="papaya/Visuals.html" title="class in papaya">Visuals</A>
<BR>
</FONT></TD>
</TR>
</TABLE>

</BODY>
</HTML>
@@ -0,0 +1,277 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Thu Jul 24 08:22:49 PDT 2014 -->
<TITLE>
Constant Field Values (Javadocs: papaya)
</TITLE>

<META NAME="date" CONTENT="2014-07-24">

<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Constant Field Values (Javadocs: papaya)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="papaya/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html?constant-values.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="constant-values.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<CENTER>
<H1>
Constant Field Values</H1>
</CENTER>
<HR SIZE="4" NOSHADE>
<B>Contents</B><UL>
<LI><A HREF="#papaya">papaya.*</A>
</UL>

<A NAME="papaya"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left"><FONT SIZE="+2">
papaya.*</FONT></TH>
</TR>
</TABLE>

<P>

<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left" COLSPAN="3">papaya.<A HREF="papaya/PapayaConstants.html" title="interface in papaya">PapayaConstants</A></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.BASELINE"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#BASELINE">BASELINE</A></CODE></TD>
<TD ALIGN="right"><CODE>0</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.big"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#big">big</A></CODE></TD>
<TD ALIGN="right"><CODE>4.503599627370496E15</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.biginv"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#biginv">biginv</A></CODE></TD>
<TD ALIGN="right"><CODE>2.220446049250313E-16</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.BOTTOM"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#BOTTOM">BOTTOM</A></CODE></TD>
<TD ALIGN="right"><CODE>102</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.CENTER"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#CENTER">CENTER</A></CODE></TD>
<TD ALIGN="right"><CODE>3</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.CORNER"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#CORNER">CORNER</A></CODE></TD>
<TD ALIGN="right"><CODE>0</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.FONTNAME"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#FONTNAME">FONTNAME</A></CODE></TD>
<TD ALIGN="right"><CODE>"Helvetica"</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.INDEX_NOT_FOUND"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#INDEX_NOT_FOUND">INDEX_NOT_FOUND</A></CODE></TD>
<TD ALIGN="right"><CODE>-1</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.LEFT"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#LEFT">LEFT</A></CODE></TD>
<TD ALIGN="right"><CODE>37</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.LOGPI"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#LOGPI">LOGPI</A></CODE></TD>
<TD ALIGN="right"><CODE>1.1447298858494002</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.MACHEP"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#MACHEP">MACHEP</A></CODE></TD>
<TD ALIGN="right"><CODE>1.1102230246251565E-16</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.MAXGAM"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#MAXGAM">MAXGAM</A></CODE></TD>
<TD ALIGN="right"><CODE>171.6243769563027</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.MAXLOG"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#MAXLOG">MAXLOG</A></CODE></TD>
<TD ALIGN="right"><CODE>709.782712893384</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.MINLOG"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#MINLOG">MINLOG</A></CODE></TD>
<TD ALIGN="right"><CODE>-745.1332191019412</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.RIGHT"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#RIGHT">RIGHT</A></CODE></TD>
<TD ALIGN="right"><CODE>39</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.SQRTH"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#SQRTH">SQRTH</A></CODE></TD>
<TD ALIGN="right"><CODE>0.7071067811865476</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.SQTPI"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;double</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#SQTPI">SQTPI</A></CODE></TD>
<TD ALIGN="right"><CODE>2.5066282746310007</CODE></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<A NAME="papaya.PapayaConstants.TOP"><!-- --></A><TD ALIGN="right"><FONT SIZE="-1">
<CODE>public&nbsp;static&nbsp;final&nbsp;int</CODE></FONT></TD>
<TD ALIGN="left"><CODE><A HREF="papaya/PapayaConstants.html#TOP">TOP</A></CODE></TD>
<TD ALIGN="right"><CODE>101</CODE></TD>
</TR>
</FONT></TD>
</TR>
</TABLE>

<P>

<P>
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="papaya/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html?constant-values.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="constant-values.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>


<a href="http://processing.org">Processing</a> library papaya by
<a href="http://adilapapaya.com">Adila Faruk</a>. (C) 2014


</BODY>
</HTML>
@@ -0,0 +1,147 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Thu Jul 24 08:22:49 PDT 2014 -->
<TITLE>
Deprecated List (Javadocs: papaya)
</TITLE>

<META NAME="date" CONTENT="2014-07-24">

<LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Deprecated List (Javadocs: papaya)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="papaya/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Deprecated</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html?deprecated-list.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="deprecated-list.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<CENTER>
<H2>
<B>Deprecated API</B></H2>
</CENTER>
<HR SIZE="4" NOSHADE>
<B>Contents</B><UL>
</UL>

<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="papaya/package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Deprecated</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="index.html?deprecated-list.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="deprecated-list.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>


<a href="http://processing.org">Processing</a> library papaya by
<a href="http://adilapapaya.com">Adila Faruk</a>. (C) 2014


</BODY>
</HTML>