From 53025f5e31b644742df2e7666152cffb404e9154 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Tue, 2 Dec 2014 18:00:39 -0500 Subject: [PATCH] no message --- .../BoxPlotExample/BoxPlotExample.pde | 109 + .../BoxPlotExample/data/warpbreaks.txt | 1 + .../CastingFinding_andMore.pde | 95 + .../ComparingTwoDatasets.pde | 180 + .../ComparingTwoDatasets/data/FRESHMAN15.csv | 1 + .../data/Helvetica-12.vlw | Bin 0 -> 9186 bytes .../data/Helvetica-22.vlw | Bin 0 -> 20303 bytes .../CorrelationAndCovariance.pde | 121 + .../CorrelationMatrix.png | Bin 0 -> 64529 bytes .../CorrelationAndCovariance/data/GARBAGE.csv | 1 + .../examples/LinearAlgebra/LinearAlgebra.pde | 184 + .../examples/LinearAlgebra/data/BEARS.csv | 1 + .../LinearCorrelation/LinearCorrelation.pde | 121 + .../LinearCorrelation/LinearModelPlot.pde | 149 + .../examples/LinearCorrelation/data/Trees.txt | 32 + .../MultiDimensionalScaling/HeatMap.pde | 60 + .../MultiDimensionalScaling.pde | 126 + .../MultiDimensionalScaling/data/BEARS.csv | 1 + .../OneWayAnovaExample/OneWayAnovaExample.pde | 111 + .../OneWayAnovaExample/data/3Stooges.csv | 1 + drawing/papaya/examples/Ranking/Ranking.pde | 44 + .../ScatterPlotExample_simple_.pde | 75 + .../SortingUsingIndices.pde | 42 + .../examples/UniqueExample/UniqueExample.pde | 149 + .../examples/UniqueExample/data/GARBAGE.csv | 1 + .../UsingTheProbabilityDistributions.pde | 88 + .../autoCorrelationExample.pde | 95 + drawing/papaya/library.properties | 8 + drawing/papaya/library/papaya.jar | Bin 0 -> 71233 bytes .../papaya/reference/allclasses-frame.html | 109 + .../papaya/reference/allclasses-noframe.html | 109 + drawing/papaya/reference/constant-values.html | 277 ++ drawing/papaya/reference/deprecated-list.html | 147 + drawing/papaya/reference/help-doc.html | 214 ++ drawing/papaya/reference/index-all.html | 2076 +++++++++++ drawing/papaya/reference/index.html | 70 + drawing/papaya/reference/overview-tree.html | 168 + drawing/papaya/reference/package-list | 1 + drawing/papaya/reference/papaya/BoxPlot.html | 498 +++ drawing/papaya/reference/papaya/Cast.html | 576 +++ .../reference/papaya/Comparison.TTest.html | 318 ++ .../papaya/reference/papaya/Comparison.html | 374 ++ .../papaya/Correlation.Significance.html | 309 ++ .../papaya/Correlation.Weighted.html | 335 ++ .../papaya/reference/papaya/Correlation.html | 548 +++ .../reference/papaya/CorrelationPlot.html | 363 ++ .../reference/papaya/Descriptive.Mean.html | 429 +++ .../reference/papaya/Descriptive.Pooled.html | 333 ++ .../reference/papaya/Descriptive.Sum.html | 438 +++ .../papaya/Descriptive.Weighted.html | 307 ++ .../papaya/reference/papaya/Descriptive.html | 1412 ++++++++ drawing/papaya/reference/papaya/Distance.html | 492 +++ .../papaya/reference/papaya/Eigenvalue.html | 358 ++ drawing/papaya/reference/papaya/Find.html | 3151 +++++++++++++++++ .../papaya/reference/papaya/Frequency.html | 502 +++ drawing/papaya/reference/papaya/Gamma.html | 449 +++ drawing/papaya/reference/papaya/LU.html | 449 +++ .../reference/papaya/Linear.BoxCox.html | 285 ++ .../reference/papaya/Linear.Significance.html | 302 ++ .../reference/papaya/Linear.StdErr.html | 299 ++ drawing/papaya/reference/papaya/Linear.html | 433 +++ drawing/papaya/reference/papaya/MDS.html | 253 ++ drawing/papaya/reference/papaya/Mat.html | 2622 ++++++++++++++ drawing/papaya/reference/papaya/NaNs.html | 447 +++ .../reference/papaya/Normality.Dago.html | 373 ++ .../papaya/reference/papaya/Normality.html | 289 ++ .../papaya/reference/papaya/OneWayAnova.html | 441 +++ .../reference/papaya/PapayaConstants.html | 602 ++++ .../papaya/reference/papaya/Polynomial.html | 347 ++ .../papaya/reference/papaya/Probability.html | 1262 +++++++ drawing/papaya/reference/papaya/QR.html | 398 +++ drawing/papaya/reference/papaya/Rank.html | 464 +++ drawing/papaya/reference/papaya/SVD.html | 417 +++ .../papaya/reference/papaya/ScatterPlot.html | 609 ++++ drawing/papaya/reference/papaya/Sorting.html | 521 +++ drawing/papaya/reference/papaya/SubPlot.html | 793 +++++ drawing/papaya/reference/papaya/Unique.html | 338 ++ drawing/papaya/reference/papaya/Visuals.html | 1404 ++++++++ .../reference/papaya/package-frame.html | 119 + .../reference/papaya/package-summary.html | 344 ++ .../papaya/reference/papaya/package-tree.html | 166 + .../papaya/reference/resources/inherit.gif | Bin 0 -> 57 bytes drawing/papaya/reference/stylesheet.css | 115 + drawing/papaya/src/papaya/BoxPlot.java | 166 + drawing/papaya/src/papaya/Cast.java | 259 ++ drawing/papaya/src/papaya/Check.java | 68 + drawing/papaya/src/papaya/Comparison.java | 291 ++ drawing/papaya/src/papaya/Correlation.java | 546 +++ .../papaya/src/papaya/CorrelationPlot.java | 161 + drawing/papaya/src/papaya/Descriptive.java | 1628 +++++++++ drawing/papaya/src/papaya/Distance.java | 400 +++ drawing/papaya/src/papaya/Eigenvalue.java | 991 ++++++ drawing/papaya/src/papaya/Find.java | 1945 ++++++++++ drawing/papaya/src/papaya/Frequency.java | 195 + drawing/papaya/src/papaya/Gamma.java | 741 ++++ drawing/papaya/src/papaya/LU.java | 410 +++ drawing/papaya/src/papaya/Linear.java | 300 ++ drawing/papaya/src/papaya/MDS.java | 149 + drawing/papaya/src/papaya/Mat.java | 1511 ++++++++ drawing/papaya/src/papaya/NaNs.java | 288 ++ drawing/papaya/src/papaya/Normality.java | 282 ++ drawing/papaya/src/papaya/OneWayAnova.java | 196 + .../papaya/src/papaya/PapayaConstants.java | 94 + drawing/papaya/src/papaya/Polynomial.java | 129 + drawing/papaya/src/papaya/Probability.java | 978 +++++ drawing/papaya/src/papaya/QR.java | 296 ++ drawing/papaya/src/papaya/Rank.java | 618 ++++ drawing/papaya/src/papaya/SVD.java | 597 ++++ drawing/papaya/src/papaya/ScatterPlot.java | 205 ++ drawing/papaya/src/papaya/Sorting.java | 817 +++++ drawing/papaya/src/papaya/SubPlot.java | 192 + drawing/papaya/src/papaya/Unique.java | 103 + drawing/papaya/src/papaya/Visuals.java | 588 +++ 113 files changed, 45395 insertions(+) create mode 100644 drawing/papaya/examples/BoxPlotExample/BoxPlotExample.pde create mode 100644 drawing/papaya/examples/BoxPlotExample/data/warpbreaks.txt create mode 100644 drawing/papaya/examples/CastingFinding_andMore/CastingFinding_andMore.pde create mode 100644 drawing/papaya/examples/ComparingTwoDatasets/ComparingTwoDatasets.pde create mode 100644 drawing/papaya/examples/ComparingTwoDatasets/data/FRESHMAN15.csv create mode 100644 drawing/papaya/examples/ComparingTwoDatasets/data/Helvetica-12.vlw create mode 100644 drawing/papaya/examples/ComparingTwoDatasets/data/Helvetica-22.vlw create mode 100644 drawing/papaya/examples/CorrelationAndCovariance/CorrelationAndCovariance.pde create mode 100644 drawing/papaya/examples/CorrelationAndCovariance/CorrelationMatrix.png create mode 100644 drawing/papaya/examples/CorrelationAndCovariance/data/GARBAGE.csv create mode 100644 drawing/papaya/examples/LinearAlgebra/LinearAlgebra.pde create mode 100644 drawing/papaya/examples/LinearAlgebra/data/BEARS.csv create mode 100644 drawing/papaya/examples/LinearCorrelation/LinearCorrelation.pde create mode 100644 drawing/papaya/examples/LinearCorrelation/LinearModelPlot.pde create mode 100644 drawing/papaya/examples/LinearCorrelation/data/Trees.txt create mode 100644 drawing/papaya/examples/MultiDimensionalScaling/HeatMap.pde create mode 100644 drawing/papaya/examples/MultiDimensionalScaling/MultiDimensionalScaling.pde create mode 100644 drawing/papaya/examples/MultiDimensionalScaling/data/BEARS.csv create mode 100644 drawing/papaya/examples/OneWayAnovaExample/OneWayAnovaExample.pde create mode 100644 drawing/papaya/examples/OneWayAnovaExample/data/3Stooges.csv create mode 100644 drawing/papaya/examples/Ranking/Ranking.pde create mode 100644 drawing/papaya/examples/ScatterPlotExample_simple_/ScatterPlotExample_simple_.pde create mode 100644 drawing/papaya/examples/SortingUsingIndices/SortingUsingIndices.pde create mode 100644 drawing/papaya/examples/UniqueExample/UniqueExample.pde create mode 100644 drawing/papaya/examples/UniqueExample/data/GARBAGE.csv create mode 100644 drawing/papaya/examples/UsingTheProbabilityDistributions/UsingTheProbabilityDistributions.pde create mode 100644 drawing/papaya/examples/autoCorrelationExample/autoCorrelationExample.pde create mode 100644 drawing/papaya/library.properties create mode 100644 drawing/papaya/library/papaya.jar create mode 100644 drawing/papaya/reference/allclasses-frame.html create mode 100644 drawing/papaya/reference/allclasses-noframe.html create mode 100644 drawing/papaya/reference/constant-values.html create mode 100644 drawing/papaya/reference/deprecated-list.html create mode 100644 drawing/papaya/reference/help-doc.html create mode 100644 drawing/papaya/reference/index-all.html create mode 100644 drawing/papaya/reference/index.html create mode 100644 drawing/papaya/reference/overview-tree.html create mode 100644 drawing/papaya/reference/package-list create mode 100644 drawing/papaya/reference/papaya/BoxPlot.html create mode 100644 drawing/papaya/reference/papaya/Cast.html create mode 100644 drawing/papaya/reference/papaya/Comparison.TTest.html create mode 100644 drawing/papaya/reference/papaya/Comparison.html create mode 100644 drawing/papaya/reference/papaya/Correlation.Significance.html create mode 100644 drawing/papaya/reference/papaya/Correlation.Weighted.html create mode 100644 drawing/papaya/reference/papaya/Correlation.html create mode 100644 drawing/papaya/reference/papaya/CorrelationPlot.html create mode 100644 drawing/papaya/reference/papaya/Descriptive.Mean.html create mode 100644 drawing/papaya/reference/papaya/Descriptive.Pooled.html create mode 100644 drawing/papaya/reference/papaya/Descriptive.Sum.html create mode 100644 drawing/papaya/reference/papaya/Descriptive.Weighted.html create mode 100644 drawing/papaya/reference/papaya/Descriptive.html create mode 100644 drawing/papaya/reference/papaya/Distance.html create mode 100644 drawing/papaya/reference/papaya/Eigenvalue.html create mode 100644 drawing/papaya/reference/papaya/Find.html create mode 100644 drawing/papaya/reference/papaya/Frequency.html create mode 100644 drawing/papaya/reference/papaya/Gamma.html create mode 100644 drawing/papaya/reference/papaya/LU.html create mode 100644 drawing/papaya/reference/papaya/Linear.BoxCox.html create mode 100644 drawing/papaya/reference/papaya/Linear.Significance.html create mode 100644 drawing/papaya/reference/papaya/Linear.StdErr.html create mode 100644 drawing/papaya/reference/papaya/Linear.html create mode 100644 drawing/papaya/reference/papaya/MDS.html create mode 100644 drawing/papaya/reference/papaya/Mat.html create mode 100644 drawing/papaya/reference/papaya/NaNs.html create mode 100644 drawing/papaya/reference/papaya/Normality.Dago.html create mode 100644 drawing/papaya/reference/papaya/Normality.html create mode 100644 drawing/papaya/reference/papaya/OneWayAnova.html create mode 100644 drawing/papaya/reference/papaya/PapayaConstants.html create mode 100644 drawing/papaya/reference/papaya/Polynomial.html create mode 100644 drawing/papaya/reference/papaya/Probability.html create mode 100644 drawing/papaya/reference/papaya/QR.html create mode 100644 drawing/papaya/reference/papaya/Rank.html create mode 100644 drawing/papaya/reference/papaya/SVD.html create mode 100644 drawing/papaya/reference/papaya/ScatterPlot.html create mode 100644 drawing/papaya/reference/papaya/Sorting.html create mode 100644 drawing/papaya/reference/papaya/SubPlot.html create mode 100644 drawing/papaya/reference/papaya/Unique.html create mode 100644 drawing/papaya/reference/papaya/Visuals.html create mode 100644 drawing/papaya/reference/papaya/package-frame.html create mode 100644 drawing/papaya/reference/papaya/package-summary.html create mode 100644 drawing/papaya/reference/papaya/package-tree.html create mode 100644 drawing/papaya/reference/resources/inherit.gif create mode 100644 drawing/papaya/reference/stylesheet.css create mode 100644 drawing/papaya/src/papaya/BoxPlot.java create mode 100644 drawing/papaya/src/papaya/Cast.java create mode 100644 drawing/papaya/src/papaya/Check.java create mode 100644 drawing/papaya/src/papaya/Comparison.java create mode 100644 drawing/papaya/src/papaya/Correlation.java create mode 100644 drawing/papaya/src/papaya/CorrelationPlot.java create mode 100644 drawing/papaya/src/papaya/Descriptive.java create mode 100644 drawing/papaya/src/papaya/Distance.java create mode 100644 drawing/papaya/src/papaya/Eigenvalue.java create mode 100644 drawing/papaya/src/papaya/Find.java create mode 100644 drawing/papaya/src/papaya/Frequency.java create mode 100644 drawing/papaya/src/papaya/Gamma.java create mode 100644 drawing/papaya/src/papaya/LU.java create mode 100644 drawing/papaya/src/papaya/Linear.java create mode 100644 drawing/papaya/src/papaya/MDS.java create mode 100644 drawing/papaya/src/papaya/Mat.java create mode 100644 drawing/papaya/src/papaya/NaNs.java create mode 100644 drawing/papaya/src/papaya/Normality.java create mode 100644 drawing/papaya/src/papaya/OneWayAnova.java create mode 100644 drawing/papaya/src/papaya/PapayaConstants.java create mode 100644 drawing/papaya/src/papaya/Polynomial.java create mode 100644 drawing/papaya/src/papaya/Probability.java create mode 100644 drawing/papaya/src/papaya/QR.java create mode 100644 drawing/papaya/src/papaya/Rank.java create mode 100644 drawing/papaya/src/papaya/SVD.java create mode 100644 drawing/papaya/src/papaya/ScatterPlot.java create mode 100644 drawing/papaya/src/papaya/Sorting.java create mode 100644 drawing/papaya/src/papaya/SubPlot.java create mode 100644 drawing/papaya/src/papaya/Unique.java create mode 100644 drawing/papaya/src/papaya/Visuals.java diff --git a/drawing/papaya/examples/BoxPlotExample/BoxPlotExample.pde b/drawing/papaya/examples/BoxPlotExample/BoxPlotExample.pde new file mode 100644 index 0000000..01ffa54 --- /dev/null +++ b/drawing/papaya/examples/BoxPlotExample/BoxPlotExample.pde @@ -0,0 +1,109 @@ +/* + Sketch demonstrating how to plot box plots using the BoxPlot class. + Author: Adila Faruk + */ + +// import the library +import papaya.*; +//import papaya.BoxPlot; +// --------------------- Sketch-wide variables ---------------------- +BoxPlot[] boxPlot = new BoxPlot[2]; +PFont titleFont, mediumFont, smallFont; + +float[] breaks; +int[] tension; +int minBreaks, maxBreaks; +float[][] fiveNumSummary; + +// boxplot labels +String[] xLabels = new String[] { + "L","M","H" +}; + + +// ----------------------------------- +void setup() { + size(630, 500); + smooth(); + noLoop(); + + titleFont = createFont("Helvetica", 22, true); + smallFont = createFont("Helvetica", 11, true); + mediumFont = createFont("Helvetica", 14, true); + // Read in the data + // This data set gives the number of warp breaks per loom, + // where a loom corresponds to a fixed length of yarn. + // breaks: number of breaks in wool + // tension: tension (L,M,H). + String lines[] = loadStrings("warpbreaks.txt"); + + int ln = lines.length-1; + breaks = new float[ln];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U_I Owfy*7n@@fA1OE&2i5Uq1 literal 0 HcmV?d00001 diff --git a/drawing/papaya/examples/CorrelationAndCovariance/CorrelationAndCovariance.pde b/drawing/papaya/examples/CorrelationAndCovariance/CorrelationAndCovariance.pde new file mode 100644 index 0000000..413c37a --- /dev/null +++ b/drawing/papaya/examples/CorrelationAndCovariance/CorrelationAndCovariance.pde @@ -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; iHPcbyZ3#) zFZY2lnjYO<_0_7iYSx@{MW`srpdk|@LqS2I$;nEoK|w*^{QEJolVu7PL&)Ec`CAJB zG3q}9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U z4hTvx74{y0Q8h6!;UUthG0t_;X?29x8l27*{ZV%M1HcHjeq3B!)Z+ca{yaT-%Moll6SxZT3vz{()`~lkX)7t9e8p_lQ^@AD1yVxW^M6({#zeT_tSE zm*fHr++yzYcbZK|Ta?r?0pOuLYoh_%r=y`!P&2-zy zrgc^k2(~aofLQvCQv<-a}7#|EgD zD14(!hx?6AAmHr|*zE#WuICQgL^{`9n=-eh!z?t|z)JM>c)m2BAS5_AcxN#3X-w}m z4}mE;6F^TFm?l)?w5?Bg)JUmpU#)318mTDa9G27q2lq5iL~#! z@7BF8`D9$kCxQ9xecvxQ4^@MSq*Nbd!WH+5}E)&O_9*No`)_q}C8TH4Bz$SI2%$*vrT z&3>ca3}c1Rg^<-4$+z6y!qCt#M_8}Rn}>#`1WStC^2ad{>>-5jDbGpi3*hm-uUTQ( zu_(5m-!6b{2_#PjTu%p(Ch+wEsCyTNyIgNJ1q2L)attzjfp;e+$P`CDjs4w6FF*#w zoELMOI?FwPe*>6$K&)lkBf_aCp7*q$LW*~%9E$9(GOAz)T0SEy>%W?IT`eY9SXdXN zB^fkCInZ|P_FFLGIeo|Oh>!{;o*Ngaa_3FHa!<>o=dd};IS=tQlBhhJctp;;w z9;5Jk@Xq4H_#O}Q0U7O}tzTqi=YZ9%O-li)Ik4#~_+7|b`~b+kNXL!ZM!^1A zjRXhxIOXK{zR|{ozWZqxFiUH*9NaH?7F0PzHKjW3u8Ep3WZoCOw}2hntjvd_@?|BZ z{#)HVOVdN(L*TDHo&GI%iZ@_^YJTScsEdeBtWTuI^Kb1lcm4y?dXNPS??!8>|9?*X nzt=_obEWkE{fw{r-#6%P7t&;Ii<)jI;3Fv}_q9qyKj41>D=rm8 literal 0 HcmV?d00001 diff --git a/drawing/papaya/examples/CorrelationAndCovariance/data/GARBAGE.csv b/drawing/papaya/examples/CorrelationAndCovariance/data/GARBAGE.csv new file mode 100644 index 0000000..e409b5b --- /dev/null +++ b/drawing/papaya/examples/CorrelationAndCovariance/data/GARBAGE.csv @@ -0,0 +1 @@ +HHSize,Metal,Paper,Plastic,Glass,Food,Yard,Text,Other,Total 2,1.09,2.41,0.27,0.86,1.04,0.38,0.05,4.66,10.76 3,1.04,7.57,1.41,3.46,3.68,0,0.46,2.34,19.96 3,2.57,9.55,2.19,4.52,4.43,0.24,0.5,3.6,27.6 6,3.02,8.82,2.83,4.92,2.98,0.63,2.26,12.65,38.11 4,1.5,8.72,2.19,6.31,6.3,0.15,0.55,2.18,27.9 2,2.1,6.96,1.81,2.49,1.46,4.58,0.36,2.14,21.9 1,1.93,6.83,0.85,0.51,8.82,0.07,0.6,2.22,21.83 5,3.57,11.42,3.05,5.81,9.62,4.76,0.21,10.83,49.27 6,2.32,16.08,3.42,1.96,4.41,0.13,0.81,4.14,33.27 4,1.89,6.38,2.1,17.67,2.73,3.86,0.66,0.25,35.54 4,3.26,13.05,2.93,3.21,9.31,0.7,0.37,11.61,44.44 7,3.99,11.36,2.44,4.94,3.59,13.45,4.25,1.15,45.17 3,2.04,15.09,2.17,3.1,5.36,0.74,0.42,4.15,33.07 5,0.99,2.8,1.41,1.39,1.47,0.82,0.44,1.03,10.35 6,2.96,6.44,2,5.21,7.06,6.14,0.2,14.43,44.44 2,1.5,5.86,0.93,2.03,2.52,1.37,0.27,9.65,24.13 4,2.43,11.08,2.97,1.74,1.75,14.7,0.39,2.54,37.6 4,2.97,12.43,2.04,3.99,5.64,0.22,2.47,9.2,38.96 3,1.42,6.05,0.65,6.26,1.93,0,0.86,0,17.17 3,3.6,13.61,2.13,3.52,6.46,0,0.96,1.32,31.6 2,4.48,6.98,0.63,2.01,6.72,2,0.11,0.18,23.11 2,1.36,14.33,1.53,2.21,5.76,0.58,0.17,1.62,27.56 4,2.11,13.31,4.69,0.25,9.72,0.02,0.46,0.4,30.96 1,0.41,0.27,0.15,0.09,0.16,0,0,0,1.08 4,2.02,6.67,1.45,6.85,5.52,0,0.68,0.03,23.22 6,3.27,17.65,2.68,2.33,11.92,0.83,0.28,4.03,42.99 11,4.95,12.73,3.53,5.45,4.68,0,0.67,19.89,51.9 3,1,9.83,1.49,2.04,4.76,0.42,0.54,0.12,20.2 4,1.55,16.39,2.31,4.98,7.85,2.04,0.2,1.48,36.8 3,1.41,6.33,0.92,3.54,2.9,3.85,0.03,0.04,19.02 2,1.05,9.19,0.89,1.06,2.87,0.33,0.01,0.03,15.43 2,1.31,9.41,0.8,2.7,5.09,0.64,0.05,0.71,20.71 2,2.5,9.45,0.72,1.14,3.17,0,0.02,0.01,17.01 4,2.35,12.32,2.66,12.24,2.4,7.87,4.73,0.78,45.35 6,3.69,20.12,4.37,5.67,13.2,0,1.15,1.17,49.37 2,3.61,7.72,0.92,2.43,2.07,0.68,0.63,0,18.06 2,1.49,6.16,1.4,4.02,4,0.3,0.04,0,17.41 2,1.36,7.98,1.45,6.45,4.27,0.02,0.12,2.02,23.67 2,1.73,9.64,1.68,1.89,1.87,0.01,1.73,0.58,19.13 2,0.94,8.08,1.53,1.78,8.13,0.36,0.12,0.05,20.99 3,1.33,10.99,1.44,2.93,3.51,0,0.39,0.59,21.18 3,2.62,13.11,1.44,1.82,4.21,4.73,0.64,0.49,29.06 2,1.25,3.26,1.36,2.89,3.34,2.69,0,0.16,14.95 2,0.26,1.65,0.38,0.99,0.77,0.34,0.04,0,4.43 3,4.41,10,1.74,1.93,1.14,0.92,0.08,4.6,24.82 6,3.22,8.96,2.35,3.61,1.45,0,0.09,1.12,20.8 4,1.86,9.46,2.3,2.53,6.54,0,0.65,2.45,25.79 4,1.76,5.88,1.14,3.76,0.92,1.12,0,0.04,14.62 3,2.83,8.26,2.88,1.32,5.14,5.6,0.35,2.03,28.41 3,2.74,12.45,2.13,2.64,4.59,1.07,0.41,1.14,27.17 10,4.63,10.58,5.28,12.33,2.94,0.12,2.94,15.65,54.47 3,1.7,5.87,1.48,1.79,1.42,0,0.27,0.59,13.12 6,3.29,8.78,3.36,3.99,10.44,0.9,1.71,13.3,45.77 5,1.22,11.03,2.83,4.44,3,4.3,1.95,6.02,34.79 4,3.2,12.29,2.87,9.25,5.91,1.32,1.87,0.55,37.26 7,3.09,20.58,2.96,4.02,16.81,0.47,1.52,2.13,51.58 5,2.58,12.56,1.61,1.38,5.01,0,0.21,1.46,24.81 4,1.67,9.92,1.58,1.59,9.96,0.13,0.2,1.13,26.18 2,0.85,3.45,1.15,0.85,3.89,0,0.02,1.04,11.25 4,1.52,9.09,1.28,8.87,4.83,0,0.95,1.61,28.15 2,1.37,3.69,0.58,3.64,1.78,0.08,0,0,11.14 2,1.32,2.61,0.74,3.03,3.37,0.17,0,0.46,11.7 \ No newline at end of file diff --git a/drawing/papaya/examples/LinearAlgebra/LinearAlgebra.pde b/drawing/papaya/examples/LinearAlgebra/LinearAlgebra.pde new file mode 100644 index 0000000..03ab1a9 --- /dev/null +++ b/drawing/papaya/examples/LinearAlgebra/LinearAlgebra.pde @@ -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; ix vs y 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; ix1,y1 to x2,y2. + * + * The multiplier c ( 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 c 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 (y1meanY+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] 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; iBD = new ArrayList(); // brain damage + ArrayListSI = new ArrayList(); // 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)BD); + OneWayAnova anovaSI = new OneWayAnova((Collection)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 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; i0){ + 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; ihynfM2Mq)UBrmQeOfRhI5x zO_+w?>9*g2_8tE(RbE&@T0&e^jX_@GkNni6oGd-VJiIJD&CJwnqYBd!>)w&elqiZb zos`^+lsZr}Fgg80tap2Mj0&o(imF=g+vulE0UAfW$ypnn`42>knxnX#KOx|+D^Xro^#axBDf^l>Ia)hgsT z5cE>b#dEN89P}{gFe=mrJkY2tiDn08zm*)-b-Q-+{vO{CYhENT9W4X^pIqj=->)XL0>K?jlKpim0f(T7EM2~H__4uyzNQ((AuWe& z8D$w|Z4%BUIfddn$J*1FGyJ@w$(e@|vsydRs-W0V}b&a}0W-hm_w>$Vm zXt39C%}kcL_F)?n=eu}81GjyL#XLqFL>&$oR^kBqMrqoUe-^iQ@-TQp&PWs9er zu;)|!=<#8#r$LaPDpvXovB8ET0Rm;6k3<0b%@zNMgQx z028xZEE42xQT*s_Tl~lADznfgkus?Pv0j0Kmz(xrN4P8xM_oC9#bEgk=Z&>H^cv@P0}r{%UL{`s~i9`QCmJ|QyUE-GHJ++QMnw*4Js745PjgWYxU za<^S$k;!p&b*iC>Q5p5Es7Yxj{!IL)G0>s!-klY@9uZV__E>+fJE zENqsvo8K4W`x#_2&oG%TMGt9inT49=bfjGJUM{bevu=@y%cnkF{(54P=ePcLh*^M+ zJQHVy93RhU?&HUeC40h&zt^BkzezV$ckmS_XZ6_(Nmxg`m2%B_Ef6 z(~6a4b8Q(8d(aE3L9%F|;`H6V%^!p^#J-qpm|X1GjMoJ}BEz-yeKb1Q<5f{K_zBug{X~=yt`V2m(c@HK>P=qVPy0UN8|74HFnV)884w|>5afX z{=v-oVsXe0HuoRmO^786@NR#>ix;fj$qCa+9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Xv1sa$TFtzY~bZ83Oe@` zQTo7nxCuWhZ*0>-Tc)+eTgZ!Yfw7a6%k_bMas5l(koq_jWh}I(TxbS9u}s=Wf_`_H z_niwuH?SN83Re(jnK8=t46Y>(bUmWm43Z6UNmXfB_8j=t@#CthwE+S6U&TdV;u2pz3g*o zii1{g2eg8)#8*fxlX*%21o(!CtMP5wc{$50{SvA9P1uVwhJ5jAIxi0=;G^7#aBK(> zrjB{z1bl=C5$gXD2vf&Ge$KFHq`8aRSj4?k`2Kn*s7wv+f5UXApj literal 0 HcmV?d00001 diff --git a/drawing/papaya/reference/allclasses-frame.html b/drawing/papaya/reference/allclasses-frame.html new file mode 100644 index 0000000..5089b69 --- /dev/null +++ b/drawing/papaya/reference/allclasses-frame.html @@ -0,0 +1,109 @@ + + + + + + +All Classes (Javadocs: papaya) + + + + + + + + + + + +All Classes +
+ + + + + +
BoxPlot +
+Cast +
+Comparison +
+Comparison.TTest +
+Correlation +
+Correlation.Significance +
+Correlation.Weighted +
+CorrelationPlot +
+Descriptive +
+Descriptive.Mean +
+Descriptive.Pooled +
+Descriptive.Sum +
+Descriptive.Weighted +
+Distance +
+Eigenvalue +
+Find +
+Frequency +
+Gamma +
+Linear +
+Linear.BoxCox +
+Linear.Significance +
+Linear.StdErr +
+LU +
+Mat +
+MDS +
+NaNs +
+Normality +
+Normality.Dago +
+OneWayAnova +
+PapayaConstants +
+Polynomial +
+Probability +
+QR +
+Rank +
+ScatterPlot +
+Sorting +
+SubPlot +
+SVD +
+Unique +
+Visuals +
+
+ + + diff --git a/drawing/papaya/reference/allclasses-noframe.html b/drawing/papaya/reference/allclasses-noframe.html new file mode 100644 index 0000000..b5c60eb --- /dev/null +++ b/drawing/papaya/reference/allclasses-noframe.html @@ -0,0 +1,109 @@ + + + + + + +All Classes (Javadocs: papaya) + + + + + + + + + + + +All Classes +
+ + + + + +
BoxPlot +
+Cast +
+Comparison +
+Comparison.TTest +
+Correlation +
+Correlation.Significance +
+Correlation.Weighted +
+CorrelationPlot +
+Descriptive +
+Descriptive.Mean +
+Descriptive.Pooled +
+Descriptive.Sum +
+Descriptive.Weighted +
+Distance +
+Eigenvalue +
+Find +
+Frequency +
+Gamma +
+Linear +
+Linear.BoxCox +
+Linear.Significance +
+Linear.StdErr +
+LU +
+Mat +
+MDS +
+NaNs +
+Normality +
+Normality.Dago +
+OneWayAnova +
+PapayaConstants +
+Polynomial +
+Probability +
+QR +
+Rank +
+ScatterPlot +
+Sorting +
+SubPlot +
+SVD +
+Unique +
+Visuals +
+
+ + + diff --git a/drawing/papaya/reference/constant-values.html b/drawing/papaya/reference/constant-values.html new file mode 100644 index 0000000..8585797 --- /dev/null +++ b/drawing/papaya/reference/constant-values.html @@ -0,0 +1,277 @@ + + + + + + +Constant Field Values (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+papaya.*
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
papaya.PapayaConstants
+public static final intBASELINE0
+public static final doublebig4.503599627370496E15
+public static final doublebiginv2.220446049250313E-16
+public static final intBOTTOM102
+public static final intCENTER3
+public static final intCORNER0
+public static final StringFONTNAME"Helvetica"
+public static final intINDEX_NOT_FOUND-1
+public static final intLEFT37
+public static final doubleLOGPI1.1447298858494002
+public static final doubleMACHEP1.1102230246251565E-16
+public static final doubleMAXGAM171.6243769563027
+public static final doubleMAXLOG709.782712893384
+public static final doubleMINLOG-745.1332191019412
+public static final intRIGHT39
+public static final doubleSQRTH0.7071067811865476
+public static final doubleSQTPI2.5066282746310007
+public static final intTOP101
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/deprecated-list.html b/drawing/papaya/reference/deprecated-list.html new file mode 100644 index 0000000..32cbfde --- /dev/null +++ b/drawing/papaya/reference/deprecated-list.html @@ -0,0 +1,147 @@ + + + + + + +Deprecated List (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents
    +
+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/help-doc.html b/drawing/papaya/reference/help-doc.html new file mode 100644 index 0000000..77f1c9e --- /dev/null +++ b/drawing/papaya/reference/help-doc.html @@ -0,0 +1,214 @@ + + + + + + +API Help (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    +
  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types
+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description +

    +

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary +

    +

  • Field Detail
  • Constructor Detail
  • Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

    +
  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail
+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

    +
  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail
+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    +
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/index-all.html b/drawing/papaya/reference/index-all.html new file mode 100644 index 0000000..a4e4669 --- /dev/null +++ b/drawing/papaya/reference/index-all.html @@ -0,0 +1,2076 @@ + + + + + + +Index (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A B C D E F G H I K L M N O P Q R S T U V W X Y Z
+

+A

+
+
abs(float[]) - +Static method in class papaya.Mat +
Return absolute values of an array +
abs(int[]) - +Static method in class papaya.Mat +
Return absolute values of an array +
arithmetic(float[]) - +Static method in class papaya.Descriptive.Mean +
Returns the arithmetic mean of a data sequence; + That is Sum( data[i] ) / data.length . +
arrayListToFloat(ArrayList<Float>) - +Static method in class papaya.Cast +
function for casting ArrayList to float[] +
arrayListToInt(ArrayList<Integer>) - +Static method in class papaya.Cast +
function for casting ArrayList to int[] +
asConnectedLines - +Variable in class papaya.ScatterPlot +
  +
asEllipses - +Variable in class papaya.ScatterPlot +
  +
asRectangles - +Variable in class papaya.ScatterPlot +
  +
auto(float[], int, float, float) - +Static method in class papaya.Correlation +
Computes the sample autocorrelation by removing the sample mean from the input series, + then normalizing the sequence by the sample variance. +
autoLag1(float[], float) - +Static method in class papaya.Correlation +
Returns the lag-1 autocorrelation of a dataset; + Note that this method uses computations different from + auto(data, 1, mean, variance). +
+
+

+B

+
+
BASELINE - +Static variable in interface papaya.PapayaConstants +
  +
bestFit(float[], float[]) - +Static method in class papaya.Linear +
Returns the slope and y-intercept of the best fit linear line + z = slope*x + intercept by minimizing the sum of least squares + between z and the y. +
bestFit(float[], float[], float) - +Static method in class papaya.Linear +
Returns the slope of the best fit linear line for the prescribed y-intercept. +
beta(double, double) - +Static method in class papaya.Gamma +
Returns the beta function of the arguments. +
betacdf(double, double, double) - +Static method in class papaya.Probability +
Returns the area from zero to x under the beta density + function. +
betacdfComplemented(double, double, double) - +Static method in class papaya.Probability +
Returns the area under the right hand tail (from x to + infinity) of the beta density function. +
betainv(double, double, double) - +Static method in class papaya.Probability +
Returns the inverse of the beta cumulative distribution function. +
bgColor - +Variable in class papaya.Visuals +
Specifies the plot background color +
big - +Static variable in interface papaya.PapayaConstants +
  +
biginv - +Static variable in interface papaya.PapayaConstants +
  +
binomcdf(double, int, int) - +Static method in class papaya.Probability +
Returns the sum of the terms 0 through k of the Binomial + probability density. +
binomcdfComplemented(double, int, int) - +Static method in class papaya.Probability +
Returns the sum of the terms k+1 through n of the Binomial + probability density. +
binominv(double, int, int) - +Static method in class papaya.Probability +
Finds the event probability p such that the sum of the + terms 0 through k of the Binomial probability density + is equal to the given cumulative probability y. +
BOTTOM - +Static variable in interface papaya.PapayaConstants +
  +
bottomBound - +Variable in class papaya.BoxPlot +
Specifies the space on the bottom, between the plot area and the bounding + rectangle. +
bottomBound - +Variable in class papaya.ScatterPlot +
Specifies the space on the bottom, between the plot area and the bounding + rectangle. +
bottomBound - +Variable in class papaya.SubPlot +
Specifies the space on the bottom, between the plot area and the bounding + rectangle. +
BoxPlot - Class in papaya
BoxPlot class
BoxPlot(PApplet, float, float, float, float) - +Constructor for class papaya.BoxPlot +
  +
+
+

+C

+
+
Cast - Class in papaya
Static Class for casting Object arrays to their corresponding primitive type.
ceilToNearest(float, int) - +Static method in class papaya.Mat +
Function for ceiling a number to the closest interval. +
CENTER - +Static variable in interface papaya.PapayaConstants +
  +
chebychev(float[][]) - +Static method in class papaya.Distance +
Computes the Chebychev distance matrix between pairs of objects + in the m-by-n data matrix X. +
chi2(float[]) - +Static method in class papaya.Normality.Dago +
Computes and returns an array containing the test statistic chi2, or the + "omnibus" test statistic, and the significance, or "p-value" of this test statistic. +
chi2cdf(double, double) - +Static method in class papaya.Probability +
Returns the area under the left hand tail (from 0 to x) + of the Chi square probability density function with + v degrees of freedom. +
chi2cdfComplemented(double, double) - +Static method in class papaya.Probability +
Returns the area under the right hand tail (from x to + infinity) of the Chi square probability density function + with v degrees of freedom. +
cityblock(float[][]) - +Static method in class papaya.Distance +
Computes the cityblock (or Manhattan) distance matrix between pairs of objects + in the m-by-n data matrix X. +
classical(float[][], int, boolean) - +Static method in class papaya.MDS +
Performs classical (metric) multidimensional scaling, on an input matrix of Distances (computed + using e.g. +
column(float[][], int, int) - +Static method in class papaya.Mat +
Function to get columns of a 2-D matrix. +
column(float[][], int) - +Static method in class papaya.Mat +
Function to get one column of a 2D matrix +
column(int[][], int) - +Static method in class papaya.Mat +
  +
columnMean(float[][]) - +Static method in class papaya.Descriptive.Mean +
Returns an array containing the arithmetic mean of each column + of the input matrix. +
compare(int, int) - +Static method in class papaya.Mat +
Returns -1 if a is less than b, or 1 if a is greater than b, or 0. +
compare(float, float) - +Static method in class papaya.Mat +
Returns -1 if a is less than b, or 1 if a is greater than b, or 0. +
Comparison - Class in papaya
Contains a number of methods for comparing more than one dataset + against each other.
Comparison() - +Constructor for class papaya.Comparison +
Makes this class non instantiable, but still let's others inherit from it. +
Comparison.TTest - Class in papaya
Methods related to comparing two populations.
compCumFrequency() - +Method in class papaya.Frequency +
Computes the cumulative frequency of the data. +
compRelCumFrequency() - +Method in class papaya.Frequency +
Computes the cumulative relative frequency of the data. +
compRelCumFrequencyPct() - +Method in class papaya.Frequency +
Computes the cumulative frequency of the data as a percentage. +
compRelFrequency() - +Method in class papaya.Frequency +
Computes the fraction of the total data that's in each bin. +
compRelFrequencyPct() - +Method in class papaya.Frequency +
Computes the percents of the total data that's in each bin. +
concat(float[], float[]) - +Static method in class papaya.Mat +
Concatenates two arrays a and b into a new array + c such that c = {a,b}. +
concat(int[], int[]) - +Static method in class papaya.Mat +
  +
cond() - +Method in class papaya.SVD +
Two norm condition number +
constant(float, int) - +Static method in class papaya.Mat +
Returns an array with of length size with + each element equal to the specified constValue. +
constant(int, int) - +Static method in class papaya.Mat +
Returns an array with of length size with + each element equal to the specified constValue. +
contains(Object[], Object) - +Static method in class papaya.Find +
Checks if the object is in the given array. +
contains(long[], long) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
contains(int[], int) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
contains(short[], short) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
contains(char[], char) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
contains(byte[], byte) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
contains(double[], double) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
contains(double[], double, double) - +Static method in class papaya.Find +
Checks if a value falling within the given tolerance is in the + given array. +
contains(float[], float) - +Static method in class papaya.Find +
Checks if the value is in the given array. +
containsNaNs(double[]) - +Static method in class papaya.NaNs +
Checks for presence of NaNs in the data array. +
containsNaNs(float[]) - +Static method in class papaya.NaNs +
Checks for presence of NaNs in the data array. +
copy(float[][]) - +Static method in class papaya.Mat +
Make a deep copy of a matrix +
copyThenSort(float[]) - +Static method in class papaya.Mat +
Sorts and returns a copy of the input array in ascending order +
CORNER - +Static variable in interface papaya.PapayaConstants +
  +
corr(float[][], float[], boolean) - +Static method in class papaya.Correlation.Weighted +
Returns the weighted linear correlation matrix C. +
corr(float[], float[], float[], boolean) - +Static method in class papaya.Correlation.Weighted +
Returns the weighted linear correlation of two data sequences. +
Correlation - Class in papaya
Contains utilities related to computing covariances, as well as linear and rank correlation.
correlation(float[][]) - +Static method in class papaya.Distance +
Computes the correlation distance matrix between pairs of objects + in the m-by-n data matrix X. +
correlation(float[], float[], float[]) - +Static method in class papaya.Linear.BoxCox +
Performs the box-cox transformation on y for a sequence of λ + and returns the array of linear correlation coefficients + between the x and the box-cox transformed y. +
Correlation.Significance - Class in papaya
Contains methods used to compute the significance, or pvalue of the input correlations.
Correlation.Weighted - Class in papaya
Contains methods related to computing the correlation and covariance of weighted + datasets.
CorrelationPlot - Class in papaya
Takes in a matrix and plots the data in each of the columns versus + each other.
CorrelationPlot(PApplet, float, float, float, float) - +Constructor for class papaya.CorrelationPlot +
Setup the plot dimensions +
cosine(float[][]) - +Static method in class papaya.Distance +
Computes the cosine distance matrix between pairs of objects + in the m-by-n data matrix X. +
cov(float[], float[], boolean) - +Static method in class papaya.Correlation +
Returns the covariance of two data sequences data1 and data2, + each of length N. +
cov(float[][], boolean) - +Static method in class papaya.Correlation +
Returns the covariance matrix of P data sequences, each of length N. +
cov(float[], float[], float[], boolean) - +Static method in class papaya.Correlation.Weighted +
Returns the weighted covariance between two data sequences. +
cov(float[][], float[], boolean) - +Static method in class papaya.Correlation.Weighted +
Returns the weighted covariance matrix with element S_JK specifying the weighted + covariance between column J and column K of the input matrix. +
cross(float[], float[]) - +Static method in class papaya.Mat +
vector cross product: c = a (cross) b +
+
+

+D

+
+
Descriptive - Class in papaya
Basic descriptive statistics class for exploratory data analysis.
Descriptive.Mean - Class in papaya
Contains methods for computing the arithmetic, geometric, harmonic, trimmed, and winsorized + means (among others).
Descriptive.Pooled - Class in papaya
Class for computing the pooled mean and variance of data sequences
Descriptive.Sum - Class in papaya
Methods for computing various different sums of datasets such as sum of inversions, + logs, products, power deviations, squares, etc.
Descriptive.Weighted - Class in papaya
Contains methods related to weighted datasets.
det() - +Method in class papaya.LU +
Determinant +
det(float[][]) - +Static method in class papaya.Mat +
returns the determinant of the square input matrix. +
dfbg() - +Method in class papaya.OneWayAnova +
Returns the degrees of freedom between groups. +
dfwg() - +Method in class papaya.OneWayAnova +
Returns the degrees of freedom within each group. +
Distance - Class in papaya
Contains methods for computing various "distance" metrics for multidimensional scaling.
divide(float[], float) - +Static method in class papaya.Mat +
Divides all elements of input array by value. +
divide(float[], float[]) - +Static method in class papaya.Mat +
Element by element division such that z[i] = x[i]/y[i]. +
divide(float[][], float) - +Static method in class papaya.Mat +
Divides each element of the input matrix A by the input value +
dotDivide(float[][], float[][]) - +Static method in class papaya.Mat +
Element by element matrix division such that C_ij = A_ij/B_ij. +
dotMultiply(float[][], float[][]) - +Static method in class papaya.Mat +
Element by element matrix multiplication such that C_ij = A_ij*B_ij. +
dotProduct(float[], float[]) - +Static method in class papaya.Mat +
dot product of two arrays such that z = sum(a_i*b_i) +
doubleToFloat(double[][]) - +Static method in class papaya.Cast +
function for casting double[][] to float[][] +
doubleToFloat(double[]) - +Static method in class papaya.Cast +
function for casting double[] to float[] +
drawAxes - +Variable in class papaya.BoxPlot +
Specifies whether to draw the axes +
drawAxes - +Variable in class papaya.ScatterPlot +
Specifies whether to draw the axes +
drawAxes - +Variable in class papaya.SubPlot +
Specifies whether to draw the axes +
drawAxes(int, float) - +Method in class papaya.Visuals +
Draws the plot axes using a line with color _sColor, and weight _sWeight +
drawBorderAndLabels(String[], int) - +Method in class papaya.CorrelationPlot +
Draw the bordering lines and write the labels. +
drawBoxPlot(String[], float, int) - +Method in class papaya.BoxPlot +
Plot the box plots. +
drawPlot(float[][], int, int) - +Method in class papaya.CorrelationPlot +
Plots the scatter plot of each of the columns of the input data matrix vs. +
drawRect() - +Method in class papaya.Visuals +
Draw the plot background rectangle using the default plot + dimensions and background color. +
drawRect(float, float, float, float, int) - +Method in class papaya.Visuals +
Draws the plot background rectangle using the input dimensions and + background color. +
drawRectangle - +Variable in class papaya.BoxPlot +
Specifies whether to draw the bounding rectangle around the plot. +
drawRectangle - +Variable in class papaya.ScatterPlot +
Specifies whether to draw the bounding rectangle around the plot. +
drawRectangle() - +Method in class papaya.ScatterPlot +
Draws a rectangle around the plot. +
drawRectangle - +Variable in class papaya.SubPlot +
Specifies whether to draw the bounding rectangle around the plot. +
drawScatterPlot(float[], float[], float, int) - +Method in class papaya.ScatterPlot +
Parent function to plot scatter plot of the data. +
drawScatterPlot(float[], float[], int, int, int) - +Method in class papaya.SubPlot +
Draws the scatterplot for subplot(xnum,ynum) by calling ScatterPlot.drawScatterPlot(float[], float[], float, int). +
durbinWatson(float[]) - +Static method in class papaya.Correlation.Significance +
The Durbin-Watson statistic is a test statistic used to detect the presence + of autocorrelation (Correlation.auto(float[], int, float, float)) + in the residuals (prediction errors) from a regression analysis. +
+
+

+E

+
+
Eigenvalue - Class in papaya
Eigenvalues and eigenvectors of a real matrix.
Eigenvalue(float[][]) - +Constructor for class papaya.Eigenvalue +
Check for symmetry, then construct the eigenvalue decomposition. +
eliminate(double[]) - +Static method in class papaya.NaNs +
Eliminate the NaNs from the input array. +
eliminate(float[]) - +Static method in class papaya.NaNs +
Eliminate the NaNs from the input array. +
equalVar(float[], float[]) - +Static method in class papaya.Comparison.TTest +
Returns the t-statistic and p-value for checking whether the means + between the two datasets are different under the assumption that both + datasets have equal variances. +
erf(double) - +Static method in class papaya.Probability +
Returns the error function of the normal distribution. +
erfComplemented(double) - +Static method in class papaya.Probability +
Returns the complementary Error function of the normal distribution; formerly named erfc. +
etasqrd() - +Method in class papaya.OneWayAnova +
Computes eta^2: a measure of the strength of the curvilinear relationship + between the independent and dependent variable. +
euclidean(float[][]) - +Static method in class papaya.Distance +
Computes the Euclidean distance between pairs of objects + in the m-by-n data matrix X. +
+
+

+F

+
+
F() - +Method in class papaya.OneWayAnova +
Returns the test statistic F. +
fcdf(double, int, int) - +Static method in class papaya.Probability +
Returns the area from zero to x under the F density + function (also known as Snedcor's density or the + variance ratio density); formerly named fdtr. +
fcdfComplemented(double, int, int) - +Static method in class papaya.Probability +
Returns the area from x to infinity under the F density + function (also known as Snedcor's density or the + variance ratio density); formerly named fdtrc. +
Find - Class in papaya
Static class for finding indices in an array corresponding to a given value/object.
finv(double, int, int) - +Static method in class papaya.Probability +
Finds the F density argument x such that the integral + from 0 to x of the F density is equal to p; formerly named fdtri. +
floatToDouble(float[][]) - +Static method in class papaya.Cast +
function for casting float[][] to double[][] +
floatToDouble(float[]) - +Static method in class papaya.Cast +
function for casting float[] to double[] +
floatToPVector(float[], float[], float[]) - +Static method in class papaya.Cast +
Returns a PVector array with the x, y, and z coordinates set to the input values + (technically not a cast, but a reorganization). +
floatToPVector(float[], float[]) - +Static method in class papaya.Cast +
Returns a PVector array with the x, and coordinates set to the input values, and the z coordinates + set to zero. +
floorToNearest(float, int) - +Static method in class papaya.Mat +
Function for flooring a number to the closest interval. +
FONTNAME - +Static variable in interface papaya.PapayaConstants +
Default font used. +
frequencies(float[], ArrayList<Float>, ArrayList<Integer>) - +Static method in class papaya.Descriptive +
Computes the frequency (number of occurances, count) of each distinct value in the given sorted data. +
frequencies - +Variable in class papaya.Unique +
ArrayList containing the frequencies of the corresponding unique value +
Frequency - Class in papaya
Class for getting the frequency distribution, cumulative frequency distribution, and other + distribution-related parameters of a given array of floats or ints.
Frequency(float[], float, float, float) - +Constructor for class papaya.Frequency +
Initialize the class by setting the minimum value, maximum value, and the bin width. +
Frequency(int[], int, int, int) - +Constructor for class papaya.Frequency +
Initialize the class by setting the minimum value, maximum value, and the bin width. +
+
+

+G

+
+
Gamma - Class in papaya
Gamma and Beta functions.
gamma(double) - +Static method in class papaya.Gamma +
Returns the Gamma function of the argument, Γ(x) +
gammacdf(double, double, double) - +Static method in class papaya.Probability +
Returns the integral from zero to x of the gamma probability + density function. +
gammacdfComplemented(double, double, double) - +Static method in class papaya.Probability +
Returns the integral from x to infinity of the gamma + probability density function: +
geometric(int, float) - +Static method in class papaya.Descriptive.Mean +
Returns the geometric mean of a data sequence. +
geometric(float[]) - +Static method in class papaya.Descriptive.Mean +
Returns the geometric mean of a data sequence. +
getBottom() - +Method in class papaya.Visuals +
  +
getD() - +Method in class papaya.Eigenvalue +
Return the block diagonal eigenvalue matrix +
getData() - +Method in class papaya.BoxPlot +
  +
getFloatPivot() - +Method in class papaya.LU +
Return pivot permutation vector as a one-dimensional float array +
getFrequency() - +Method in class papaya.Frequency +
Returns the pre-computed frequency array. +
getH() - +Method in class papaya.QR +
Return the Householder vectors +
getHeight() - +Method in class papaya.Visuals +
  +
getImagEigenvalues() - +Method in class papaya.Eigenvalue +
Return the imaginary parts of the eigenvalues +
getL() - +Method in class papaya.LU +
Return lower triangular factor, L. +
getLeft() - +Method in class papaya.Visuals +
  +
getLength() - +Method in class papaya.Frequency +
returns the length of the dataset. +
getNaNPositions(double[]) - +Static method in class papaya.NaNs +
Returns an array list of indexes where data[i] is NaN. +
getNaNPositions(float[]) - +Static method in class papaya.NaNs +
Returns an array list of indexes where data[i] is NaN. +
getNumBins() - +Method in class papaya.Frequency +
Returns the number of bins. +
getPivot() - +Method in class papaya.LU +
Return pivot permutation vector +
getQ() - +Method in class papaya.QR +
Generate and return the (economy-sized) orthogonal factor +
getR() - +Method in class papaya.QR +
Return the upper triangular factor +
getRealEigenvalues() - +Method in class papaya.Eigenvalue +
Return the real parts of the eigenvalues +
getRight() - +Method in class papaya.Visuals +
  +
getS() - +Method in class papaya.SVD +
Return the diagonal matrix of singular values +
getSingularValues() - +Method in class papaya.SVD +
Return the one-dimensional array of singular values +
getTop() - +Method in class papaya.Visuals +
  +
getU() - +Method in class papaya.LU +
Return upper triangular factor, U +
getU() - +Method in class papaya.SVD +
Return the left singular vectors +
getV() - +Method in class papaya.Eigenvalue +
Return the eigenvector matrix with each column corresponding to + an eigenvector of the input matrix. +
getV() - +Method in class papaya.SVD +
Return the right singular vectors +
getWidth() - +Method in class papaya.Visuals +
  +
GRAY - +Static variable in interface papaya.PapayaConstants +
  +
+
+

+H

+
+
harmonic(int, float) - +Static method in class papaya.Descriptive.Mean +
Returns the harmonic mean of a data sequence. +
harmonic(float[]) - +Static method in class papaya.Descriptive.Mean +
Returns the harmonic mean of a data sequence as Sum( 1.0 / data[i]). +
horizLine(float, float, float, int, float) - +Method in class papaya.Visuals +
draws a horizonal line with color _sColor, and weight _sWeight +
+
+

+I

+
+
identity(int) - +Static method in class papaya.Mat +
returns the identity matrix of the specified dimension +
idx - +Variable in class papaya.Unique +
Class containing the integer arrays that hold the indices of each unique value. +
incompleteBeta(double, double, double) - +Static method in class papaya.Gamma +
Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta. +
incompleteBetaInverse(double, double, double) - +Static method in class papaya.Gamma +
Returns the inverse of the incomplete Beta integral. +
incompleteGamma(double, double) - +Static method in class papaya.Gamma +
Returns the Incomplete Gamma function; formerly named igamma. +
incompleteGammaComplement(double, double) - +Static method in class papaya.Gamma +
Returns the Complemented Incomplete Gamma function; formerly named igamc. +
INDEX_NOT_FOUND - +Static variable in interface papaya.PapayaConstants +
Index to return if a given value/object is not found in the Cast function. +
indexOf(Object[], Object) - +Static method in class papaya.Find +
Finds the index of the given object in the array. +
indexOf(Object[], Object, int) - +Static method in class papaya.Find +
Finds the index of the given object in the array starting at the given index. +
indexOf(long[], long) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(long[], long, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(int[], int) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(int[], int, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(short[], short) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(short[], short, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(char[], char) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(char[], char, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(byte[], byte) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(byte[], byte, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(double[], double) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(double[], double, double) - +Static method in class papaya.Find +
Finds the index of the given value within a given tolerance in the array. +
indexOf(double[], double, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(double[], double, int, double) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(float[], float) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(float[], float, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indexOf(boolean[], boolean) - +Static method in class papaya.Find +
Finds the index of the given value in the array. +
indexOf(boolean[], boolean, int) - +Static method in class papaya.Find +
Finds the index of the given value in the array starting at the given index. +
indices(float[], boolean) - +Static method in class papaya.Sorting +
Gets the array of indices that can be used to sort the array in ascending or + descending order. +
indices(double[], boolean) - +Static method in class papaya.Sorting +
  +
indices(int[], boolean) - +Static method in class papaya.Sorting +
  +
indices(float[], int, int, boolean) - +Static method in class papaya.Sorting +
Gets the array of indices that can be used to sort the section of the + input array going from fromIndex(inclusive) to toIndex(exclusive) + in ascending or descending order. +
indices(double[], int, int, boolean) - +Static method in class papaya.Sorting +
  +
indices(int[], int, int, boolean) - +Static method in class papaya.Sorting +
  +
INDICES_NOT_FOUND - +Static variable in interface papaya.PapayaConstants +
Index array to return if a given value/object is not found in the Cast function. +
indicesGreaterThan(int[], int) - +Static method in class papaya.Find +
  +
indicesGreaterThan(float[], float) - +Static method in class papaya.Find +
  +
indicesGreaterThanOrEqualTo(int[], int) - +Static method in class papaya.Find +
  +
indicesGreaterThanOrEqualTo(float[], float) - +Static method in class papaya.Find +
  +
indicesLessThan(int[], int) - +Static method in class papaya.Find +
  +
indicesLessThan(float[], float) - +Static method in class papaya.Find +
  +
indicesLessThanOrEqualTo(int[], int) - +Static method in class papaya.Find +
  +
indicesLessThanOrEqualTo(float[], float) - +Static method in class papaya.Find +
  +
indicesWith(Object[], Object) - +Static method in class papaya.Find +
Finds the indices containing the specified object in the array. +
indicesWith(Object[], Object, int) - +Static method in class papaya.Find +
Finds the indices containing the specified object in the array. +
indicesWith(long[], long) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(long[], long, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(int[], int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(int[], int, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(short[], short) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(short[], short, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(char[], char) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(char[], char, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(byte[], byte) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(byte[], byte, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(double[], double) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(double[], double, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(float[], float) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(float[], float, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(boolean[], boolean) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWith(boolean[], boolean, int) - +Static method in class papaya.Find +
Finds the indices containing the specified value in the array. +
indicesWithin(int[], float, float) - +Static method in class papaya.Find +
Finds the indices for the array elements within the min and max value (inclusive). +
indicesWithin(float[], float, float) - +Static method in class papaya.Find +
Finds the indices for the array elements within the min and max value (inclusive). +
intercept(float, float, int) - +Static method in class papaya.Linear.Significance +
Returns the p-value, or significance, of the computed intercept under the null-hypothesis + of intercept = 0 (two-tailed test). +
intercept(float[], float) - +Static method in class papaya.Linear.StdErr +
Returns the standard error of the computed slope given x and the + standard error in the residuals. +
inverse(float[], float) - +Static method in class papaya.Mat +
Returns the array z[i] = 1/x[i]; If x[i] is zero, it sets z[i] + to the specified replaceZeroWith value instead. +
inverse(float[][]) - +Static method in class papaya.Mat +
Matrix inverse if A is square, pseudoinverse otherwise +
inversions(float[], int, int) - +Static method in class papaya.Descriptive.Sum +
Returns the sum of inversions of a data sequence, + which is Sum( 1.0 / data[i]). +
isConstant(float[]) - +Static method in class papaya.Mat +
  +
isFullRank() - +Method in class papaya.QR +
Is the matrix full rank? +
isNonsingular() - +Method in class papaya.LU +
Is the matrix nonsingular? +
+
+

+K

+
+
keySetToFloat(HashMap) - +Static method in class papaya.Cast +
Function for casting hashMap keySet to float[] +
keySetToInt(HashMap) - +Static method in class papaya.Cast +
Function for casting hashMap keySet to float[] +
keySetToString(HashMap) - +Static method in class papaya.Cast +
Function for casting hashMap keySet to String[] +
kurtosis(float, float) - +Static method in class papaya.Descriptive +
Returns the kurtosis (aka excess) of a data sequence. +
kurtosis(float[], float, float) - +Static method in class papaya.Descriptive +
Returns the kurtosis (aka excess) of a data sequence, which is + -3 + moment(data,4,mean) / standardDeviation4. +
kurtosis(float[]) - +Static method in class papaya.Normality.Dago +
Computes and returns an array containing the test statistic zb2associated with + b2 and the significance, or "p-value" of the kurtosis test statistic zb2, assuming a + two-tailed null hypothesis as well as . +
+
+

+L

+
+
lastIndexOf(Object[], Object) - +Static method in class papaya.Find +
Finds the last index of the given object within the array. +
lastIndexOf(Object[], Object, int) - +Static method in class papaya.Find +
Finds the last index of the given object in the array starting at the given index. +
lastIndexOf(long[], long) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(long[], long, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(int[], int) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(int[], int, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(short[], short) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(short[], short, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(char[], char) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(char[], char, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(byte[], byte) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(byte[], byte, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(double[], double) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(double[], double, double) - +Static method in class papaya.Find +
Finds the last index of the given value within a given tolerance in the array. +
lastIndexOf(double[], double, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(double[], double, int, double) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(float[], float) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(float[], float, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
lastIndexOf(boolean[], boolean) - +Static method in class papaya.Find +
Finds the last index of the given value within the array. +
lastIndexOf(boolean[], boolean, int) - +Static method in class papaya.Find +
Finds the last index of the given value in the array starting at the given index. +
LEFT - +Static variable in interface papaya.PapayaConstants +
  +
leftBound - +Variable in class papaya.BoxPlot +
Specifies the space on the left between the plot area, and the + bounding rectangle. +
leftBound - +Variable in class papaya.ScatterPlot +
Specifies the space on the left between the plot area, and the + bounding rectangle. +
leftBound - +Variable in class papaya.SubPlot +
Specifies the space on the left between the plot area, and the + bounding rectangle. +
legendHoriz(String, int[], String[]) - +Method in class papaya.SubPlot +
Draws a legend going to the right with the first element situated at (x,y). +
legendHoriz(float, float, int[], String[]) - +Method in class papaya.Visuals +
Draws a legend going to the right with the first element situated at (x,y). +
legendVert(float, float, int[], String[]) - +Method in class papaya.SubPlot +
Draws a legend going downwards with the first element situated at (x,y). +
legendVert(float, float, int[], String[]) - +Method in class papaya.Visuals +
Draws a legend going downwards with the first element situated at (x,y). +
line(float, float, float, float, int, float) - +Method in class papaya.Visuals +
Draws a straight line going from (x[0],y[0]) to (x[1],y[1]) + with color _sColor, and weight _sWeight +
linear(float[][], boolean) - +Static method in class papaya.Correlation +
Returns the (Pearson Product Moment) correlation matrix between multiple columns of a matrix + with each column corresponding to a dataset, and each row an observation. +
linear(float[], float[], boolean) - +Static method in class papaya.Correlation +
Returns the (Pearson Product Moment) linear correlation of two data sequences. +
linear(float, int) - +Static method in class papaya.Correlation.Significance +
Returns the p-value, or significance level of the linear correlation r + between two datasets under the null hypothesis of no correlation. +
Linear - Class in papaya
Contains methods related to determining the linear linear + relationship between two datasets (of equal arrays) such as the + best-fit linear line parameters, box-cox transformations, etc.
Linear() - +Constructor for class papaya.Linear +
  +
Linear.BoxCox - Class in papaya
Contains methods related to the Box-Cox transformation of a data set; useful in + determining the best transformation that will yield the best method for converting + a monotonic, non-linear relationship between x and y into + a linear one.
Linear.Significance - Class in papaya
Contains methods used to compute the significance, or pvalue of the input correlations.
Linear.Significance() - +Constructor for class papaya.Linear.Significance +
  +
Linear.StdErr - Class in papaya
Contains methods related to computing the standard errors of the residuals, slope and intercept + associated with the best-fit linear line.
linspace(int, int) - +Static method in class papaya.Mat +
Returns the array of (end-start+1) points going from + start (inclusive) to end (inclusive): + y[0] = start; y[1] = start+1; ... +
linspace(int, int, int) - +Static method in class papaya.Mat +
  +
linspace(float, float, float) - +Static method in class papaya.Mat +
  +
log(float[]) - +Static method in class papaya.Mat +
Returns an array with each element equal to the natural logarithm (the base-e logarithm) + the corresponding input array. +
log10(float[]) - +Static method in class papaya.Mat +
Returns an array with each element equal to the log 10 value (base 10 logarithm) + of the corresponding input array. +
logGamma(double) - +Static method in class papaya.Gamma +
Returns the natural logarithm of the gamma function; formerly named lgamma. +
LOGPI - +Static variable in interface papaya.PapayaConstants +
  +
logs(float[], int, int) - +Static method in class papaya.Descriptive.Sum +
Returns the sum of logarithms of a data sequence, which is Sum( Log(data[i]). +
logToBase(float[], float) - +Static method in class papaya.Mat +
Returns an array with each element equal to the log A value + of the corresponding input array. +
LU - Class in papaya
LU Decomposition.
LU(float[][]) - +Constructor for class papaya.LU +
Constructor. +
+
+

+M

+
+
MACHEP - +Static variable in interface papaya.PapayaConstants +
machine constants +
mag(float[]) - +Static method in class papaya.Mat +
Returns the magnitude of the input array = sqrt(x1^2 + x2^2 + ... +
mahalanobis(float[][]) - +Static method in class papaya.Distance +
Computes the Mahalanobis distance matrix of the m-by-n input matrix X. +
mannWhitney(float[], float[]) - +Static method in class papaya.Comparison +
Computes and returns the MannWhitney (or Wilcoxon Rank Sum) test statistic, U and p-value for + assessing whether one of two samples of independent observations tends to have + larger values than the other. +
map(float, float, float, float, float) - +Static method in class papaya.Mat +
Convenience function to map a variable from one coordinate space to another. +
map(float[], float, float) - +Static method in class papaya.Mat +
Similar to map([] value, valueArrayMinimum, valueArrayMaximum, from, to) +
map(float[], float, float, float, float) - +Static method in class papaya.Mat +
Function for mapping an input array of floats for plotting + Extends processing "map" function to accomodate + arrays. +
mapXData(float[]) - +Method in class papaya.Visuals +
Maps the x-data from the range min(data) to max(data) to + the plotLeft and plotLeft+plotWidth. +
mapXData(float[], float, float) - +Method in class papaya.Visuals +
Maps the x-data from the range minXDat to maxXDat to + the plotLeft and plotRight. +
mapYData(float[]) - +Method in class papaya.Visuals +
Maps the y-data from the range min(data) to max(data) to + the plotBottom and plotTop. +
mapYData(float[], float, float) - +Method in class papaya.Visuals +
Maps the y-data from the range minYDat to maxYDat to + the plotBottom and plotTop. +
Mat - Class in papaya
Static class for performing some basic matrix operations.
max(int, int) - +Static method in class papaya.Descriptive +
  +
max(float, float) - +Static method in class papaya.Descriptive +
  +
max(double, double) - +Static method in class papaya.Descriptive +
  +
max(double[]) - +Static method in class papaya.Descriptive +
Returns the largest member of a data sequence. +
max(float[]) - +Static method in class papaya.Descriptive +
Returns the largest member of a data sequence. +
max(int[]) - +Static method in class papaya.Descriptive +
Returns the largest member of a data sequence. +
max(float[][]) - +Static method in class papaya.Descriptive +
Returns the largest member of a matrix. +
max(int[][]) - +Static method in class papaya.Descriptive +
Returns the largest member of a matrix. +
MAXGAM - +Static variable in interface papaya.PapayaConstants +
  +
MAXLOG - +Static variable in interface papaya.PapayaConstants +
  +
MDS - Class in papaya
Contains methods for performing but classical and non-classical multidimensional scaling.
mean(float[]) - +Static method in class papaya.Descriptive +
Returns the arithmetic mean of a data sequence; + That is Sum( data[i] ) / data.length . +
mean(float, int, float, int) - +Static method in class papaya.Descriptive.Pooled +
Returns the pooled mean of two data sequences. +
mean(float[], int[]) - +Static method in class papaya.Descriptive.Pooled +
Returns the pooled mean of a k data sequences. +
mean(float[], float[]) - +Static method in class papaya.Descriptive.Weighted +
Returns the weighted mean of a data sequence. +
meanDeviation(float[], float) - +Static method in class papaya.Descriptive +
Returns the mean deviation of a dataset. +
median(float[], boolean) - +Static method in class papaya.Descriptive +
Returns the median of a data sequence. +
min(int, int) - +Static method in class papaya.Descriptive +
  +
min(float, float) - +Static method in class papaya.Descriptive +
  +
min(double, double) - +Static method in class papaya.Descriptive +
  +
min(double[]) - +Static method in class papaya.Descriptive +
Returns the smallest member of a data sequence. +
min(float[]) - +Static method in class papaya.Descriptive +
Returns the smallest member of a data sequence. +
min(float[][]) - +Static method in class papaya.Descriptive +
Returns the smallest member of a matrix. +
min(int[]) - +Static method in class papaya.Descriptive +
Returns the smallest member of a data sequence. +
min(int[][]) - +Static method in class papaya.Descriptive +
Returns the smallest member of a matrix. +
minkowski(float[][], int) - +Static method in class papaya.Distance +
Returns the Minkowski distance matrix of the m-by-n input matrix X. +
MINLOG - +Static variable in interface papaya.PapayaConstants +
  +
mod(float[]) - +Static method in class papaya.Descriptive +
Returns the array containing the elements that appear the most in a given dataset. +
moment(float[], int, float) - +Static method in class papaya.Descriptive +
Returns the moment of k-th order with constant c of a data sequence, + which is Sum( (data[i]-c)k ) / data.size(). +
multiply(float[][], float[][]) - +Static method in class papaya.Mat +
Multiplies two matrices A and B returning C = A*B + where C_ij = Sum(k=1 to n) A_ik*B_kj. +
multiply(float[][], float[]) - +Static method in class papaya.Mat +
Multiplies the matrix A with the vector x returning A*x = y + where y_j= Sum(k=j to n) A_ij*x_j. +
multiply(float[][], float) - +Static method in class papaya.Mat +
Multiplies the matrix A with the scalar a returning a*A = B + where B_ij = a*A_ij. +
multiply(float[], float[]) - +Static method in class papaya.Mat +
Multiplies two arrays and returns the multiplied array. +
multiply(float[], float) - +Static method in class papaya.Mat +
Multiplies each element of an array by a number, and returns the multiplied array. +
+
+

+N

+
+
NaNs - Class in papaya
Contains various methods for dealing with NaNs in your data.
nbinomcdf(double, int, int) - +Static method in class papaya.Probability +
Returns the sum of the terms 0 through k of the Negative Binomial Distribution. +
nbinomcdfComplemented(double, int, int) - +Static method in class papaya.Probability +
Returns the sum of the terms k+1 to infinity of the Negative + Binomial distribution. +
norm1(float[][]) - +Static method in class papaya.Mat +
Returns the norm1 of the input matrix, equal to the + maximum absolute column sum of the matrix. +
norm2(float[][]) - +Static method in class papaya.Mat +
Returns the norm2 (or maximum singular value) of the input matrix. +
norm2(float[]) - +Static method in class papaya.Mat +
Returns the norm2 or magnitude of an array. +
norm2() - +Method in class papaya.SVD +
Two norm +
Normality - Class in papaya
Contains various utilities for checking if the dataset comes from a normal distribution.
Normality.Dago - Class in papaya
Methods for computing the skewnewss, kurtosis, and D'Agostino-Peasrson K^2 "omnibus" test-statistics (that + combine the former two), and accompanying significance (or p-values) + for testing the underlying population normality.
normalizeToMinMax(float[]) - +Static method in class papaya.Mat +
Returns an array with elements consisting of the data + normalized to the specified min/max; new data goes from 0 to 1. +
normalizeToSum(float[]) - +Static method in class papaya.Mat +
Returns an array with elements given by z[i] = data[i] / sum(data); +
normalProbability(float[]) - +Static method in class papaya.Normality +
Return the Normal order statistic medians (N) necessary to produce a Q-Q plot + for a normal distribution (or normal probability plot). +
normcdf(double) - +Static method in class papaya.Probability +
Returns the area under the Normal (Gaussian) probability density + function, integrated from minus infinity to x (assumes mean is zero, variance is one). +
normcdf(double, double, double) - +Static method in class papaya.Probability +
Returns the area under the Normal (Gaussian) probability density + function, integrated from minus infinity to x when the + data has not been standardized (i.e. +
normF(float[][]) - +Static method in class papaya.Mat +
/** Returns the Frobenius norm of the input matrix; + sqrt of sum of squares of all elements. +
normInf(float[][]) - +Static method in class papaya.Mat +
Returns the Infinity norm of the input matrix, equal to the + maximum row sum. +
norminv(double) - +Static method in class papaya.Probability +
Returns the value, x, for which the area under the + Normal (Gaussian) probability density function (integrated from + minus infinity to x) is equal to the argument y + (assumes mean is zero, variance is one); formerly named ndtri. +
numGreaterThan(int[], int) - +Static method in class papaya.Find +
Finds the number of elements strictly greater than the specified value. +
numGreaterThan(float[], float) - +Static method in class papaya.Find +
Finds the number of elements strictly greater than the specified value. +
numGreaterThanOrEqualTo(int[], int) - +Static method in class papaya.Find +
Finds the number of elements greater than or equal to the specified value. +
numGreaterThanOrEqualTo(float[], float) - +Static method in class papaya.Find +
Finds the number of elements greater than or equal to the specified value. +
numLessThan(int[], int) - +Static method in class papaya.Find +
Finds the number of elements strictly less than the specified value. +
numLessThan(float[], float) - +Static method in class papaya.Find +
Finds the number of elements strictly less than the specified value. +
numLessThanOrEqualTo(int[], int) - +Static method in class papaya.Find +
Finds the number of elements less than or equal to the specified value. +
numLessThanOrEqualTo(float[], float) - +Static method in class papaya.Find +
Finds the number of elements less than or equal to the specified value. +
numRepeats(Object[], Object) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(long[], long) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(int[], int) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(short[], short) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(char[], char) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(byte[], byte) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(double[], double) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(float[], float) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
numRepeats(boolean[], boolean) - +Static method in class papaya.Find +
Finds the number of times a given value/object is present in an array. +
+
+

+O

+
+
OneWayAnova - Class in papaya
Computes the one-way ANOVA p-value to test the equality of two or more sample + means by analyzing the sample variances using the test statistic + F = variance between samples / variance within samples.
OneWayAnova(Collection<float[]>) - +Constructor for class papaya.OneWayAnova +
Performs an Analysis of Variance (ANOVA) for a collection of float arrays. +
outliers(float[], float, float, boolean) - +Static method in class papaya.Descriptive +
Returns the array containing all elements in the dataset that are less than + or equal to the lowerLimit + and more than or equal to the upperLimit +
+
+

+P

+
+
paired(float[], float[]) - +Static method in class papaya.Comparison.TTest +
Returns the t-statistic and p-value for checking a pair of dependent samples. +
papaya - package papaya
 
PapayaConstants - Interface in papaya
PapayaConstants stores some of the constants used in plotting.
poissoncdf(double, int) - +Static method in class papaya.Probability +
Returns the sum of the first k terms of the Poisson distribution. +
poissoncdfComplemented(int, double) - +Static method in class papaya.Probability +
Returns the sum of the terms k+1 to Infinity of the Poisson distribution. +
Polynomial - Class in papaya
Static Class for casting one variable type to another.
polyval(double, double[]) - +Static method in class papaya.Polynomial +
y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. +
polyval(double[], double[]) - +Static method in class papaya.Polynomial +
y = polyval(x,coeff) returns the array values of a polynomial of degree n evaluated at + each element of x. +
polyval(float, float[]) - +Static method in class papaya.Polynomial +
y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. +
polyval(float[], float[]) - +Static method in class papaya.Polynomial +
y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. +
populate(double[], int[]) - +Static method in class papaya.Mat +
Returns an array with each element corresponding to fullDataset[indices[i]]. +
populate(float[], int[]) - +Static method in class papaya.Mat +
Returns an array with each element corresponding to fullDataset[indices[i]]. +
populate(int[], int[]) - +Static method in class papaya.Mat +
Returns an array with each element corresponding to fullDataset[indices[i]]. +
populate(String[], int[]) - +Static method in class papaya.Mat +
Returns an array with each element corresponding to fullDataset[indices[i]]. +
powerDeviations(float[], int, float) - +Static method in class papaya.Descriptive.Sum +
Returns Sum( (data[i]-c)k ); + optimized for common parameters like c == 0.0 and/or k == -2 .. +
powerDeviations(float[], int, float, int, int) - +Static method in class papaya.Descriptive.Sum +
Returns Sum( (data[i]-c)k ) for all i = from .. +
powers(float[], int) - +Static method in class papaya.Descriptive.Sum +
Returns the sum of powers of a data sequence, which is Sum ( data[i]k ). +
print(double[], int) - +Static method in class papaya.Mat +
Print the array to the screen in a single line. +
print(double[][], int) - +Static method in class papaya.Mat +
Print the matrix to the screen with each row of the + matrix taking up one line. +
print(double[][], String[], String[], int) - +Static method in class papaya.Mat +
Print the matrix to the screen with the columns and rows labeled according to the + input strings. +
print(float[], int) - +Static method in class papaya.Mat +
Print the array to the screen in a single line. +
print(float[][], int) - +Static method in class papaya.Mat +
Print the matrix to the screen with each row of the + matrix taking up one line. +
print(float[][], String[], String[], int) - +Static method in class papaya.Mat +
Print the matrix to the screen with the columns and rows labeled according to the + input strings. +
print(int[], int) - +Static method in class papaya.Mat +
Print the array to the screen in a single line. +
print(int[][], int) - +Static method in class papaya.Mat +
Print the matrix to the screen with each row of the + matrix taking up one line. +
print(int[][], String[], String[], int) - +Static method in class papaya.Mat +
Print the matrix to the screen with the columns and rows labeled according to the + input strings. +
Probability - Class in papaya
Cumulative distribution functions and corresponding inverses of certain probability distributions.
product(int, float) - +Static method in class papaya.Descriptive +
Returns the product, which is Prod( data[i] ). +
product(float[]) - +Static method in class papaya.Descriptive +
Returns the product of a data sequence, which is Prod( data[i] ). +
products(float[], float[]) - +Static method in class papaya.Descriptive.Sum +
Returns the sum of the product of two data arrays, Sum( x[i] * y[i]). +
pValue() - +Method in class papaya.OneWayAnova +
Returns the significance, or "p-value" of the test statistic OneWayAnova.F(). +
pValues(float[]) - +Static method in class papaya.Normality.Dago +
Returns an array containing the three significance, or p-values, for testing normality. +
+
+

+Q

+
+
QR - Class in papaya
QR Decomposition.
QR(float[][]) - +Constructor for class papaya.QR +
QR Decomposition, computed by Householder reflections. +
quantile(float[], float) - +Static method in class papaya.Descriptive +
Returns the phi-quantile; that is, an element elem + for which holds that phi percent of data elements are less than + elem. +
quantileInverse(float[], float) - +Static method in class papaya.Descriptive +
Returns how many percent of the elements contained in the receiver are <= element. +
quantiles(float[], float[]) - +Static method in class papaya.Descriptive +
Returns the quantiles of the specified percentages. +
quartiles(float[], boolean) - +Static method in class papaya.Descriptive +
Returns the quartiles of the input data array (not necessarily sorted). +
+
+

+R

+
+
rank(float[][]) - +Static method in class papaya.Mat +
Returns the effective numerical rank (obtained from SVD) + of the input matrix. +
Rank - Class in papaya
Ranking based on the natural ordering on floats for a sequence of data that may also + contain NaNs.
rank(int[], int, int) - +Static method in class papaya.Rank +
Rank an array containing NaN values using the natural ordering on Floats, with + NaN values handled according to nanStrategy and ties + resolved using tiesStrategy. +
rank(float[], int, int) - +Static method in class papaya.Rank +
Rank an array containing NaN values using the natural ordering on Floats, with + NaN values handled according to nanStrategy and ties + resolved using tiesStrategy. +
rank(int[], int) - +Static method in class papaya.Rank +
Rank an array (with no NaNs) using the natural ordering on Floats with ties + resolved using tiesStrategy. +
rank(float[], int) - +Static method in class papaya.Rank +
Rank an array (with no NaNs) using the natural ordering on Floats with ties + resolved using tiesStrategy. +
rank() - +Method in class papaya.SVD +
Effective numerical matrix rank +
rankInterpolated(float[], float) - +Static method in class papaya.Descriptive +
Returns the linearly interpolated number of elements in an array that + are ≤ a given element. +
replace(float[][], float, float) - +Static method in class papaya.Mat +
Returns a new matrix B equal to A, except that all elements in A which are equal to oldValue with + the newValue. +
replace(float[], float, float) - +Static method in class papaya.Mat +
Returns a new array data2 which is similar to data, except that all elements in data + which are equal to oldValue are replaced with + the newValue. +
replaceNewWith(double[], double) - +Static method in class papaya.NaNs +
Returns a new array with NaN elements in the original data set replaced with the value + specified by newNaN. +
replaceNewWith(float[], float) - +Static method in class papaya.NaNs +
Returns a new array with NaN elements in the original data set replaced with the value + specified by newNaN. +
replaceOriginalWith(double[], double) - +Static method in class papaya.NaNs +
Modifies the original data array by replacing the NaN elements in the data set with the value + specified by newNaN. +
replaceOriginalWith(float[], float) - +Static method in class papaya.NaNs +
Modifies the original data array by replacing the NaN elements in the data set with the value + specified by newNaN. +
reshape(float[][], int, int) - +Static method in class papaya.Mat +
Reshapes a matrix into the new specified dimensions. +
residual(float[], int) - +Static method in class papaya.Linear.StdErr +
Returns the standard error of the residuals given the degrees of freedom. +
residuals(float[], float[], float, float) - +Static method in class papaya.Linear +
Compute and return the array of residuals given by + Delta_i = z_i - y_i, + where + z_i = (slope*x_i + intercept) is the best fit linear line. +
residuals(float[], float[]) - +Static method in class papaya.Linear +
Compute and return the array of residuals given by + Delta_i = z_i - y_i, + where + z_i = (slope*x_i + intercept) is the best fit linear line. +
reverse(double[]) - +Static method in class papaya.Mat +
reverses the order of the elements in an array. +
reverse(float[]) - +Static method in class papaya.Mat +
reverses the order of the elements in an array. +
reverse(int[]) - +Static method in class papaya.Mat +
reverses the order of the elements in an array. +
RIGHT - +Static variable in interface papaya.PapayaConstants +
  +
rightBound - +Variable in class papaya.BoxPlot +
Specifies the space on the right betweent the plot area, and the + bounding rectangle. +
rightBound - +Variable in class papaya.ScatterPlot +
Specifies the space on the right betweent the plot area, and the + bounding rectangle. +
rightBound - +Variable in class papaya.SubPlot +
Specifies the space on the right betweent the plot area, and the + bounding rectangle. +
rms(int, double) - +Static method in class papaya.Descriptive +
Returns the RMS (Root-Mean-Square) of a data sequence. +
rms(float, float) - +Static method in class papaya.Descriptive.Weighted +
Returns the weighted RMS (Root-Mean-Square) of a data sequence. +
roundToDecimalPlace(float, int) - +Static method in class papaya.Mat +
Function for rounding to a given decimal place. +
rowMean(float[][]) - +Static method in class papaya.Descriptive.Mean +
Returns an array containing the arithmetic mean of each row of the input matrix. +
+
+

+S

+
+
s - +Variable in class papaya.SubPlot +
  +
ScatterPlot - Class in papaya
A simple class to plot x vs y data as a + scatter plot.
ScatterPlot(PApplet, float, float, float, float) - +Constructor for class papaya.ScatterPlot +
  +
setBackgroundColor(int) - +Method in class papaya.Visuals +
  +
setData(float[][], float, float) - +Method in class papaya.BoxPlot +
Sets the data to be plotted. +
setDataExtremes(float, float, float, float) - +Method in class papaya.ScatterPlot +
Set the minimum/maximum values on the x and y axis to nice numbers. +
setDataExtremes(float, float, float, float, int, int) - +Method in class papaya.SubPlot +
Sets the data extremes for subplot(xnum,ynum) by calling ScatterPlot.setDataExtremes(float, float, float, float) +
setHeight(float) - +Method in class papaya.Visuals +
  +
setLeft(float) - +Method in class papaya.Visuals +
  +
setToFloat(Set<Float>) - +Static method in class papaya.Cast +
Function for casting a Set to float[] +
setToInt(Set<Integer>) - +Static method in class papaya.Cast +
Function for casting a Set to float[] +
setTop(float) - +Method in class papaya.Visuals +
  +
setToString(Set<String>) - +Static method in class papaya.Cast +
Function for casting a Set to String array. +
setupFont(String, int, int, int) - +Method in class papaya.Visuals +
function for setting the font up for writing the labels +
setupFont(String, int, int, int, int) - +Method in class papaya.Visuals +
overload setupFont function that takes in font color +
setWidth(float) - +Method in class papaya.Visuals +
  +
seuclidean(float[][]) - +Static method in class papaya.Distance +
Computes the standardized Euclidean distance between pairs of objects + in the m-by-n data matrix X by standardizing X first prior to computing + the distances. +
signTest(float[], float[]) - +Static method in class papaya.Comparison +
Performs the sign test on an input array and returns the test statistic used to + test the hypothesis that there is "no difference in medians" + between the continuous distributions of two random variables X and Y. +
skew(float, float) - +Static method in class papaya.Descriptive +
Returns the skew of a data sequence when the 3rd moment has already been computed. +
skew(float[], float, float) - +Static method in class papaya.Descriptive +
Returns the skew of a data sequence, which is moment(data,3,mean) / standardDeviation3. +
skew(float[]) - +Static method in class papaya.Normality.Dago +
Computes and returns an array containing the test statistic zb1associated with sqrt(b1) and + the significance, or "p-value" of the skew test statistic zb1, assuming a + two-tailed null hypothesis as well as . +
skewSymmetric(float[][]) - +Static method in class papaya.Mat +
Returns the skew symmetric part of the input matrix ((A-A')/2). +
slope(float, float, int) - +Static method in class papaya.Linear.Significance +
Returns the p-value, or significance, of the computed slope under the null-hypothesis + of slope = 0 (two-tailed test). +
slope(float[], float) - +Static method in class papaya.Linear.StdErr +
Returns the standard error of the computed slope given x and the + standard error in the residuals. +
solve(float[], boolean) - +Method in class papaya.LU +
Solve A*x = b for x +
solve(float[][]) - +Method in class papaya.LU +
Solve A*X = B +
solve(float[]) - +Method in class papaya.QR +
Least squares solution of A*X = b +
solve(float[][]) - +Method in class papaya.QR +
Least squares solution of A*X = B +
Sorting - Class in papaya
Class for getting the array of indices that can be used to sort the array in ascending or + descending order.
spearman(float, int) - +Static method in class papaya.Correlation.Significance +
Returns the p-value, or significance level of the Spearman rank-correlation rho + between two datasets under the null hypothesis of no correlation. +
spearman(float[][], boolean) - +Static method in class papaya.Correlation +
Computes Spearman's rank-correlation, or rho, between multiple columns of a matrix + with each column corresponding to a dataset, and each row an observation. +
spearman(float[], float[], boolean) - +Static method in class papaya.Correlation +
Computes Spearman's rank-correlation, or rho. +
spearman(float[][]) - +Static method in class papaya.Distance +
Computes the Spearman distance matrix of the m-by-n input matrix X. +
split(float[], float[]) - +Static method in class papaya.Mat +
Splits (partitions) an array into sublists such that each sublist contains the elements with a given range. +
SQRTH - +Static variable in interface papaya.PapayaConstants +
  +
SQTPI - +Static variable in interface papaya.PapayaConstants +
  +
squaredDeviations(int, float) - +Static method in class papaya.Descriptive.Sum +
Returns the sum of squared mean deviation of of a data sequence. +
squares(float[]) - +Static method in class papaya.Descriptive.Sum +
Returns the sum of squares of a data sequence. +
ssbg() - +Method in class papaya.OneWayAnova +
Returns the sum of squared deviates between each group. +
sswg() - +Method in class papaya.OneWayAnova +
Returns the sum of squared deviates of the data within each group. +
std(float[], boolean) - +Static method in class papaya.Descriptive +
Returns the standard deviation of a dataset. +
std(float[][], boolean) - +Static method in class papaya.Descriptive +
Returns an array with each element of the array corresponding to + the standard deviations of each column of the input + matrix. +
stdUnbiased(int, float) - +Static method in class papaya.Descriptive +
Returns the unbiased sample standard deviation assuming the sample is normally distributed. +
STROKEWEIGHT - +Static variable in interface papaya.PapayaConstants +
  +
subMatrix(float[][], int, int, int, int) - +Static method in class papaya.Mat +
Get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +
subMatrix(float[][], int[], int, int) - +Static method in class papaya.Mat +
Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +
subMatrix(float[][], int, int, int[]) - +Static method in class papaya.Mat +
Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +
subMatrix(float[][], int[], int[]) - +Static method in class papaya.Mat +
Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +
subMatrix(int[][], int[], int[]) - +Static method in class papaya.Mat +
  +
SubPlot - Class in papaya
Convenient class for drawing multiple scatter plots.
SubPlot(PApplet, float, float, float, float, int, int) - +Constructor for class papaya.SubPlot +
Creates numX*numY plots, each of with xWidth, and height yHeight. +
subtract(float[], float[]) - +Static method in class papaya.Mat +
Returns the array z = x-y where each element of z[i] = x[i] - y[i] +
subtract(float[][], float[][]) - +Static method in class papaya.Mat +
Returns the matrix z = x-y where each element of z[i][j] = x[i][j] - y[i][j] +
sum(float[]) - +Static method in class papaya.Descriptive.Sum +
Returns the simple sum of a data sequence. +
sum(float[]) - +Static method in class papaya.Mat +
Returns the sum of a data sequence. +
sum(float[], float[]) - +Static method in class papaya.Mat +
Returns the sum of two data sequences. +
sum(float[], float) - +Static method in class papaya.Mat +
Sum of an array with a number. +
sum(int[]) - +Static method in class papaya.Mat +
Returns the sum of a data sequence. +
sum(int[], int[]) - +Static method in class papaya.Mat +
Returns the sum of two data sequences. +
sum(int[], int) - +Static method in class papaya.Mat +
Sum of an array with a number. +
sum(float[][], float[][]) - +Static method in class papaya.Mat +
Returns the matrix z = x+y where each element of z[i][j] = x[i][j] + y[i][j] +
SVD - Class in papaya
Singular Value Decomposition.
SVD(float[][]) - +Constructor for class papaya.SVD +
Construct the singular value decomposition. +
swap(float[], int, int) - +Static method in class papaya.Mat +
Swap function that swaps the values in an array +
swap(int[], int, int) - +Static method in class papaya.Mat +
Swap function that swaps the values in an array (overload function) +
symmetric(float[][]) - +Static method in class papaya.Mat +
Returns the symmetric part of the input matrix ((A+A')/2). +
+
+

+T

+
+
tcdf(double, double) - +Static method in class papaya.Probability +
Returns the integral from minus infinity to t of the Student-t + distribution with k > 0 degrees of freedom. +
TEXTSIZE - +Static variable in interface papaya.PapayaConstants +
  +
tinv(double, double) - +Static method in class papaya.Probability +
Returns the value, t, for which the area under the + Student-t probability density function (integrated from + minus infinity to t) is equal to p. +
TOP - +Static variable in interface papaya.PapayaConstants +
  +
topBound - +Variable in class papaya.BoxPlot +
Specifies the space on the top, between the plot area and the bounding + rectangle. +
topBound - +Variable in class papaya.ScatterPlot +
Specifies the space on the top, between the plot area and the bounding + rectangle. +
topBound - +Variable in class papaya.SubPlot +
Specifies the space on the top, between the plot area and the bounding + rectangle. +
trace(float[][]) - +Static method in class papaya.Mat +
Returns the matrix trace or sum of the diagonal elements. +
transform(float[], float) - +Static method in class papaya.Linear.BoxCox +
Performs the box-cox transformation, returning the transformed data. +
transpose(float[][]) - +Static method in class papaya.Mat +
Returns the transpose of the input matrix. +
transpose(int[][]) - +Static method in class papaya.Mat +
  +
trimmed(float[], float, int, int) - +Static method in class papaya.Descriptive.Mean +
Returns the trimmed arithmetic mean of a sorted data sequence. +
tukeyFiveNum(float[]) - +Static method in class papaya.Descriptive +
Return the tukey five number summary of a dataset consisting of the minimum, maximum, + and three quartile values. +
twoArrays(float[], float[], int, int, boolean) - +Static method in class papaya.Sorting +
Sorts the input x and y arrays according to + x and going from fromIndex(inclusive) to toIndex(exclusive) + in ascending or descending order. +
twoArrays(double[], double[], int, int, boolean) - +Static method in class papaya.Sorting +
  +
twoArrays(int[], int[], int, int, boolean) - +Static method in class papaya.Sorting +
  +
+
+

+U

+
+
unequalVar(float[], float[]) - +Static method in class papaya.Comparison.TTest +
Returns the t-statistic and p-value for checking whether the means + between the two datasets are different under the assumption that both + datasets have unequal variances. +
Unique - Class in papaya
Class for getting and storing an unsorted array's unique elements, + the indices of these elements, and the number of times the elements occur.
Unique(float[], boolean) - +Constructor for class papaya.Unique +
Class for storing the unique values in an unsorted data array. +
uniqueElems(int[]) - +Static method in class papaya.Find +
Find the unique elements in a int array (uses HashSets) +
uniqueElems(float[]) - +Static method in class papaya.Find +
Find the unique elements in a float array (uses HashSets) +
+
+

+V

+
+
values - +Variable in class papaya.Unique +
ArrayList containing the unique values +
var(float, int, float, int, boolean) - +Static method in class papaya.Descriptive.Pooled +
Returns the pooled variance of two data sequences. +
var(float[], int[], boolean) - +Static method in class papaya.Descriptive.Pooled +
Returns the pooled variance of k data sequences. +
var(float[], boolean) - +Static method in class papaya.Descriptive +
Returns the variance of a dataset, V. +
var(float[][], boolean) - +Static method in class papaya.Descriptive +
Returns an array containing the variance of each column of the input matrix X. +
var(float[], float[], boolean) - +Static method in class papaya.Descriptive.Weighted +
Returns the weighted variance of a data sequence of length N + There are (unfortunately) many different definitions of the unbiased weighted variance. +
vectorToFloat(Vector<Float>) - +Static method in class papaya.Cast +
function for casting Vector to float[] +
vectorToInt(Vector<Integer>) - +Static method in class papaya.Cast +
function for casting Vector to int[] +
vertLine(float, float, float, int, float) - +Method in class papaya.Visuals +
draws a vertical line with color _sColor, and weight _sWeight +
Visuals - Class in papaya
Visuals is the parent class behind most of the other plotting classes.
Visuals(PApplet, float, float, float, float) - +Constructor for class papaya.Visuals +
The parent class behind the other plotting classes. +
+
+

+W

+
+
winsorized(float[], float, int, int) - +Static method in class papaya.Descriptive.Mean +
Returns the winsorized mean of a sorted data sequence. +
within(float, float, float) - +Static method in class papaya.Mat +
Checks to see if a number is in the range specified by [min,max]. +
within(float[], float, float) - +Static method in class papaya.Mat +
returns an array containing all numbers within the min and max (inclusive). +
writeLabels(PFont, String[], float[], float[]) - +Method in class papaya.Visuals +
  +
writeLabels(PFont, String, float, float) - +Method in class papaya.Visuals +
  +
writeLabels(PFont, float, float, float) - +Method in class papaya.Visuals +
  +
writeLabels(float, float, float) - +Method in class papaya.Visuals +
  +
writeLabels(String, float, float) - +Method in class papaya.Visuals +
  +
writeTitle(PFont, String, int, int) - +Method in class papaya.SubPlot +
Writes the title for subplot(xnum,ynum). +
writeTitle(String, int, int) - +Method in class papaya.SubPlot +
Writes the title for subplot(xnum,ynum). +
writeTitle(String, PFont) - +Method in class papaya.Visuals +
titles the plot given the String _title and the PFont +
+
+

+X

+
+
xLabels(int, int, int) - +Method in class papaya.SubPlot +
Writes the x labels for subplot(xnum,ynum). +
xLabels(float, float, float, float, int) - +Method in class papaya.Visuals +
Write the x-axis labels. +
xLabels(float, float, String[]) - +Method in class papaya.Visuals +
Write the x-axis labels. +
xLefts - +Variable in class papaya.SubPlot +
  +
xSpacing - +Variable in class papaya.SubPlot +
  +
xTicks(float, float, int, int) - +Method in class papaya.Visuals +
Draws the x-axis tickmarks. +
xW - +Variable in class papaya.SubPlot +
  +
XYLabels - +Variable in class papaya.ScatterPlot +
  +
XYTicks - +Variable in class papaya.ScatterPlot +
  +
+
+

+Y

+
+
yH - +Variable in class papaya.SubPlot +
  +
yLabels(int, int, int) - +Method in class papaya.SubPlot +
Writes the y labels for subplot(xnum,ynum). +
yLabels(float, float, float, float, int) - +Method in class papaya.Visuals +
Write the y-axis labels. +
yLabels(float, float, String[]) - +Method in class papaya.Visuals +
Write the y-axis labels. +
YLines(int) - +Method in class papaya.Visuals +
Draws horizontal y-lines on the plot +
ySpacing - +Variable in class papaya.SubPlot +
  +
yTicks(float, float, int, int) - +Method in class papaya.Visuals +
Draws the y-axis tickmarks. +
yTops - +Variable in class papaya.SubPlot +
  +
+
+

+Z

+
+
zScore(float, float, float) - +Static method in class papaya.Descriptive +
  +
zScore(float[], float, float) - +Static method in class papaya.Descriptive +
Returns the array of z-scores for a given data array. +
zScore(float[][], float[], float[]) - +Static method in class papaya.Descriptive +
Computes the standardized version of the input matrix. +
+
+A B C D E F G H I K L M N O P Q R S T U V W X Y Z + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/index.html b/drawing/papaya/reference/index.html new file mode 100644 index 0000000..c231207 --- /dev/null +++ b/drawing/papaya/reference/index.html @@ -0,0 +1,70 @@ + + + + + + +Javadocs: papaya + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="papaya/package-summary.html">Non-frame version.</A> + + + diff --git a/drawing/papaya/reference/overview-tree.html b/drawing/papaya/reference/overview-tree.html new file mode 100644 index 0000000..5ffd83c --- /dev/null +++ b/drawing/papaya/reference/overview-tree.html @@ -0,0 +1,168 @@ + + + + + + +Class Hierarchy (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
papaya
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/package-list b/drawing/papaya/reference/package-list new file mode 100644 index 0000000..cc8ed38 --- /dev/null +++ b/drawing/papaya/reference/package-list @@ -0,0 +1 @@ +papaya diff --git a/drawing/papaya/reference/papaya/BoxPlot.html b/drawing/papaya/reference/papaya/BoxPlot.html new file mode 100644 index 0000000..a49302b --- /dev/null +++ b/drawing/papaya/reference/papaya/BoxPlot.html @@ -0,0 +1,498 @@ + + + + + + +BoxPlot (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class BoxPlot

+
+java.lang.Object
+  extended by papaya.Visuals
+      extended by papaya.BoxPlot
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class BoxPlot
extends Visuals
+ + +

+BoxPlot class +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+ floatbottomBound + +
+          Specifies the space on the bottom, between the plot area and the bounding + rectangle.
+ booleandrawAxes + +
+          Specifies whether to draw the axes
+ booleandrawRectangle + +
+          Specifies whether to draw the bounding rectangle around the plot.
+ floatleftBound + +
+          Specifies the space on the left between the plot area, and the + bounding rectangle.
+ floatrightBound + +
+          Specifies the space on the right betweent the plot area, and the + bounding rectangle.
+ floattopBound + +
+          Specifies the space on the top, between the plot area and the bounding + rectangle.
+ + + + + + + +
Fields inherited from class papaya.Visuals
bgColor
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
BoxPlot(PApplet _theParent, + float _plotLeft, + float _plotTop, + float _plotWidth, + float _plotHeight) + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiddrawBoxPlot(String[] _labels, + float _sWeight, + int _fColor) + +
+          Plot the box plots.
+ float[][]getData() + +
+           
+ voidsetData(float[][] _fiveNumArr, + float _minVal, + float _maxVal) + +
+          Sets the data to be plotted.
+ + + + + + + +
Methods inherited from class papaya.Visuals
drawAxes, drawRect, drawRect, getBottom, getHeight, getLeft, getRight, getTop, getWidth, horizLine, legendHoriz, legendVert, line, mapXData, mapXData, mapYData, mapYData, setBackgroundColor, setHeight, setLeft, setTop, setupFont, setupFont, setWidth, vertLine, writeLabels, writeLabels, writeLabels, writeLabels, writeLabels, writeTitle, xLabels, xLabels, xTicks, yLabels, yLabels, YLines, yTicks
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+drawRectangle

+
+public boolean drawRectangle
+
+
Specifies whether to draw the bounding rectangle around the plot. +

+

+
+
+
+ +

+drawAxes

+
+public boolean drawAxes
+
+
Specifies whether to draw the axes +

+

+
+
+
+ +

+leftBound

+
+public float leftBound
+
+
Specifies the space on the left between the plot area, and the + bounding rectangle. That is, the left-most point of + the rectangle is given by plotLeft-leftBound. +

+

+
+
+
+ +

+rightBound

+
+public float rightBound
+
+
Specifies the space on the right betweent the plot area, and the + bounding rectangle. That is, the right-most point of + the rectangle is given by plotLeft+plotWidth+rightBound. +

+

+
+
+
+ +

+topBound

+
+public float topBound
+
+
Specifies the space on the top, between the plot area and the bounding + rectangle. That is, the top-most point of the rectangle is given by + plotTop - topBound. +

+

+
+
+
+ +

+bottomBound

+
+public float bottomBound
+
+
Specifies the space on the bottom, between the plot area and the bounding + rectangle. That is, the bottom-most point of the rectangle is given by + plotTop + plotHeight + bottomBound. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+BoxPlot

+
+public BoxPlot(PApplet _theParent,
+               float _plotLeft,
+               float _plotTop,
+               float _plotWidth,
+               float _plotHeight)
+
+
+ + + + + + + + +
+Method Detail
+ +

+setData

+
+public void setData(float[][] _fiveNumArr,
+                    float _minVal,
+                    float _maxVal)
+
+
Sets the data to be plotted. +

+

+
Parameters:
_fiveNumArr - array of five number box plot summaries + with each row corresponding to a given data set. See Descriptive.tukeyFiveNum(float[]) for more info.
_minVal - the minimum value to show in the plot
_maxVal - the maximum value to show in the plot
+
+
+
+ +

+getData

+
+public float[][] getData()
+
+
+ +
Returns:
the tukey five number array
+
+
+
+ +

+drawBoxPlot

+
+public void drawBoxPlot(String[] _labels,
+                        float _sWeight,
+                        int _fColor)
+
+
Plot the box plots. +

+

+
Parameters:
_labels - labels for the box plot
_sWeight - the stroke weight to use for the lines.
_fColor - the fill color for the boxplots
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Cast.html b/drawing/papaya/reference/papaya/Cast.html new file mode 100644 index 0000000..1eca94c --- /dev/null +++ b/drawing/papaya/reference/papaya/Cast.html @@ -0,0 +1,576 @@ + + + + + + +Cast (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Cast

+
+java.lang.Object
+  extended by papaya.Cast
+
+
+
+
public final class Cast
extends Object
+ + +

+Static Class for casting Object arrays to their corresponding primitive type. + Similar to the toArray(T[] a) method specified in the java Collections + interface, but for float[] and int[] arrays (as opposed to Float[] and Integer[]). +

+ +

+

+ +

+

+
Author:
+
Nur Adila Faruk Senan
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[]arrayListToFloat(ArrayList<Float> _inputDat) + +
+          function for casting ArrayList to float[]
+static int[]arrayListToInt(ArrayList<Integer> _inputDat) + +
+          function for casting ArrayList to int[]
+static float[]doubleToFloat(double[] _inputDat) + +
+          function for casting double[] to float[]
+static float[][]doubleToFloat(double[][] _inputDat) + +
+          function for casting double[][] to float[][]
+static double[]floatToDouble(float[] _inputDat) + +
+          function for casting float[] to double[]
+static double[][]floatToDouble(float[][] _inputDat) + +
+          function for casting float[][] to double[][]
+static PVector[]floatToPVector(float[] x, + float[] y) + +
+          Returns a PVector array with the x, and coordinates set to the input values, and the z coordinates + set to zero.
+static PVector[]floatToPVector(float[] x, + float[] y, + float[] z) + +
+          Returns a PVector array with the x, y, and z coordinates set to the input values + (technically not a cast, but a reorganization).
+static float[]keySetToFloat(HashMap _hMap) + +
+          Function for casting hashMap keySet to float[]
+static int[]keySetToInt(HashMap _hMap) + +
+          Function for casting hashMap keySet to float[]
+static String[]keySetToString(HashMap _hMap) + +
+          Function for casting hashMap keySet to String[]
+static float[]setToFloat(Set<Float> theSet) + +
+          Function for casting a Set to float[]
+static int[]setToInt(Set<Integer> theSet) + +
+          Function for casting a Set to float[]
+static String[]setToString(Set<String> theSet) + +
+          Function for casting a Set to String array.
+static float[]vectorToFloat(Vector<Float> _inputDat) + +
+          function for casting Vector to float[]
+static int[]vectorToInt(Vector<Integer> _inputDat) + +
+          function for casting Vector to int[]
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+arrayListToInt

+
+public static int[] arrayListToInt(ArrayList<Integer> _inputDat)
+
+
function for casting ArrayList to int[] +

+

+
Parameters:
_inputDat - ArrayList array that needs to be cast to int[] +
Returns:
the resulting int[] array
+
+
+
+ +

+arrayListToFloat

+
+public static float[] arrayListToFloat(ArrayList<Float> _inputDat)
+
+
function for casting ArrayList to float[] +

+

+
Parameters:
_inputDat - ArrayList array that needs to be cast to float[] +
Returns:
the resulting float[] array
+
+
+
+ +

+floatToDouble

+
+public static double[][] floatToDouble(float[][] _inputDat)
+
+
function for casting float[][] to double[][] +

+

+
Parameters:
_inputDat - float[][] 2d array +
Returns:
deep copy of _inputDat with each element cast to a double
+
+
+
+ +

+floatToDouble

+
+public static double[] floatToDouble(float[] _inputDat)
+
+
function for casting float[] to double[] +

+

+
Parameters:
_inputDat - float[] array +
Returns:
deep copy of _inputDat with each element cast to a double
+
+
+
+ +

+doubleToFloat

+
+public static float[][] doubleToFloat(double[][] _inputDat)
+
+
function for casting double[][] to float[][] +

+

+
Parameters:
_inputDat - double[][] 2d array +
Returns:
deep copy of _inputDat with each element cast to a float
+
+
+
+ +

+doubleToFloat

+
+public static float[] doubleToFloat(double[] _inputDat)
+
+
function for casting double[] to float[] +

+

+
Parameters:
_inputDat - double[] array +
Returns:
deep copy of _inputDat with each element cast to a float
+
+
+
+ +

+keySetToString

+
+public static String[] keySetToString(HashMap _hMap)
+
+
Function for casting hashMap keySet to String[] +

+

+
Parameters:
_hMap - input HashMap +
Returns:
Hashmap.keySet() cast to String[] + Use only for the case where the HashMap Keys are Strings
+
+
+
+ +

+keySetToInt

+
+public static int[] keySetToInt(HashMap _hMap)
+
+
Function for casting hashMap keySet to float[] +

+

+
Parameters:
_hMap - input HashMap +
Returns:
Hashmap.keySet() cast to float[] + Use only for the case where the HashMap Keys are floats
+
+
+
+ +

+keySetToFloat

+
+public static float[] keySetToFloat(HashMap _hMap)
+
+
Function for casting hashMap keySet to float[] +

+

+
Parameters:
_hMap - input HashMap +
Returns:
Hashmap.keySet() cast to float[] + Use only for the case where the HashMap Keys are floats
+
+
+
+ +

+setToInt

+
+public static int[] setToInt(Set<Integer> theSet)
+
+
Function for casting a Set to float[] +

+

+
+
+
+
+ +

+setToFloat

+
+public static float[] setToFloat(Set<Float> theSet)
+
+
Function for casting a Set to float[] +

+

+
+
+
+
+ +

+setToString

+
+public static String[] setToString(Set<String> theSet)
+
+
Function for casting a Set to String array. This is really just one line of code, but it's + much easier to have it as an external function rather than having to remember it +

+

+
+
+
+
+ +

+vectorToInt

+
+public static int[] vectorToInt(Vector<Integer> _inputDat)
+
+
function for casting Vector to int[] +

+

+
Parameters:
_inputDat - Vector array that needs to be cast to int[] +
Returns:
the resulting int[] array
+
+
+
+ +

+vectorToFloat

+
+public static float[] vectorToFloat(Vector<Float> _inputDat)
+
+
function for casting Vector to float[] +

+

+
Parameters:
_inputDat - Vector array that needs to be cast to float[] +
Returns:
the resulting float[] array
+
+
+
+ +

+floatToPVector

+
+public static PVector[] floatToPVector(float[] x,
+                                       float[] y,
+                                       float[] z)
+
+
Returns a PVector array with the x, y, and z coordinates set to the input values + (technically not a cast, but a reorganization). +

+

+
+
+
+
+ +

+floatToPVector

+
+public static PVector[] floatToPVector(float[] x,
+                                       float[] y)
+
+
Returns a PVector array with the x, and coordinates set to the input values, and the z coordinates + set to zero. + (technically not a cast, but a reorganization). +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Comparison.TTest.html b/drawing/papaya/reference/papaya/Comparison.TTest.html new file mode 100644 index 0000000..06849d9 --- /dev/null +++ b/drawing/papaya/reference/papaya/Comparison.TTest.html @@ -0,0 +1,318 @@ + + + + + + +Comparison.TTest (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Comparison.TTest

+
+java.lang.Object
+  extended by papaya.Comparison.TTest
+
+
+
Enclosing class:
Comparison
+
+
+
+
public static class Comparison.TTest
extends Object
+ + +

+Methods related to comparing two populations. Each method returns an array with the + first element containing the t-statistic, and the second corresponding to the + p-value, or significance, of rejecting the null hypothesis. +

+ Tests can be:

    +
  • One-sample or two-sample
  • +
  • One-sided or two-sided
  • +
  • Paired or unpaired (for two-sample tests)
  • +
  • Homoscedastic (equal variance assumption) or heteroscedastic + (for two sample tests)
  • +
  • Fixed significance level (boolean-valued) or returning p-values. +

+

+ Test statistics are available for all tests. Methods including "Test" in + in their names perform tests, all other methods return t-statistics. Among + the "Test" methods, double-valued methods return p-values; + boolean-valued methods perform fixed significance level tests. + Significance levels are always specified as numbers between 0 and 0.5 + (e.g. tests at the 95% level use alpha=0.05).

+

+ + Note: Inspired by the + stats.inference.TTest class available in the Apache Commons math library. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[]equalVar(float[] data1, + float[] data2) + +
+          Returns the t-statistic and p-value for checking whether the means + between the two datasets are different under the assumption that both + datasets have equal variances.
+static float[]paired(float[] before, + float[] after) + +
+          Returns the t-statistic and p-value for checking a pair of dependent samples.
+static float[]unequalVar(float[] data1, + float[] data2) + +
+          Returns the t-statistic and p-value for checking whether the means + between the two datasets are different under the assumption that both + datasets have unequal variances.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+equalVar

+
+public static float[] equalVar(float[] data1,
+                               float[] data2)
+
+
Returns the t-statistic and p-value for checking whether the means + between the two datasets are different under the assumption that both + datasets have equal variances. The p-value corresponds to the + null hypothesis of no-difference (i.e. two-tailed). +

+

+ +
Returns:
an array with the first element = t and the second element = p.
+
+
+
+ +

+unequalVar

+
+public static float[] unequalVar(float[] data1,
+                                 float[] data2)
+
+
Returns the t-statistic and p-value for checking whether the means + between the two datasets are different under the assumption that both + datasets have unequal variances. The p-value corresponds to the + null hypothesis of no-difference (i.e. two-tailed). + This is also known as Welch's t-test. +

+

+ +
Returns:
an array with the first element = t and the second element = p.
+
+
+
+ +

+paired

+
+public static float[] paired(float[] before,
+                             float[] after)
+
+
Returns the t-statistic and p-value for checking a pair of dependent samples. + That is, when there is only one sample that has been tested twice + (repeated measures) or when there are two samples that have been + matched or "paired". The p-value corresponds to the + null hypothesis of no-difference in both measurements (i.e. two-tailed). +

Both datasets have to have equal lengths. +

+

+
Parameters:
before - the dataset before treatment/measurement.
after - the dataset after treatment/measurement. +
Returns:
an array with the first element = t and the second element = p.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Comparison.html b/drawing/papaya/reference/papaya/Comparison.html new file mode 100644 index 0000000..19e56e6 --- /dev/null +++ b/drawing/papaya/reference/papaya/Comparison.html @@ -0,0 +1,374 @@ + + + + + + +Comparison (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Comparison

+
+java.lang.Object
+  extended by papaya.Comparison
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class Comparison
extends Object
implements PapayaConstants
+ + +

+Contains a number of methods for comparing more than one dataset + against each other. Rank-based methods and are powerful in the sense that they do not rely + on the data assuming a normal distribution. +

+ +

+


+ +

+ + + + + + + + + + + +
+Nested Class Summary
+static classComparison.TTest + +
+          Methods related to comparing two populations.
+ + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
Comparison() + +
+          Makes this class non instantiable, but still let's others inherit from it.
+  + + + + + + + + + + + + + + + +
+Method Summary
+static float[]mannWhitney(float[] data1, + float[] data2) + +
+          Computes and returns the MannWhitney (or Wilcoxon Rank Sum) test statistic, U and p-value for + assessing whether one of two samples of independent observations tends to have + larger values than the other.
+static floatsignTest(float[] x, + float[] y) + +
+          Performs the sign test on an input array and returns the test statistic used to + test the hypothesis that there is "no difference in medians" + between the continuous distributions of two random variables X and Y.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Comparison

+
+public Comparison()
+
+
Makes this class non instantiable, but still let's others inherit from it. +

+

+ + + + + + + + +
+Method Detail
+ +

+mannWhitney

+
+public static float[] mannWhitney(float[] data1,
+                                  float[] data2)
+
+
Computes and returns the MannWhitney (or Wilcoxon Rank Sum) test statistic, U and p-value for + assessing whether one of two samples of independent observations tends to have + larger values than the other. That is, +
U = min(U1,U2)
+ where +
+ U1 = Sum(Ranks1)  - n1*(n1+1)/2,   
+ U2 = Sum(Ranks2) - n2*(n2+1)/2.
+ 
+ and the significance, or p-value is computed assuming + a two-tailed null-hypothesis that both samples are similar. +

+

+
+
+
+
Parameters:
data1 - the first dataset
data2 - the second dataset +
Returns:
a 2 element array with first element corresponding to the test statistic, and second + equal to the p-value or significance. +
Throws: +
IllegalArgumentException - if either of the sample sizes is less than 8 (the normal approximation + is no longer valid in that case. Best to consult a table instead).
+
+
+
+ +

+signTest

+
+public static float signTest(float[] x,
+                             float[] y)
+
+
Performs the sign test on an input array and returns the test statistic used to + test the hypothesis that there is "no difference in medians" + between the continuous distributions of two random variables X and Y. It is used in + the situation when we can draw paired samples from X and Y and is a convenient method + as it makes very few assumptions about the nature of the distributions under test. +

+

To elaborate, the null hypothesis H0 states that given a random pair of measurements (X[i], Y[i]), + X[i] and Y[i] are equally likely to be larger than the other. + Now, let n be the number of pairs for which Y[i] ≠ X[i] and w + be the number of pairs for which Y[i] - X[i] > 0. + Assuming that H0 is true, then W follows a binomial distribution W ~ b(n, 0.5). + + This method returns the sum of the terms 0 through w of the Binomial + probability density. +

 
+ Sum_(j=0 to w)  [ (n!)/(j!*(n-j)! ]  *  [ p^j * (1-p)^(n-j) ]
+ from 0 to the test-statistic, or
+ 

+ p = Probability.binomcdf(.5,w,n). +

+ For n > 100, the normal distribution cdf is returned instead. + If this is less than the critical value, then we can reject the null hypothesis that there + is no difference between the samples X and Y. +

+

+
+
+
+
Parameters:
x - data set containing 1st observation sequence
y - data set containing 2nd observation sequence +
Returns:
the significance, or p-value, assuming a two-tailed null hypothesis (i.e. no difference)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Correlation.Significance.html b/drawing/papaya/reference/papaya/Correlation.Significance.html new file mode 100644 index 0000000..41d6f38 --- /dev/null +++ b/drawing/papaya/reference/papaya/Correlation.Significance.html @@ -0,0 +1,309 @@ + + + + + + +Correlation.Significance (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Correlation.Significance

+
+java.lang.Object
+  extended by papaya.Correlation.Significance
+
+
+
Enclosing class:
Correlation
+
+
+
+
public static class Correlation.Significance
extends Object
+ + +

+Contains methods used to compute the significance, or pvalue of the input correlations. + The significance is computed using the normal of student-t approximations and hence are + not to be used for small datasets(i.e. size<20). +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatdurbinWatson(float[] data) + +
+          The Durbin-Watson statistic is a test statistic used to detect the presence + of autocorrelation (Correlation.auto(float[], int, float, float)) + in the residuals (prediction errors) from a regression analysis.
+static floatlinear(float r, + int size) + +
+          Returns the p-value, or significance level of the linear correlation r + between two datasets under the null hypothesis of no correlation.
+static floatspearman(float rho, + int size) + +
+          Returns the p-value, or significance level of the Spearman rank-correlation rho + between two datasets under the null hypothesis of no correlation.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+durbinWatson

+
+public static float durbinWatson(float[] data)
+
+
The Durbin-Watson statistic is a test statistic used to detect the presence + of autocorrelation (Correlation.auto(float[], int, float, float)) + in the residuals (prediction errors) from a regression analysis. +

+ If e_t is the residual associated with the observation at time t, + and there are T observations, then the test statistic, d is +

+
+ d =   Sum_{from t=2 to T} ( e_t - e_{t-1} )^2    /   Sum_{from t=1 to T} ( e_t )^2
+ 
+

+

+ +
Returns:
d the Durbin Watson test statistic
+
+
+
+ +

+linear

+
+public static float linear(float r,
+                           int size)
+
+
Returns the p-value, or significance level of the linear correlation r + between two datasets under the null hypothesis of no correlation. + That is, H_0: ρ=0 (No linear correlation; Two-tailed test). The p-value is + computed by transforming the correlation to create a t-statistic + having n-2 degrees of freedom: +
 t = r * sqrt( (n-2)/(1-r^2) ),
+ where n is the size of the corresponding datasets. +

+

+
Parameters:
r - the linear correlation coefficient
size - the size of the corresponding datasets (i.e. number of rows/observations). +
Throws: +
IllegalArgumentException - if the size is less than 20. Below this, + the student-T approximation is inaccurate.
+
+
+
+ +

+spearman

+
+public static float spearman(float rho,
+                             int size)
+
+
Returns the p-value, or significance level of the Spearman rank-correlation rho + between two datasets under the null hypothesis of no correlation. + That is, H_0: ρ_0=0 (No linear correlation; Two-tailed test). + The p-value is computed by transforming the correlation to create a t-statistic + having n-2 degrees of freedom: +
 t = rho * sqrt( (n-2)/(1-rho^2) ),
+ where n is the size of the corresponding datasets. +

+

+
Parameters:
rho - the Spearman-correlation coefficient
size - the size of the corresponding datasets (i.e. number of rows/observations). +
Throws: +
IllegalArgumentException - if the size is less than 20. Below this, + the student-T approximation is inaccurate.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Correlation.Weighted.html b/drawing/papaya/reference/papaya/Correlation.Weighted.html new file mode 100644 index 0000000..f83d791 --- /dev/null +++ b/drawing/papaya/reference/papaya/Correlation.Weighted.html @@ -0,0 +1,335 @@ + + + + + + +Correlation.Weighted (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Correlation.Weighted

+
+java.lang.Object
+  extended by papaya.Correlation.Weighted
+
+
+
Enclosing class:
Correlation
+
+
+
+
public static class Correlation.Weighted
extends Object
+ + +

+Contains methods related to computing the correlation and covariance of weighted + datasets. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[][]corr(float[][] data, + float[] weights, + boolean unbiased) + +
+          Returns the weighted linear correlation matrix C.
+static floatcorr(float[] data1, + float[] data2, + float[] weights, + boolean unbiased) + +
+          Returns the weighted linear correlation of two data sequences.
+static float[][]cov(float[][] data, + float[] weights, + boolean unbiased) + +
+          Returns the weighted covariance matrix with element S_JK specifying the weighted + covariance between column J and column K of the input matrix.
+static floatcov(float[] data1, + float[] data2, + float[] weights, + boolean unbiased) + +
+          Returns the weighted covariance between two data sequences.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+corr

+
+public static float[][] corr(float[][] data,
+                             float[] weights,
+                             boolean unbiased)
+
+
Returns the weighted linear correlation matrix C. + If S is an estimate of the weighted covariance matrix, then element JK of the + weighted correlation matrix C is then given by +
+ C_JK = S_JK / sqrt(S_JJ,unbiasedValue)*sqrt(S_KK,unbiasedValue).
+ 
+ See Correlation.cov(float[][],boolean). +

+

+
Parameters:
data - input matrix each column corresponding to a sample, each row an observation.
weights - the weights to use.
unbiased - set to true to return the unbiased weighted correlation matrix, false to return the biased version.
+
+
+
+ +

+corr

+
+public static float corr(float[] data1,
+                         float[] data2,
+                         float[] weights,
+                         boolean unbiased)
+
+
Returns the weighted linear correlation of two data sequences. +

+

+
Parameters:
unbiased - set to true to return the unbiased weighted correlation, false to return the biased version.
+
+
+
+ +

+cov

+
+public static float cov(float[] data1,
+                        float[] data2,
+                        float[] weights,
+                        boolean unbiased)
+
+
Returns the weighted covariance between two data sequences. +

+

+
Parameters:
unbiased - set to true to return the unbiased weighted covariance, false to return the biased version.
+
+
+
+ +

+cov

+
+public static float[][] cov(float[][] data,
+                            float[] weights,
+                            boolean unbiased)
+
+
Returns the weighted covariance matrix with element S_JK specifying the weighted + covariance between column J and column K of the input matrix. +

+ The formula used to compute element S_JK of the unbiased covariance matrix is: +

+ S_JK = biasCorrection * Sum ( w[i] * ( dataJ[i] - mu_w(dataJ) )*( dataK[i] - mu_w(dataK) ) ) / Sum (w[i])
+ 
+ where mu_w corresponds to the weighted mean of the dataset + and the biasCorrection term above is +
+ biasCorrection = ( Sum(w[i]) )^2  / ( ( Sum(w[i]) )^2 - Sum( w[i]^2 )  ).
+ 
+ The elements of the biased covariance matrix are computed sans the bias Correction factor. +

+ Reference: + Covariance of weighted samples, wikipedia.org. +

+

+
Parameters:
data - input matrix each column corresponding to a sample, each row an observation.
weights - the weights to use.
unbiased - set to true to return the unbiased weighted covariance matrix, false to return the biased version.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Correlation.html b/drawing/papaya/reference/papaya/Correlation.html new file mode 100644 index 0000000..aea74a8 --- /dev/null +++ b/drawing/papaya/reference/papaya/Correlation.html @@ -0,0 +1,548 @@ + + + + + + +Correlation (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Correlation

+
+java.lang.Object
+  extended by papaya.Correlation
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public final class Correlation
extends Object
implements PapayaConstants
+ + +

+Contains utilities related to computing covariances, as well as linear and rank correlation. + Methods relating to computing +

    +
  • normal correlations and covariances (biased or unbiased) are in the main class. +
  • weighted correlation and covariances are in the Correlation.Weighted subclass. +
  • significance of the correlations (i.e. p-values) are in the Correlation.Significance subclass. +
+ Whatever it is, remember that correlation does not always imply causation. +

+ +

+


+ +

+ + + + + + + + + + + + + + + +
+Nested Class Summary
+static classCorrelation.Significance + +
+          Contains methods used to compute the significance, or pvalue of the input correlations.
+static classCorrelation.Weighted + +
+          Contains methods related to computing the correlation and covariance of weighted + datasets.
+ + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatauto(float[] data, + int lag, + float mean, + float variance) + +
+          Computes the sample autocorrelation by removing the sample mean from the input series, + then normalizing the sequence by the sample variance.
+static floatautoLag1(float[] data, + float mean) + +
+          Returns the lag-1 autocorrelation of a dataset; + Note that this method uses computations different from + auto(data, 1, mean, variance).
+static float[][]cov(float[][] data, + boolean unbiased) + +
+          Returns the covariance matrix of P data sequences, each of length N.
+static floatcov(float[] data1, + float[] data2, + boolean unbiased) + +
+          Returns the covariance of two data sequences data1 and data2, + each of length N.
+static float[][]linear(float[][] data, + boolean unbiased) + +
+          Returns the (Pearson Product Moment) correlation matrix between multiple columns of a matrix + with each column corresponding to a dataset, and each row an observation.
+static floatlinear(float[] data1, + float[] data2, + boolean unbiased) + +
+          Returns the (Pearson Product Moment) linear correlation of two data sequences.
+static float[][]spearman(float[][] data, + boolean unbiased) + +
+          Computes Spearman's rank-correlation, or rho, between multiple columns of a matrix + with each column corresponding to a dataset, and each row an observation.
+static floatspearman(float[] x, + float[] y, + boolean unbiased) + +
+          Computes Spearman's rank-correlation, or rho.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+auto

+
+public static float auto(float[] data,
+                         int lag,
+                         float mean,
+                         float variance)
+
+
Computes the sample autocorrelation by removing the sample mean from the input series, + then normalizing the sequence by the sample variance. That is, it returns +
+ R(lag) = E[ (X[t] - mu) * ( X[t+lag] - mu ) ] / variance(X).   
+ where 
+ E[ (X[t] - mu) * ( X[t+lag] - mu ) ]  = 1/size(X) * Sum_(i=0 to size-lag)( (X[t]-mu)*X[t+lag]-mu) ). 
+ 
+ Reference: Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. + Time Series Analysis: Forecasting and Control. 3rd ed. + Upper Saddle River, NJ: Prentice-Hall, 1994. +

+

+

+
+
+
+
Parameters:
data - the array of data
lag - the lag value. Has to be smaller than the data sequence length
mean - the data mean
variance - the data variance +
Returns:
the autocorrelation value
+
+
+
+ +

+autoLag1

+
+public static float autoLag1(float[] data,
+                             float mean)
+
+
Returns the lag-1 autocorrelation of a dataset; + Note that this method uses computations different from + auto(data, 1, mean, variance). +

+

+
+
+
+
+
+
+
+ +

+linear

+
+public static float[][] linear(float[][] data,
+                               boolean unbiased)
+
+
Returns the (Pearson Product Moment) correlation matrix between multiple columns of a matrix + with each column corresponding to a dataset, and each row an observation. + That is, given P columns, data1, data2, ... , dataP, + each of length n, it computes and returns the P-by-P correlation + matrix, C with each element CJK given by +
+ CJK = CKJ = corr(dataJ,dataK,unbiasedValue).
+ 
+

+

+
+
+
+
Parameters:
data - The input data. Each column corresponds to a dataset; + each row corresponds to an observation
unbiased - set to true to return the unbiased correlation, + false to return the biased version. +
Returns:
the correlation matrix (symmetric, by definition)
+
+
+
+ +

+linear

+
+public static float linear(float[] data1,
+                           float[] data2,
+                           boolean unbiased)
+
+
Returns the (Pearson Product Moment) linear correlation of two data sequences. + It is related to the cov(float[], float[], boolean) function via +
+ corr = cov(x,y,unbiasedValue)/sqrt( cov(x,x, unbiasedValue)*cov(y,y,unbiasedValue) )
+ 
+

+

+
+
+
+
Parameters:
unbiased - set to true to return the unbiased correlation, + false to return the biased version.
+
+
+
+ +

+spearman

+
+public static float[][] spearman(float[][] data,
+                                 boolean unbiased)
+
+
Computes Spearman's rank-correlation, or rho, between multiple columns of a matrix + with each column corresponding to a dataset, and each row an observation. + That is, each pair of columns are first converted to ranks rXJ, rXK + and the correlation between the ranks computed using the Pearson correlation coefficient + formula. +

+

+
+
+
+
Parameters:
unbiased - set to true to return the unbiased correlation, + false to return the biased version.
+
+
+
+ +

+spearman

+
+public static float spearman(float[] x,
+                             float[] y,
+                             boolean unbiased)
+
+
Computes Spearman's rank-correlation, or rho. + That is, the raw dataset Xi,Yi are first converted to ranks rXi, rYi + and the correlation between the ranks computed using the Pearson correlation coefficient + formula. +

+

+
+
+
+
Parameters:
unbiased - set to true to return the unbiased correlation, + false to return the biased version.
+
+
+
+ +

+cov

+
+public static float cov(float[] data1,
+                        float[] data2,
+                        boolean unbiased)
+
+
Returns the covariance of two data sequences data1 and data2, + each of length N. That is, +
 
+ cov(data1, data2) = E(  (data1[i] - mean(data1))* (data2[i] - mean(data2)) ),
+ 
+ where E is the mathematical expectation. +

+ cov(x,y,true) normalizes by N - 1, if N > 1, where N is the number of observations. + This makes cov(x,y,true) the best unbiased estimate of the covariance matrix if the + observations are from a normal distribution. For N = 1, cov(x,y,true) normalizes by N. +

+ cov(x,y,false) normalizes by N and produces the second moment matrix of the observations + about their mean. +

+

+
+
+
+
Parameters:
data1 - x
data2 - y
unbiased - set to true to return the unbiased covariance (division by N-1), + false to return the biased version (division by N).
+
+
+
+ +

+cov

+
+public static float[][] cov(float[][] data,
+                            boolean unbiased)
+
+
Returns the covariance matrix of P data sequences, each of length N. + That is, given P columns, data1, data2, ... , dataP, + each of length n, it computes and returns the P-by-P covariance + matrix, S with each element SJK given by +
+ SJK = SKJ = cov(dataJ,dataK,bias).       
+ 
+ + cov(data,true) normalizes by N - 1, if N > 1, where N is the number of observations + (or the number of rows in the input matrix). + This makes cov(data,true) the best unbiased estimate of the covariance matrix if the + observations are from a normal distribution. For N = 1, cov(data) normalizes by N. + +

+ cov(data,false) normalizes by N and produces the second moment matrix of the observations + about their mean. +

+

+
+
+
+
Parameters:
data - Each column corresponds to a dataset; each row corresponds to an observation
unbiased - set to true to return the unbiased covariance matrix, false to return the biased version.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/CorrelationPlot.html b/drawing/papaya/reference/papaya/CorrelationPlot.html new file mode 100644 index 0000000..de786bf --- /dev/null +++ b/drawing/papaya/reference/papaya/CorrelationPlot.html @@ -0,0 +1,363 @@ + + + + + + +CorrelationPlot (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class CorrelationPlot

+
+java.lang.Object
+  extended by papaya.Visuals
+      extended by papaya.CorrelationPlot
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class CorrelationPlot
extends Visuals
+ + +

+Takes in a matrix and plots the data in each of the columns versus + each other. Each of the columns are normalized to their minimum and maximum values which + can be a little misleading. For example, say you are looking at columns specifying the weight + of different panda bears over 100 days. + Panda bear A (Ling-Ling)'s weight varies from 650 to 970 pounds + (she's an emotional eater), while panda bear B (Thomas)'s weight varies from 512 to 516 pounds + (he's not a big fan of bamboo; also kind of metrosexual). The correlation plot will not show you + this difference in magnitudes or ranges! + There are many ways of addressing that, and all of them involve you writing your + own code. :) +

If you absolutely insist on using this despite the warning above, then the (somewhat messy) hack + around it is to pad each column of your data with 2 additional rows containing the + minimum and maximum that you want to abide by. Just make sure it doesn't muck everything + else up though! +

+ +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from class papaya.Visuals
bgColor
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
CorrelationPlot(PApplet _theParent, + float _plotLeft, + float _plotTop, + float _plotWidth, + float _plotHeight) + +
+          Setup the plot dimensions
+  + + + + + + + + + + + + + + + +
+Method Summary
+ voiddrawBorderAndLabels(String[] categories, + int bgColor) + +
+          Draw the bordering lines and write the labels.
+ voiddrawPlot(float[][] data, + int pos, + int fColor) + +
+          Plots the scatter plot of each of the columns of the input data matrix vs.
+ + + + + + + +
Methods inherited from class papaya.Visuals
drawAxes, drawRect, drawRect, getBottom, getHeight, getLeft, getRight, getTop, getWidth, horizLine, legendHoriz, legendVert, line, mapXData, mapXData, mapYData, mapYData, setBackgroundColor, setHeight, setLeft, setTop, setupFont, setupFont, setWidth, vertLine, writeLabels, writeLabels, writeLabels, writeLabels, writeLabels, writeTitle, xLabels, xLabels, xTicks, yLabels, yLabels, YLines, yTicks
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+CorrelationPlot

+
+public CorrelationPlot(PApplet _theParent,
+                       float _plotLeft,
+                       float _plotTop,
+                       float _plotWidth,
+                       float _plotHeight)
+
+
Setup the plot dimensions +

+

+ + + + + + + + +
+Method Detail
+ +

+drawPlot

+
+public void drawPlot(float[][] data,
+                     int pos,
+                     int fColor)
+
+
Plots the scatter plot of each of the columns of the input data matrix vs. the + other columns. Each of the columns are normalized to their minimum and maximum values which + can be a little misleading. For example, say you are looking at columns specifying the weight + of different panda bears over 100 days. + Panda bear A (Ling-Ling)'s weight varies from 450 to 670 pounds + (she's an emotional eater), while panda bear B (Thomas)'s weight varies from 512 to 516 pounds + (he's not a big fan of bamboo). The correlation plot will not show you this difference + since both could follow the same sort of distribution. + + There are many ways of addressing that, and all of them involve you writing your + own code. :) +

If you absolutely insist on using this despite the warning above, then the (very messy) hack + around it is to pad each column of your data with 2 additional rows containing the + minimum and maximum that you want to abide by. Just make sure it doesn't muck everything + else up though! +

+

+
Parameters:
data - the data array with each column corresponding to a dataset
pos - 0 for top right plots, 1 for bottom left plots
fColor - the fill color for the dots on the plot.
+
+
+
+ +

+drawBorderAndLabels

+
+public void drawBorderAndLabels(String[] categories,
+                                int bgColor)
+
+
Draw the bordering lines and write the labels. +

+

+
Parameters:
categories - the labels along the diagonal
bgColor - background rectangle color
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Descriptive.Mean.html b/drawing/papaya/reference/papaya/Descriptive.Mean.html new file mode 100644 index 0000000..4d702c4 --- /dev/null +++ b/drawing/papaya/reference/papaya/Descriptive.Mean.html @@ -0,0 +1,429 @@ + + + + + + +Descriptive.Mean (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Descriptive.Mean

+
+java.lang.Object
+  extended by papaya.Descriptive.Mean
+
+
+
Enclosing class:
Descriptive
+
+
+
+
public static class Descriptive.Mean
extends Object
+ + +

+Contains methods for computing the arithmetic, geometric, harmonic, trimmed, and winsorized + means (among others). +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatarithmetic(float[] data) + +
+          Returns the arithmetic mean of a data sequence; + That is Sum( data[i] ) / data.length .
+static float[]columnMean(float[][] data) + +
+          Returns an array containing the arithmetic mean of each column + of the input matrix.
+static floatgeometric(float[] data) + +
+          Returns the geometric mean of a data sequence.
+static floatgeometric(int size, + float sumOfLogarithms) + +
+          Returns the geometric mean of a data sequence.
+static floatharmonic(float[] data) + +
+          Returns the harmonic mean of a data sequence as Sum( 1.0 / data[i]).
+static floatharmonic(int size, + float sumOfInversions) + +
+          Returns the harmonic mean of a data sequence.
+static float[]rowMean(float[][] data) + +
+          Returns an array containing the arithmetic mean of each row of the input matrix.
+static floattrimmed(float[] sortedData, + float mean, + int left, + int right) + +
+          Returns the trimmed arithmetic mean of a sorted data sequence.
+static floatwinsorized(float[] sortedData, + float mean, + int left, + int right) + +
+          Returns the winsorized mean of a sorted data sequence.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+columnMean

+
+public static float[] columnMean(float[][] data)
+
+
Returns an array containing the arithmetic mean of each column + of the input matrix. +

+

+
+
+
+
+ +

+rowMean

+
+public static float[] rowMean(float[][] data)
+
+
Returns an array containing the arithmetic mean of each row of the input matrix. +

+

+
+
+
+
+ +

+arithmetic

+
+public static float arithmetic(float[] data)
+
+
Returns the arithmetic mean of a data sequence; + That is Sum( data[i] ) / data.length . +

+

+
+
+
+
+ +

+geometric

+
+public static float geometric(int size,
+                              float sumOfLogarithms)
+
+
Returns the geometric mean of a data sequence. + Note that for a geometric mean to be meaningful, the minimum of the data sequence must not be less or equal to zero. +
+ The geometric mean is given by pow( Product( data[i] ), 1/size) + which is equivalent to Math.exp( Sum( Log(data[i]) ) / size). +

+ The latter version is used here is the former easily results in overflows. +

+

+
+
+
+
+ +

+geometric

+
+public static float geometric(float[] data)
+
+
Returns the geometric mean of a data sequence. + Note that for a geometric mean to be meaningful, the minimum of the data sequence must not be less or equal to zero. +
+ The geometric mean is given by pow( Product( data[i] ), 1/data.size()). + This method tries to avoid overflows at the expense of an equivalent but somewhat slow definition: + geometricMean = Math.exp( Sum( Log(data[i]) ) / size). +

+

+
+
+
+
+ +

+harmonic

+
+public static float harmonic(int size,
+                             float sumOfInversions)
+
+
Returns the harmonic mean of a data sequence. +

+

+
Parameters:
size - the number of elements in the data sequence.
sumOfInversions - Sum( 1.0 / data[i]).
+
+
+
+ +

+harmonic

+
+public static float harmonic(float[] data)
+
+
Returns the harmonic mean of a data sequence as Sum( 1.0 / data[i]). +

+

+
Parameters:
data - array
+
+
+
+ +

+trimmed

+
+public static float trimmed(float[] sortedData,
+                            float mean,
+                            int left,
+                            int right)
+
+
Returns the trimmed arithmetic mean of a sorted data sequence. +

+

+
Parameters:
sortedData - the data sequence; must be sorted ascending.
mean - the mean of the (full) sorted data sequence.
left - the number of leading elements to trim.
right - the number of trailing elements to trim.
+
+
+
+ +

+winsorized

+
+public static float winsorized(float[] sortedData,
+                               float mean,
+                               int left,
+                               int right)
+
+
Returns the winsorized mean of a sorted data sequence. +

+

+
Parameters:
sortedData - the data sequence; must be sorted ascending.
mean - the mean of the (full) sorted data sequence.
left - the number of leading elements to trim.
right - the number of trailing elements to trim.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Descriptive.Pooled.html b/drawing/papaya/reference/papaya/Descriptive.Pooled.html new file mode 100644 index 0000000..1712a93 --- /dev/null +++ b/drawing/papaya/reference/papaya/Descriptive.Pooled.html @@ -0,0 +1,333 @@ + + + + + + +Descriptive.Pooled (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Descriptive.Pooled

+
+java.lang.Object
+  extended by papaya.Descriptive.Pooled
+
+
+
Enclosing class:
Descriptive
+
+
+
+
public static class Descriptive.Pooled
extends Object
+ + +

+Class for computing the pooled mean and variance of data sequences +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatmean(float[] means, + int[] sizes) + +
+          Returns the pooled mean of a k data sequences.
+static floatmean(float mean1, + int size1, + float mean2, + int size2) + +
+          Returns the pooled mean of two data sequences.
+static floatvar(float[] variances, + int[] sizes, + boolean unbiased) + +
+          Returns the pooled variance of k data sequences.
+static floatvar(float variance1, + int size1, + float variance2, + int size2, + boolean unbiased) + +
+          Returns the pooled variance of two data sequences.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+mean

+
+public static float mean(float mean1,
+                         int size1,
+                         float mean2,
+                         int size2)
+
+
Returns the pooled mean of two data sequences. + That is (size1 * mean1 + size2 * mean2) / (size1 + size2). +

+

+

+
Parameters:
size1 - the number of elements in data sequence 1.
mean1 - the mean of data sequence 1.
size2 - the number of elements in data sequence 2.
mean2 - the mean of data sequence 2.
+
+
+
+ +

+mean

+
+public static float mean(float[] means,
+                         int[] sizes)
+
+
Returns the pooled mean of a k data sequences. + That is (size1 * mean1 + size2 * mean1 + ... + sizek * meank) / (size1 + size2 + ... + sizek). +

+

+

+
+
+
+
+ +

+var

+
+public static float var(float variance1,
+                        int size1,
+                        float variance2,
+                        int size2,
+                        boolean unbiased)
+
+
Returns the pooled variance of two data sequences. The unbiased estimate of the + pooled variance is computed as +
+ unbiasedPooledVar = Sum( (size_i -1)*variance_i ) / Sum( (size_i-1) ),
+ 
+ while the biased pooled variance is computed using +
+ biasedPooledVar = Sum( (size_i)*variance_i ) / Sum(size_i),
+ 
+ For more than 2 datasets, use var(float[],int[],boolean).
+

+

+
Parameters:
size1 - the number of elements in data sequence 1.
variance1 - the variance of data sequence 1.
size2 - the number of elements in data sequence 2.
variance2 - the variance of data sequence 2.
unbiased - set to true to return the unbiased pooled variance, + false to return the biased version.
+
+
+
+ +

+var

+
+public static float var(float[] variances,
+                        int[] sizes,
+                        boolean unbiased)
+
+
Returns the pooled variance of k data sequences. The unbiased estimate of the + pooled variance is computed as +
+ unbiasedPooledVar = Sum( (sizes[i] -1)*variances[i] ) / Sum( (sizes[i]-1) ),
+ 
+ while the biased pooled variance is computed using +
+ biasedPooledVar = Sum( (sizes[i])*variances[i] ) / Sum(sizes[i]),
+

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Descriptive.Sum.html b/drawing/papaya/reference/papaya/Descriptive.Sum.html new file mode 100644 index 0000000..e068514 --- /dev/null +++ b/drawing/papaya/reference/papaya/Descriptive.Sum.html @@ -0,0 +1,438 @@ + + + + + + +Descriptive.Sum (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Descriptive.Sum

+
+java.lang.Object
+  extended by papaya.Descriptive.Sum
+
+
+
Enclosing class:
Descriptive
+
+
+
+
public static class Descriptive.Sum
extends Object
+ + +

+Methods for computing various different sums of datasets such as sum of inversions, + logs, products, power deviations, squares, etc. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static doubleinversions(float[] data, + int from, + int to) + +
+          Returns the sum of inversions of a data sequence, + which is Sum( 1.0 / data[i]).
+static doublelogs(float[] data, + int from, + int to) + +
+          Returns the sum of logarithms of a data sequence, which is Sum( Log(data[i]).
+static doublepowerDeviations(float[] data, + int k, + float c) + +
+          Returns Sum( (data[i]-c)k ); + optimized for common parameters like c == 0.0 and/or k == -2 ..
+static doublepowerDeviations(float[] data, + int k, + float c, + int from, + int to) + +
+          Returns Sum( (data[i]-c)k ) for all i = from ..
+static doublepowers(float[] data, + int k) + +
+          Returns the sum of powers of a data sequence, which is Sum ( data[i]k ).
+static doubleproducts(float[] data1, + float[] data2) + +
+          Returns the sum of the product of two data arrays, Sum( x[i] * y[i]).
+static floatsquaredDeviations(int size, + float variance) + +
+          Returns the sum of squared mean deviation of of a data sequence.
+static doublesquares(float[] data) + +
+          Returns the sum of squares of a data sequence.
+static floatsum(float[] data) + +
+          Returns the simple sum of a data sequence.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+inversions

+
+public static double inversions(float[] data,
+                                int from,
+                                int to)
+
+
Returns the sum of inversions of a data sequence, + which is Sum( 1.0 / data[i]). +

+

+
Parameters:
data - the data sequence.
from - the index of the first data element (inclusive).
to - the index of the last data element (inclusive).
+
+
+
+ +

+logs

+
+public static double logs(float[] data,
+                          int from,
+                          int to)
+
+
Returns the sum of logarithms of a data sequence, which is Sum( Log(data[i]). +

+

+
Parameters:
data - the data sequence.
from - the index of the first data element (inclusive).
to - the index of the last data element (inclusive).
+
+
+
+ +

+products

+
+public static double products(float[] data1,
+                              float[] data2)
+
+
Returns the sum of the product of two data arrays, Sum( x[i] * y[i]). +

+

+
Parameters:
data1 - the first data sequence.
data2 - the second data sequence +
Returns:
the sum of the product of the two data sequences.
+
+
+
+ +

+powerDeviations

+
+public static double powerDeviations(float[] data,
+                                     int k,
+                                     float c)
+
+
Returns Sum( (data[i]-c)k ); + optimized for common parameters like c == 0.0 and/or k == -2 .. 4. +

+

+
+
+
+
+ +

+powerDeviations

+
+public static double powerDeviations(float[] data,
+                                     int k,
+                                     float c,
+                                     int from,
+                                     int to)
+
+
Returns Sum( (data[i]-c)k ) for all i = from .. to; + optimized for common parameters like c == 0.0 and/or k == -2 .. 5. + Note that no checks are made for divisions by zero (important for + k = -2 and k = -1), so think twice before using this + if the data has elements = 0. +

+

+
+
+
+
+ +

+powers

+
+public static double powers(float[] data,
+                            int k)
+
+
Returns the sum of powers of a data sequence, which is Sum ( data[i]k ). +

+

+
+
+
+
+ +

+squaredDeviations

+
+public static float squaredDeviations(int size,
+                                      float variance)
+
+
Returns the sum of squared mean deviation of of a data sequence. + That is variance * (size-1) == Sum( (data[i] - mean)^2 ). +

+

+
Parameters:
size - the number of elements of the data sequence.
variance - the variance of the data sequence.
+
+
+
+ +

+squares

+
+public static double squares(float[] data)
+
+
Returns the sum of squares of a data sequence. + That is Sum ( data[i]*data[i] ). +

+

+
+
+
+
+ +

+sum

+
+public static float sum(float[] data)
+
+
Returns the simple sum of a data sequence. + That is Sum( data[i] ). +

+

+
See Also:
Mat.sum(float[]), +Mat.sum(float[], float[]), +Mat.sum(float[],float)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Descriptive.Weighted.html b/drawing/papaya/reference/papaya/Descriptive.Weighted.html new file mode 100644 index 0000000..72e00ce --- /dev/null +++ b/drawing/papaya/reference/papaya/Descriptive.Weighted.html @@ -0,0 +1,307 @@ + + + + + + +Descriptive.Weighted (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Descriptive.Weighted

+
+java.lang.Object
+  extended by papaya.Descriptive.Weighted
+
+
+
Enclosing class:
Descriptive
+
+
+
+
public static class Descriptive.Weighted
extends Object
+ + +

+Contains methods related to weighted datasets. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatmean(float[] data, + float[] weights) + +
+          Returns the weighted mean of a data sequence.
+static floatrms(float sumOfProducts, + float sumOfSquaredProducts) + +
+          Returns the weighted RMS (Root-Mean-Square) of a data sequence.
+static floatvar(float[] data, + float[] weights, + boolean unbiased) + +
+          Returns the weighted variance of a data sequence of length N + There are (unfortunately) many different definitions of the unbiased weighted variance.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+mean

+
+public static float mean(float[] data,
+                         float[] weights)
+
+
Returns the weighted mean of a data sequence. Used when the values in a set of + data do not share equal importance. + That is Sum (data[i] * weights[i]) / Sum ( weights[i] ). +

+

+
+
+
+
+ +

+rms

+
+public static float rms(float sumOfProducts,
+                        float sumOfSquaredProducts)
+
+
Returns the weighted RMS (Root-Mean-Square) of a data sequence. + That is Sum( data[i] * data[i] * weights[i]) / Sum( data[i] * weights[i] ), + or in other words sumOfProducts / sumOfSquaredProducts. +

+

+
Parameters:
sumOfProducts - == Sum( data[i] * weights[i] ).
sumOfSquaredProducts - == Sum( data[i] * data[i] * weights[i] ).
+
+
+
+ +

+var

+
+public static float var(float[] data,
+                        float[] weights,
+                        boolean unbiased)
+
+
Returns the weighted variance of a data sequence of length N + There are (unfortunately) many different definitions of the unbiased weighted variance. + Here, we use the following formula +
+ weighted.var(x,w,unbiased=true) = biasCorrection * Sum ( w[i] * (x[i] - mu_w)^2  ) / Sum(w[i]).
+ 
+ where mu_w corresponds to the weighted mean and the biasCorrection + term +
+ biasCorrection = ( Sum(w[i]) )^2  / ( ( Sum(w[i]) )^2 - Sum( w[i]^2 )  ).
+ 
+ corrects for the bias in the variance. + weighted.var(x,w,unbiased=false) computes the biased weighted variance and is given by the formula above, + but without the correction factor. + +

The formula above agrees with that presented in + + the NIST Information Technology Laboratory page. + The algorithm used, is a one-pass formula credited to + "D. H. D. West (1979). Communications of the ACM, 22, 9, 532-535: + Updating Mean and Variance Estimates: An Improved Method", and spelled out under the +
+ weighted incremental algorithm section of the link. +

+

+
Parameters:
unbiased - set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N). +
Returns:
the weighted variance.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Descriptive.html b/drawing/papaya/reference/papaya/Descriptive.html new file mode 100644 index 0000000..3d79788 --- /dev/null +++ b/drawing/papaya/reference/papaya/Descriptive.html @@ -0,0 +1,1412 @@ + + + + + + +Descriptive (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Descriptive

+
+java.lang.Object
+  extended by papaya.Descriptive
+
+
+
+
public class Descriptive
extends Object
+ + +

+Basic descriptive statistics class for exploratory data analysis. + Methods for computing Correlations and Covariances are in the Correlation + class. Where appropriate, methods with similar functions are grouped into + static subclasses. For example, the Descriptive.Sum class contains the following + methods: +

+ while the Descriptive.Mean class has the + + utilities. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + +
+Nested Class Summary
+static classDescriptive.Mean + +
+          Contains methods for computing the arithmetic, geometric, harmonic, trimmed, and winsorized + means (among others).
+static classDescriptive.Pooled + +
+          Class for computing the pooled mean and variance of data sequences
+static classDescriptive.Sum + +
+          Methods for computing various different sums of datasets such as sum of inversions, + logs, products, power deviations, squares, etc.
+static classDescriptive.Weighted + +
+          Contains methods related to weighted datasets.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static voidfrequencies(float[] sortedData, + ArrayList<Float> distinctValues, + ArrayList<Integer> frequencies) + +
+          Computes the frequency (number of occurances, count) of each distinct value in the given sorted data.
+static floatkurtosis(float[] data, + float mean, + float standardDeviation) + +
+          Returns the kurtosis (aka excess) of a data sequence, which is + -3 + moment(data,4,mean) / standardDeviation4.
+static floatkurtosis(float moment4, + float standardDeviation) + +
+          Returns the kurtosis (aka excess) of a data sequence.
+static doublemax(double[] data) + +
+          Returns the largest member of a data sequence.
+static doublemax(double a, + double b) + +
+           
+static floatmax(float[] data) + +
+          Returns the largest member of a data sequence.
+static floatmax(float[][] data) + +
+          Returns the largest member of a matrix.
+static floatmax(float a, + float b) + +
+           
+static intmax(int[] data) + +
+          Returns the largest member of a data sequence.
+static intmax(int[][] data) + +
+          Returns the largest member of a matrix.
+static intmax(int a, + int b) + +
+           
+static floatmean(float[] data) + +
+          Returns the arithmetic mean of a data sequence; + That is Sum( data[i] ) / data.length .
+static floatmeanDeviation(float[] data, + float mean) + +
+          Returns the mean deviation of a dataset.
+static floatmedian(float[] data, + boolean isSorted) + +
+          Returns the median of a data sequence.
+static doublemin(double[] data) + +
+          Returns the smallest member of a data sequence.
+static doublemin(double a, + double b) + +
+           
+static floatmin(float[] data) + +
+          Returns the smallest member of a data sequence.
+static floatmin(float[][] data) + +
+          Returns the smallest member of a matrix.
+static floatmin(float a, + float b) + +
+           
+static intmin(int[] data) + +
+          Returns the smallest member of a data sequence.
+static intmin(int[][] data) + +
+          Returns the smallest member of a matrix.
+static intmin(int a, + int b) + +
+           
+static float[]mod(float[] data) + +
+          Returns the array containing the elements that appear the most in a given dataset.
+static floatmoment(float[] data, + int k, + float c) + +
+          Returns the moment of k-th order with constant c of a data sequence, + which is Sum( (data[i]-c)k ) / data.size().
+static float[]outliers(float[] data, + float lowerLimit, + float upperLimit, + boolean isSorted) + +
+          Returns the array containing all elements in the dataset that are less than + or equal to the lowerLimit + and more than or equal to the upperLimit
+static floatproduct(float[] data) + +
+          Returns the product of a data sequence, which is Prod( data[i] ).
+static floatproduct(int size, + float sumOfLogarithms) + +
+          Returns the product, which is Prod( data[i] ).
+static floatquantile(float[] sortedData, + float phi) + +
+          Returns the phi-quantile; that is, an element elem + for which holds that phi percent of data elements are less than + elem.
+static floatquantileInverse(float[] sortedList, + float element) + +
+          Returns how many percent of the elements contained in the receiver are <= element.
+static float[]quantiles(float[] sortedData, + float[] percentages) + +
+          Returns the quantiles of the specified percentages.
+static float[]quartiles(float[] data, + boolean isSorted) + +
+          Returns the quartiles of the input data array (not necessarily sorted).
+static floatrankInterpolated(float[] sortedList, + float element) + +
+          Returns the linearly interpolated number of elements in an array that + are ≤ a given element.
+static floatrms(int size, + double sumOfSquares) + +
+          Returns the RMS (Root-Mean-Square) of a data sequence.
+static floatskew(float[] data, + float mean, + float standardDeviation) + +
+          Returns the skew of a data sequence, which is moment(data,3,mean) / standardDeviation3.
+static floatskew(float moment3, + float standardDeviation) + +
+          Returns the skew of a data sequence when the 3rd moment has already been computed.
+static float[]std(float[][] data, + boolean unbiased) + +
+          Returns an array with each element of the array corresponding to + the standard deviations of each column of the input + matrix.
+static floatstd(float[] data, + boolean unbiased) + +
+          Returns the standard deviation of a dataset.
+static floatstdUnbiased(int size, + float sampleVariance) + +
+          Returns the unbiased sample standard deviation assuming the sample is normally distributed.
+static float[]tukeyFiveNum(float[] data) + +
+          Return the tukey five number summary of a dataset consisting of the minimum, maximum, + and three quartile values.
+static float[]var(float[][] data, + boolean unbiased) + +
+          Returns an array containing the variance of each column of the input matrix X.
+static floatvar(float[] data, + boolean unbiased) + +
+          Returns the variance of a dataset, V.
+static float[][]zScore(float[][] X, + float[] means, + float[] standardDeviations) + +
+          Computes the standardized version of the input matrix.
+static float[]zScore(float[] x, + float mean, + float standardDeviation) + +
+          Returns the array of z-scores for a given data array.
+static floatzScore(float x, + float mean, + float standardDeviation) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+frequencies

+
+public static void frequencies(float[] sortedData,
+                               ArrayList<Float> distinctValues,
+                               ArrayList<Integer> frequencies)
+
+
Computes the frequency (number of occurances, count) of each distinct value in the given sorted data. + After this call, both distinctValues and frequencies have a new size (which is equal for both), + which is the number of distinct values in the sorted data. +

+ Distinct values are filled into distinctValues, starting at index 0. + The frequency of each distinct value is filled into frequencies, starting at index 0. + As a result, the smallest distinct value (and its frequency) can be found at index 0, + the second smallest distinct value (and its frequency) at index 1, ..., + the largest distinct value (and its frequency) at index distinctValues.size()-1. +

+ Example: +
+ sortedData = (5,6,6,7,8,8) --> distinctValues = (5,6,7,8), frequencies = (1,2,1,2) +

+ Code-wise, you would write: +
 
+ ArrayList distinctValues = new ArrayList(); 
+ 
+ ArrayList frequencies = new ArrayList();  
+ 
+ frequencies(sortedData,distinctValues,frequencies);
+ 
+

+

+
Parameters:
sortedData - the data; must be sorted ascending.
distinctValues - a ArrayList to be filled with the distinct values; can have any size.
frequencies - a ArrayList to be filled with the frequencies; can have any size; + set this parameter to null to ignore it.
See Also:
Frequency, +Unique
+
+
+
+ +

+kurtosis

+
+public static float kurtosis(float moment4,
+                             float standardDeviation)
+
+
Returns the kurtosis (aka excess) of a data sequence. +

+

+
Parameters:
moment4 - the fourth central moment, which is moment(data,4,mean).
standardDeviation - the standardDeviation.
+
+
+
+ +

+kurtosis

+
+public static float kurtosis(float[] data,
+                             float mean,
+                             float standardDeviation)
+
+
Returns the kurtosis (aka excess) of a data sequence, which is + -3 + moment(data,4,mean) / standardDeviation4. +

+

+
+
+
+
+ +

+max

+
+public static int max(int a,
+                      int b)
+
+
+
+
+
+
+ +

+max

+
+public static float max(float a,
+                        float b)
+
+
+
+
+
+
+ +

+max

+
+public static double max(double a,
+                         double b)
+
+
+
+
+
+
+ +

+max

+
+public static double max(double[] data)
+
+
Returns the largest member of a data sequence. +

+

+
+
+
+
+ +

+max

+
+public static float max(float[] data)
+
+
Returns the largest member of a data sequence. +

+

+
+
+
+
+ +

+max

+
+public static int max(int[] data)
+
+
Returns the largest member of a data sequence. +

+

+
+
+
+
+ +

+max

+
+public static float max(float[][] data)
+
+
Returns the largest member of a matrix. +

+

+
+
+
+
+ +

+max

+
+public static int max(int[][] data)
+
+
Returns the largest member of a matrix. +

+

+
+
+
+
+ +

+mean

+
+public static float mean(float[] data)
+
+
Returns the arithmetic mean of a data sequence; + That is Sum( data[i] ) / data.length . + Similar to Descriptive.Mean.arithmetic(float[]). +

+

+
+
+
+
+ +

+meanDeviation

+
+public static float meanDeviation(float[] data,
+                                  float mean)
+
+
Returns the mean deviation of a dataset. + That is Sum( Math.abs(data[i]-mean)) ) / data.length. +

+

+
+
+
+
+ +

+median

+
+public static float median(float[] data,
+                           boolean isSorted)
+
+
Returns the median of a data sequence. +

+

+
Parameters:
data - the data sequence;
isSorted - true if the data sequence is sorted (in ascending order), else false.
+
+
+
+ +

+min

+
+public static int min(int a,
+                      int b)
+
+
+
+
+
+
+ +

+min

+
+public static float min(float a,
+                        float b)
+
+
+
+
+
+
+ +

+min

+
+public static double min(double a,
+                         double b)
+
+
+
+
+
+
+ +

+min

+
+public static double min(double[] data)
+
+
Returns the smallest member of a data sequence. +

+

+
+
+
+
+ +

+min

+
+public static float min(float[] data)
+
+
Returns the smallest member of a data sequence. +

+

+
+
+
+
+ +

+min

+
+public static float min(float[][] data)
+
+
Returns the smallest member of a matrix. +

+

+
+
+
+
+ +

+min

+
+public static int min(int[] data)
+
+
Returns the smallest member of a data sequence. +

+

+
+
+
+
+ +

+min

+
+public static int min(int[][] data)
+
+
Returns the smallest member of a matrix. +

+

+
+
+
+
+ +

+mod

+
+public static float[] mod(float[] data)
+
+
Returns the array containing the elements that appear the most in a given dataset. + (The return type has to be an array since a dataset can have more than one mod value). +

+

+
Parameters:
data - the data array +
Returns:
the array containing the (distinct) elements that appear the most.
+
+
+
+ +

+moment

+
+public static float moment(float[] data,
+                           int k,
+                           float c)
+
+
Returns the moment of k-th order with constant c of a data sequence, + which is Sum( (data[i]-c)k ) / data.size(). +

+

+
+
+
+
+ +

+outliers

+
+public static float[] outliers(float[] data,
+                               float lowerLimit,
+                               float upperLimit,
+                               boolean isSorted)
+
+
Returns the array containing all elements in the dataset that are less than + or equal to the lowerLimit + and more than or equal to the upperLimit +

+

+
Parameters:
data - the data array
lowerLimit -
upperLimit -
isSorted - true if the data array has been sorted in ascending order, else set to false.
+
+
+
+ +

+product

+
+public static float product(int size,
+                            float sumOfLogarithms)
+
+
Returns the product, which is Prod( data[i] ). + In other words: data[0]*data[1]*...*data[data.length-1]. + This method uses the equivalent definition: + prod = pow( exp( Sum( Log(x[i]) ) / length*length). +

+

+
+
+
+
+ +

+product

+
+public static float product(float[] data)
+
+
Returns the product of a data sequence, which is Prod( data[i] ). + In other words: data[0]*data[1]*...*data[data.length-1]. + Note that you may easily get numeric overflows. Use product(int,float) + instead to avoid that. +

+

+
+
+
+
+ +

+quartiles

+
+public static float[] quartiles(float[] data,
+                                boolean isSorted)
+
+
Returns the quartiles of the input data array (not necessarily sorted). + +

Details:
+ The first quartile, or lower quartile (Q[0]), is the value that cuts off + the first 25% of the data when it is sorted in ascending order. + The second quartile, or median (Q[1]), is the value that cuts off the first 50%. + The third quartile, or upper quartile (Q[2], is the value that cuts off the first 75%. +

+

+

+
Parameters:
data - The data array.
isSorted - true if the data array has been sorted in ascending order, else set to false. +
Returns:
The 3 quartile values Q[0], Q[1], and Q[2].
+
+
+
+ +

+quantile

+
+public static float quantile(float[] sortedData,
+                             float phi)
+
+
Returns the phi-quantile; that is, an element elem + for which holds that phi percent of data elements are less than + elem. + The quantile need not necessarily be contained in the data sequence, + it can be a linear interpolation. +

+

+
Parameters:
sortedData - the data sequence; must be sorted ascending.
phi - the percentage; must satisfy 0 <= phi <= 1.
+
+
+
+ +

+quantileInverse

+
+public static float quantileInverse(float[] sortedList,
+                                    float element)
+
+
Returns how many percent of the elements contained in the receiver are <= element. + Does linear interpolation if the element is not contained but lies in between + two contained elements. +

+

+
Parameters:
sortedList - the list to be searched (must be sorted ascending).
element - the element to search for. +
Returns:
the percentage phi of elements <= element + (0.0 <= phi <= 1.0).
+
+
+
+ +

+quantiles

+
+public static float[] quantiles(float[] sortedData,
+                                float[] percentages)
+
+
Returns the quantiles of the specified percentages. + The quantiles need not necessarily be contained in the data sequence, it can be a linear interpolation. +

+

+
Parameters:
sortedData - the data sequence; must be sorted ascending.
percentages - the percentages for which quantiles are to be computed. + Each percentage must be in the interval [0.0f,1.0f]. +
Returns:
the quantiles.
+
+
+
+ +

+rankInterpolated

+
+public static float rankInterpolated(float[] sortedList,
+                                     float element)
+
+
Returns the linearly interpolated number of elements in an array that + are ≤ a given element. + The rank is the number of elements ≤ element. + Ranks are of the form {0, 1, 2,..., sortedList.size()}. +

If no element is ≤ element, then the rank is zero.

+ +

If the element lies in between two contained elements, then + linear interpolation is used and a non integer value is returned.

+

+

+
Parameters:
sortedList - the list to be searched (must be sorted ascending).
element - the element to search for. +
Returns:
the rank of the element.
+
+
+
+ +

+rms

+
+public static float rms(int size,
+                        double sumOfSquares)
+
+
Returns the RMS (Root-Mean-Square) of a data sequence. + That is Math.sqrt(Sum( data[i]*data[i] ) / data.length). + The RMS of data sequence is the square-root of the mean of the squares of the elements in the data sequence. + It is a measure of the average "size" of the elements of a data sequence. +

+

+
Parameters:
sumOfSquares - sumOfSquares(data) == Sum( data[i]*data[i] ) of the data sequence.
size - the number of elements in the data sequence.
+
+
+
+ +

+skew

+
+public static float skew(float moment3,
+                         float standardDeviation)
+
+
Returns the skew of a data sequence when the 3rd moment has already been computed. +

+

+
Parameters:
moment3 - the third central moment, which is moment(data,3,mean).
standardDeviation - the standardDeviation.
+
+
+
+ +

+skew

+
+public static float skew(float[] data,
+                         float mean,
+                         float standardDeviation)
+
+
Returns the skew of a data sequence, which is moment(data,3,mean) / standardDeviation3. +

+

+
+
+
+
+ +

+std

+
+public static float std(float[] data,
+                        boolean unbiased)
+
+
Returns the standard deviation of a dataset. + + There are two definitions of the standard deviation: +
+ sigma_1 = 1/(N-1) * Sum( (x[i] - mean(x))^2 )
+ sigma_2 = 1/(N) * Sum( (x[i] - mean(x))^2 )
+ 
+ sigma_1 is the square root of an unbiased estimator of the variance of the population + the x is drawn, as long as x consists of independent, identically distributed samples. + sigma_2 corresponds to the second moment of the set of values about their mean. +

+ std(data,unbiased==true) returns sigma_1 above, while std(data,unbiased==false) returns sigma_2. +

+

+
Parameters:
data - the dataset
unbiased - set to true to return the unbiased standard deviation, + false to return the biased version.
+
+
+
+ +

+std

+
+public static float[] std(float[][] data,
+                          boolean unbiased)
+
+
Returns an array with each element of the array corresponding to + the standard deviations of each column of the input + matrix. Each column of the matrix corresponds to a dataset, and each row an observation. + + There are two definitions of the standard deviation: +
+ sigma_1 = 1/(N-1) * Sum( (x[i] - mean(x))^2 )
+ sigma_2 = 1/(N) * Sum( (x[i] - mean(x))^2 )
+ 
+ sigma_1 is the square root of an unbiased estimator of the variance of the population + the x is drawn, as long as x consists of independent, identically distributed samples. + sigma_2 corresponds to the second moment of the set of values about their mean. +

+ std(data,unbiased==true) returns sigma_1 above, while std(data,unbiased==false) returns sigma_2. +

+

+
Parameters:
data - the dataset
unbiased - set to true to return the unbiased standard deviation, + false to return the biased version.
+
+
+
+ +

+stdUnbiased

+
+public static float stdUnbiased(int size,
+                                float sampleVariance)
+
+
Returns the unbiased sample standard deviation assuming the sample is normally distributed. + + Ref: R.R. Sokal, F.J. Rohlf, Biometry: the principles and practice of statistics + in biological research (W.H. Freeman and Company, New York, 1998, 3rd edition) + p. 53. +

See also this entry on wikipedia.org +

+

+
Parameters:
size - the number of elements of the data sequence.
sampleVariance - the sample variance.
+
+
+
+ +

+tukeyFiveNum

+
+public static float[] tukeyFiveNum(float[] data)
+
+
Return the tukey five number summary of a dataset consisting of the minimum, maximum, + and three quartile values. +

+

+
Parameters:
data - the data array +
Returns:
the array of five numbers.
+
+
+
+ +

+var

+
+public static float var(float[] data,
+                        boolean unbiased)
+
+
Returns the variance of a dataset, V. + For matrices, var(X,unbiased=true) returns an array containing the variance of each column of X. + The result V is an unbiased estimator of the variance of the population from which + X is drawn, as long as X consists of independent, identically distributed samples. +

+ var(x,true) normalizes V by N - 1 if N > 1, where N is the sample size. + This is an unbiased estimator of the variance of the population from which X is drawn, + as long as X consists of independent, identically distributed samples. For N = 1, + V is normalized by 1. +

+ V = var(x,false) normalizes by N and produces the second moment of the sample about its mean. + +

Reference: +
+ Algorithms for calculating variance, Wikipedia.org +
+ Incremental calculation of weighted mean and variance, Tony Finch +

+

+
Parameters:
data - the data sequence.
unbiased - set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N). +
Returns:
the variance in the data.
+
+
+
+ +

+var

+
+public static float[] var(float[][] data,
+                          boolean unbiased)
+
+
Returns an array containing the variance of each column of the input matrix X. + The result V is an unbiased estimator of the variance of the population from which + X is drawn, as long as X consists of independent, identically distributed samples. +

+ var(X,unbiased=true) normalizes V by N - 1 if N > 1, where N is the sample size. + This is an unbiased estimator of the variance of the population from which X is drawn, + as long as X consists of independent, identically distributed samples. For N = 1, + V is normalized by 1. +

+ V = var(X,unbiased=false) normalizes by N and produces the second moment of the sample about its mean. + +

Reference: +
+ Algorithms for calculating variance, Wikipedia.org +
+ Incremental calculation of weighted mean and variance, Tony Finch +

+

+
Parameters:
data - the data sequence.
unbiased - set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N). +
Returns:
the variance in the data.
+
+
+
+ +

+zScore

+
+public static float zScore(float x,
+                           float mean,
+                           float standardDeviation)
+
+
+ +
Returns:
the z-score of that element computed as (x-mean)/standardDeviation
+
+
+
+ +

+zScore

+
+public static float[] zScore(float[] x,
+                             float mean,
+                             float standardDeviation)
+
+
Returns the array of z-scores for a given data array. + with each elment given by + z[i] = ( x[i] - mean ) / standardDeviation. +

+

+ +
Returns:
the standardized array, z
+
+
+
+ +

+zScore

+
+public static float[][] zScore(float[][] X,
+                               float[] means,
+                               float[] standardDeviations)
+
+
Computes the standardized version of the input matrix. That is each, each element + of column j, of the output is given by + Z[i][j] = ( X[i][j]- mean(X[,j]) / standardDeviation(X[,j]) + where mean(X[,j]) is the mean value of column j of X. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Distance.html b/drawing/papaya/reference/papaya/Distance.html new file mode 100644 index 0000000..780a608 --- /dev/null +++ b/drawing/papaya/reference/papaya/Distance.html @@ -0,0 +1,492 @@ + + + + + + +Distance (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Distance

+
+java.lang.Object
+  extended by papaya.Distance
+
+
+
+
public final class Distance
extends Object
+ + +

+Contains methods for computing various "distance" metrics for multidimensional scaling. +

+ For an m-by-n input matrix with m observations and n variables, the output D is + the symmetric m-by-m matrix with zeros along the diagonals and element ij + specifying the distance between rows i and j. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[][]chebychev(float[][] X) + +
+          Computes the Chebychev distance matrix between pairs of objects + in the m-by-n data matrix X.
+static float[][]cityblock(float[][] X) + +
+          Computes the cityblock (or Manhattan) distance matrix between pairs of objects + in the m-by-n data matrix X.
+static float[][]correlation(float[][] X) + +
+          Computes the correlation distance matrix between pairs of objects + in the m-by-n data matrix X.
+static float[][]cosine(float[][] X) + +
+          Computes the cosine distance matrix between pairs of objects + in the m-by-n data matrix X.
+static float[][]euclidean(float[][] X) + +
+          Computes the Euclidean distance between pairs of objects + in the m-by-n data matrix X.
+static float[][]mahalanobis(float[][] X) + +
+          Computes the Mahalanobis distance matrix of the m-by-n input matrix X.
+static float[][]minkowski(float[][] X, + int exp) + +
+          Returns the Minkowski distance matrix of the m-by-n input matrix X.
+static float[][]seuclidean(float[][] X) + +
+          Computes the standardized Euclidean distance between pairs of objects + in the m-by-n data matrix X by standardizing X first prior to computing + the distances.
+static float[][]spearman(float[][] X) + +
+          Computes the Spearman distance matrix of the m-by-n input matrix X.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+cityblock

+
+public static float[][] cityblock(float[][] X)
+
+
Computes the cityblock (or Manhattan) distance matrix between pairs of objects + in the m-by-n data matrix X. That is, +
+ Dist[i][j] = (X[i][1] - X[j][1]) + (X[i][2] - X[j][2]) + ... + (X[i][n] - X[j][n]). 
+ 
+

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the cityblock + (or manhattan) distance between the rows of the input X. +

+

+
+
+
+
+ +

+chebychev

+
+public static float[][] chebychev(float[][] X)
+
+
Computes the Chebychev distance matrix between pairs of objects + in the m-by-n data matrix X. That is, +
+ Dist[i][j] =Max( |X[i][1] - X[j][1]| , |X[i][2] - X[j][2]| , ... , |(X[i][n] - X[j][n]|). 
+ 
+

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the Chebychev + distance between the rows of the input X. +

+

+
+
+
+
+ +

+correlation

+
+public static float[][] correlation(float[][] X)
+
+
Computes the correlation distance matrix between pairs of objects + in the m-by-n data matrix X. E.g., if y1 and y2 corresponds to observation (or row) + 1 and 2 of X, then +
+ Dist[1][2] = 1 -  sum_{j=1^numColumns} ( ( y1_j - mean(y1) ) * ( y2_j - mean(y2) ) / ( n * std(y1)*std(y2) ) ), 
+ 
+ where n = number of columns. +

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the correlation + distance between the rows of the input X. +

+

+
+
+
+
+ +

+cosine

+
+public static float[][] cosine(float[][] X)
+
+
Computes the cosine distance matrix between pairs of objects + in the m-by-n data matrix X. E.g., if y1 and y2 corresponds to observation (or row) + 1 and 2 of X, then +
+ Dist[1][2] = 1- sum_{j=1^numColumns} ( y1_j * y2_j ) / ( mag(y1)*mag(y2) ), 
+ 
+ where mag(y1) = sum_{i=1 to numColumns} (y1[j]*y1[j]) and likewise + for mag(y2). + etc. +

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the cosine + distance between the rows of the input X. +

+

+
+
+
+
+ +

+euclidean

+
+public static float[][] euclidean(float[][] X)
+
+
Computes the Euclidean distance between pairs of objects + in the m-by-n data matrix X. That is, +
+ Dist[i][j]^2 = (X[i][1] - X[j][1]) ^2+ (X[i][2] - X[j][2])^2 + ... + (X[i][n] - X[j][n])^2. 
+ 
+

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the Euclidean + distance between the rows of the input X. +

+

+
+
+
+
+ +

+seuclidean

+
+public static float[][] seuclidean(float[][] X)
+
+
Computes the standardized Euclidean distance between pairs of objects + in the m-by-n data matrix X by standardizing X first prior to computing + the distances. The standardized X is computed using +
+ standardized value = (original value - mean)/standard deviation
+ 
+ where the mean and standard deviation correspond to the column mean and std. +

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the standardized + Euclidean distance between the rows of the input X. +

+

+
+
+
+
+ +

+mahalanobis

+
+public static float[][] mahalanobis(float[][] X)
+
+
Computes the Mahalanobis distance matrix of the m-by-n input matrix X. That is, +
+ Dist[i][j]^2 = (X[i][1] - X[j][1])^2/ invcov[1][1] + ... + (X[i][n] - X[j][n])^2/ invcov[n][n]. 
+ 
+ + Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the s + mahalanobis distance between the rows of the input X. +

+

+
+
+
+
+ +

+minkowski

+
+public static float[][] minkowski(float[][] X,
+                                  int exp)
+
+
Returns the Minkowski distance matrix of the m-by-n input matrix X. That is, +
+ Dist[i][j]^p= (X[i][1] - X[j][1])^p/ + (X[i][2] - X[j][2])^p + ... + (X[i][n] - X[j][n])^p.
+ 
+ Notice that for the special case of p = 1, the Minkowski metric + gives the city block metric, for the special case of p = 2, + the Minkowski metric gives the Euclidean distance, + and for the special case of p = &inf;, the Minkowski metric gives the Chebychev distance. + Also notice that the larger the value of p, the higher the probability of causing overflow + errors (which are, in turn, highly correlated to headaches and overall feelings of malaise). +

+

+
Parameters:
exp - the Minkowski exponent (positive).
+
+
+
+ +

+spearman

+
+public static float[][] spearman(float[][] X)
+
+
Computes the Spearman distance matrix of the m-by-n input matrix X. E.g., if y1 and y2 corresponds to observation (or row) + 1 and 2 of X with corresponding ranks +
r11, r12, ... , r1n +
+ and +
r21, r22, ... , r2n,
then +

+ Dist[1][2] = 1 -  sum_{j=1^numColumns} ( ( r1_j - mean(r1) ) * ( r2_j - mean(r2) ) / ( n * std(r1)*std(r2) ) ), 
+ 
+ and similarly for the remaining rows. +

+ Rows of X correspond to observations, and columns correspond to variables. + Returns the m-by-m matrix D with D[r1][r2] corresponding to the Spearman + distance between the rows of the input X. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Eigenvalue.html b/drawing/papaya/reference/papaya/Eigenvalue.html new file mode 100644 index 0000000..b48dff6 --- /dev/null +++ b/drawing/papaya/reference/papaya/Eigenvalue.html @@ -0,0 +1,358 @@ + + + + + + +Eigenvalue (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Eigenvalue

+
+java.lang.Object
+  extended by papaya.Eigenvalue
+
+
+
+
public class Eigenvalue
extends Object
+ + +

+Eigenvalues and eigenvectors of a real matrix. +

+ If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is + diagonal and the eigenvector matrix V is orthogonal. + I.e. A = V.times(D.times(V.transpose())) and + V.times(V.transpose()) equals the identity matrix. +

+ If A is not symmetric, then the eigenvalue matrix D is block diagonal + with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, + lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The + columns of V represent the eigenvectors in the sense that A*V = V*D, + i.e. A.times(V) equals V.times(D). The matrix V may be badly + conditioned, or even singular, so the validity of the equation + A = V*D*inverse(V) depends upon V.cond(). +

+Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +Cast.doubleToFloat(double[][]) if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
Eigenvalue(float[][] Arg) + +
+          Check for symmetry, then construct the eigenvalue decomposition.
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ double[][]getD() + +
+          Return the block diagonal eigenvalue matrix
+ double[]getImagEigenvalues() + +
+          Return the imaginary parts of the eigenvalues
+ double[]getRealEigenvalues() + +
+          Return the real parts of the eigenvalues
+ double[][]getV() + +
+          Return the eigenvector matrix with each column corresponding to + an eigenvector of the input matrix.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Eigenvalue

+
+public Eigenvalue(float[][] Arg)
+
+
Check for symmetry, then construct the eigenvalue decomposition. + Upon initialization, the matrices D and V, as well as the vectors containing the + real and imaginary eigenvalues are computed and stored. +

+

+
See Also:
getV(), +getD(), +getRealEigenvalues(), +getImagEigenvalues()
+
+ + + + + + + + +
+Method Detail
+ +

+getV

+
+public double[][] getV()
+
+
Return the eigenvector matrix with each column corresponding to + an eigenvector of the input matrix. +

+

+ +
Returns:
V
+
+
+
+ +

+getRealEigenvalues

+
+public double[] getRealEigenvalues()
+
+
Return the real parts of the eigenvalues +

+

+ +
Returns:
real(diag(D))
+
+
+
+ +

+getImagEigenvalues

+
+public double[] getImagEigenvalues()
+
+
Return the imaginary parts of the eigenvalues +

+

+ +
Returns:
imag(diag(D))
+
+
+
+ +

+getD

+
+public double[][] getD()
+
+
Return the block diagonal eigenvalue matrix +

+

+ +
Returns:
D
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Find.html b/drawing/papaya/reference/papaya/Find.html new file mode 100644 index 0000000..26f8612 --- /dev/null +++ b/drawing/papaya/reference/papaya/Find.html @@ -0,0 +1,3151 @@ + + + + + + +Find (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Find

+
+java.lang.Object
+  extended by papaya.Find
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public final class Find
extends Object
implements PapayaConstants
+ + +

+Static class for finding indices in an array corresponding to a given value/object. +

+ (Portions of this code were (conveniently!) copied and pasted from commons.apache.org.) :) +

+

+ +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static booleancontains(byte[] array, + byte valueToFind) + +
+          Checks if the value is in the given array.
+static booleancontains(char[] array, + char valueToFind) + +
+          Checks if the value is in the given array.
+static booleancontains(double[] array, + double valueToFind) + +
+          Checks if the value is in the given array.
+static booleancontains(double[] array, + double valueToFind, + double tolerance) + +
+          Checks if a value falling within the given tolerance is in the + given array.
+static booleancontains(float[] array, + float valueToFind) + +
+          Checks if the value is in the given array.
+static booleancontains(int[] array, + int valueToFind) + +
+          Checks if the value is in the given array.
+static booleancontains(long[] array, + long valueToFind) + +
+          Checks if the value is in the given array.
+static booleancontains(Object[] array, + Object objectToFind) + +
+          Checks if the object is in the given array.
+static booleancontains(short[] array, + short valueToFind) + +
+          Checks if the value is in the given array.
+static intindexOf(boolean[] array, + boolean valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(boolean[] array, + boolean valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(byte[] array, + byte valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(byte[] array, + byte valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(char[] array, + char valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(char[] array, + char valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(double[] array, + double valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(double[] array, + double valueToFind, + double tolerance) + +
+          Finds the index of the given value within a given tolerance in the array.
+static intindexOf(double[] array, + double valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(double[] array, + double valueToFind, + int startIndex, + double tolerance) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(float[] array, + float valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(float[] array, + float valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(int[] array, + int valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(int[] array, + int valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(long[] array, + long valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(long[] array, + long valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static intindexOf(Object[] array, + Object objectToFind) + +
+          Finds the index of the given object in the array.
+static intindexOf(Object[] array, + Object objectToFind, + int startIndex) + +
+          Finds the index of the given object in the array starting at the given index.
+static intindexOf(short[] array, + short valueToFind) + +
+          Finds the index of the given value in the array.
+static intindexOf(short[] array, + short valueToFind, + int startIndex) + +
+          Finds the index of the given value in the array starting at the given index.
+static int[]indicesGreaterThan(float[] array, + float valueOfMin) + +
+           
+static int[]indicesGreaterThan(int[] array, + int valueOfMin) + +
+           
+static int[]indicesGreaterThanOrEqualTo(float[] array, + float valueOfMin) + +
+           
+static int[]indicesGreaterThanOrEqualTo(int[] array, + int valueOfMin) + +
+           
+static int[]indicesLessThan(float[] array, + float valueOfMax) + +
+           
+static int[]indicesLessThan(int[] array, + int valueOfMax) + +
+           
+static int[]indicesLessThanOrEqualTo(float[] array, + float valueOfMax) + +
+           
+static int[]indicesLessThanOrEqualTo(int[] array, + int valueOfMax) + +
+           
+static int[]indicesWith(boolean[] array, + boolean valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(boolean[] array, + boolean valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(byte[] array, + byte valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(byte[] array, + byte valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(char[] array, + char valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(char[] array, + char valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(double[] array, + double valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(double[] array, + double valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(float[] array, + float valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(float[] array, + float valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(int[] array, + int valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(int[] array, + int valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(long[] array, + long valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(long[] array, + long valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(Object[] array, + Object objectToFind) + +
+          Finds the indices containing the specified object in the array.
+static int[]indicesWith(Object[] array, + Object objectToFind, + int startIndex) + +
+          Finds the indices containing the specified object in the array.
+static int[]indicesWith(short[] array, + short valueToFind) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWith(short[] array, + short valueToFind, + int startIndex) + +
+          Finds the indices containing the specified value in the array.
+static int[]indicesWithin(float[] array, + float minVal, + float maxVal) + +
+          Finds the indices for the array elements within the min and max value (inclusive).
+static int[]indicesWithin(int[] array, + float minVal, + float maxVal) + +
+          Finds the indices for the array elements within the min and max value (inclusive).
+static intlastIndexOf(boolean[] array, + boolean valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(boolean[] array, + boolean valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(byte[] array, + byte valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(byte[] array, + byte valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(char[] array, + char valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(char[] array, + char valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(double[] array, + double valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(double[] array, + double valueToFind, + double tolerance) + +
+          Finds the last index of the given value within a given tolerance in the array.
+static intlastIndexOf(double[] array, + double valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(double[] array, + double valueToFind, + int startIndex, + double tolerance) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(float[] array, + float valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(float[] array, + float valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(int[] array, + int valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(int[] array, + int valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(long[] array, + long valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(long[] array, + long valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intlastIndexOf(Object[] array, + Object objectToFind) + +
+          Finds the last index of the given object within the array.
+static intlastIndexOf(Object[] array, + Object objectToFind, + int startIndex) + +
+          Finds the last index of the given object in the array starting at the given index.
+static intlastIndexOf(short[] array, + short valueToFind) + +
+          Finds the last index of the given value within the array.
+static intlastIndexOf(short[] array, + short valueToFind, + int startIndex) + +
+          Finds the last index of the given value in the array starting at the given index.
+static intnumGreaterThan(float[] array, + float valueOfMin) + +
+          Finds the number of elements strictly greater than the specified value.
+static intnumGreaterThan(int[] array, + int valueOfMin) + +
+          Finds the number of elements strictly greater than the specified value.
+static intnumGreaterThanOrEqualTo(float[] array, + float valueOfMin) + +
+          Finds the number of elements greater than or equal to the specified value.
+static intnumGreaterThanOrEqualTo(int[] array, + int valueOfMin) + +
+          Finds the number of elements greater than or equal to the specified value.
+static intnumLessThan(float[] array, + float valueOfMax) + +
+          Finds the number of elements strictly less than the specified value.
+static intnumLessThan(int[] array, + int valueOfMax) + +
+          Finds the number of elements strictly less than the specified value.
+static intnumLessThanOrEqualTo(float[] array, + float valueOfMax) + +
+          Finds the number of elements less than or equal to the specified value.
+static intnumLessThanOrEqualTo(int[] array, + int valueOfMax) + +
+          Finds the number of elements less than or equal to the specified value.
+static intnumRepeats(boolean[] array, + boolean valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(byte[] array, + byte valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(char[] array, + char valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(double[] array, + double valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(float[] array, + float valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(int[] array, + int valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(long[] array, + long valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(Object[] array, + Object objectToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static intnumRepeats(short[] array, + short valueToFind) + +
+          Finds the number of times a given value/object is present in an array.
+static float[]uniqueElems(float[] array) + +
+          Find the unique elements in a float array (uses HashSets)
+static int[]uniqueElems(int[] array) + +
+          Find the unique elements in a int array (uses HashSets)
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+indexOf

+
+public static int indexOf(Object[] array,
+                          Object objectToFind)
+
+

Finds the index of the given object in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
objectToFind - the object to find, may be null +
Returns:
the index of the object within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(Object[] array,
+                          Object objectToFind,
+                          int startIndex)
+
+

Finds the index of the given object in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
objectToFind - the object to find, may be null
startIndex - the index to start searching at +
Returns:
the index of the object within the array starting at the index, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(Object[] array,
+                              Object objectToFind)
+
+

Finds the last index of the given object within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
objectToFind - the object to find, may be null +
Returns:
the last index of the object within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(Object[] array,
+                              Object objectToFind,
+                              int startIndex)
+
+

Finds the last index of the given object in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than + the array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
objectToFind - the object to find, may be null
startIndex - the start index to travers backwards from +
Returns:
the last index of the object within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(Object[] array,
+                               Object objectToFind)
+
+

Checks if the object is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
objectToFind - the object to find +
Returns:
true if the array contains the object
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(Object[] array,
+                                Object objectToFind)
+
+

Finds the indices containing the specified object in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object to find, may be null
objectToFind - the object to find +
Returns:
the indices containing the object within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(Object[] array,
+                                Object objectToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified object in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object to find, may be null
objectToFind - the object to find
startIndex - the index to start searching at +
Returns:
the indices containing the object within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(Object[] array,
+                             Object objectToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
objectToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(long[] array,
+                          long valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(long[] array,
+                          long valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(long[] array,
+                              long valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(long[] array,
+                              long valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(long[] array,
+                               long valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(long[] array,
+                                long valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(long[] array,
+                                long valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(long[] array,
+                             long valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(int[] array,
+                          int valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(int[] array,
+                          int valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(int[] array,
+                              int valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(int[] array,
+                              int valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(int[] array,
+                               int valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(int[] array,
+                                int valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(int[] array,
+                                int valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWithin

+
+public static int[] indicesWithin(int[] array,
+                                  float minVal,
+                                  float maxVal)
+
+

Finds the indices for the array elements within the min and max value (inclusive).

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
+
+
+
+ +

+indicesLessThanOrEqualTo

+
+public static int[] indicesLessThanOrEqualTo(int[] array,
+                                             int valueOfMax)
+
+
+
+
+
+
+
+
+
+ +

+indicesLessThan

+
+public static int[] indicesLessThan(int[] array,
+                                    int valueOfMax)
+
+
+
+
+
+
+
+
+
+ +

+indicesGreaterThanOrEqualTo

+
+public static int[] indicesGreaterThanOrEqualTo(int[] array,
+                                                int valueOfMin)
+
+
+
+
+
+
+
+
+
+ +

+indicesGreaterThan

+
+public static int[] indicesGreaterThan(int[] array,
+                                       int valueOfMin)
+
+
+
+
+
+
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(int[] array,
+                             int valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+numLessThanOrEqualTo

+
+public static int numLessThanOrEqualTo(int[] array,
+                                       int valueOfMax)
+
+

Finds the number of elements less than or equal to the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements ? that value
+
+
+
+ +

+numLessThan

+
+public static int numLessThan(int[] array,
+                              int valueOfMax)
+
+

Finds the number of elements strictly less than the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements strictly less than that value
+
+
+
+ +

+numGreaterThanOrEqualTo

+
+public static int numGreaterThanOrEqualTo(int[] array,
+                                          int valueOfMin)
+
+

Finds the number of elements greater than or equal to the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements ? that value
+
+
+
+ +

+numGreaterThan

+
+public static int numGreaterThan(int[] array,
+                                 int valueOfMin)
+
+

Finds the number of elements strictly greater than the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements strictly greater than that value
+
+
+
+ +

+uniqueElems

+
+public static int[] uniqueElems(int[] array)
+
+
Find the unique elements in a int array (uses HashSets) +

+

+
+
+
+
+
+
+
+ +

+indexOf

+
+public static int indexOf(short[] array,
+                          short valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(short[] array,
+                          short valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(short[] array,
+                              short valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(short[] array,
+                              short valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(short[] array,
+                               short valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(short[] array,
+                                short valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(short[] array,
+                                short valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(short[] array,
+                             short valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(char[] array,
+                          char valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
+
2.1
+
+
+
+
+ +

+indexOf

+
+public static int indexOf(char[] array,
+                          char valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
+
2.1
+
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(char[] array,
+                              char valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
+
2.1
+
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(char[] array,
+                              char valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
Since:
+
2.1
+
+
+
+
+ +

+contains

+
+public static boolean contains(char[] array,
+                               char valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
Since:
+
2.1
+
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(char[] array,
+                                char valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(char[] array,
+                                char valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(char[] array,
+                             char valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(byte[] array,
+                          byte valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(byte[] array,
+                          byte valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(byte[] array,
+                              byte valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(byte[] array,
+                              byte valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(byte[] array,
+                               byte valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(byte[] array,
+                                byte valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(byte[] array,
+                                byte valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(byte[] array,
+                             byte valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(double[] array,
+                          double valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(double[] array,
+                          double valueToFind,
+                          double tolerance)
+
+

Finds the index of the given value within a given tolerance in the array. + This method will return the index of the first value which falls between the region + defined by valueToFind - tolerance and valueToFind + tolerance.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
tolerance - tolerance of the search +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(double[] array,
+                          double valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(double[] array,
+                          double valueToFind,
+                          int startIndex,
+                          double tolerance)
+
+

Finds the index of the given value in the array starting at the given index. + This method will return the index of the first value which falls between the region + defined by valueToFind - tolerance and valueToFind + tolerance.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at
tolerance - tolerance of the search +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(double[] array,
+                              double valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(double[] array,
+                              double valueToFind,
+                              double tolerance)
+
+

Finds the last index of the given value within a given tolerance in the array. + This method will return the index of the last value which falls between the region + defined by valueToFind - tolerance and valueToFind + tolerance.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
tolerance - tolerance of the search +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(double[] array,
+                              double valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(double[] array,
+                              double valueToFind,
+                              int startIndex,
+                              double tolerance)
+
+

Finds the last index of the given value in the array starting at the given index. + This method will return the index of the last value which falls between the region + defined by valueToFind - tolerance and valueToFind + tolerance.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from
tolerance - search for value within plus/minus this amount +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(double[] array,
+                               double valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
+
+
+
+ +

+contains

+
+public static boolean contains(double[] array,
+                               double valueToFind,
+                               double tolerance)
+
+

Checks if a value falling within the given tolerance is in the + given array. If the array contains a value within the inclusive range + defined by (value - tolerance) to (value + tolerance).

+ +

The method returns false if a null array + is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search
valueToFind - the value to find
tolerance - the array contains the tolerance of the search +
Returns:
true if value falling within tolerance is in array
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(double[] array,
+                                double valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(double[] array,
+                                double valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(double[] array,
+                             double valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(float[] array,
+                          float valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(float[] array,
+                          float valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(float[] array,
+                              float valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(float[] array,
+                              float valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than the + array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+contains

+
+public static boolean contains(float[] array,
+                               float valueToFind)
+
+

Checks if the value is in the given array.

+ +

The method returns false if a null array is passed in.

+

+

+
+
+
+
Parameters:
array - the array to search through
valueToFind - the value to find +
Returns:
true if the array contains the object
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(float[] array,
+                                float valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(float[] array,
+                                float valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWithin

+
+public static int[] indicesWithin(float[] array,
+                                  float minVal,
+                                  float maxVal)
+
+

Finds the indices for the array elements within the min and max value (inclusive).

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(float[] array,
+                             float valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indicesLessThanOrEqualTo

+
+public static int[] indicesLessThanOrEqualTo(float[] array,
+                                             float valueOfMax)
+
+
+
+
+
+
+
+
+
+ +

+indicesLessThan

+
+public static int[] indicesLessThan(float[] array,
+                                    float valueOfMax)
+
+
+
+
+
+
+
+
+
+ +

+indicesGreaterThanOrEqualTo

+
+public static int[] indicesGreaterThanOrEqualTo(float[] array,
+                                                float valueOfMin)
+
+
+
+
+
+
+
+
+
+ +

+indicesGreaterThan

+
+public static int[] indicesGreaterThan(float[] array,
+                                       float valueOfMin)
+
+
+
+
+
+
+
+
+
+ +

+numLessThanOrEqualTo

+
+public static int numLessThanOrEqualTo(float[] array,
+                                       float valueOfMax)
+
+

Finds the number of elements less than or equal to the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements ? that value
+
+
+
+ +

+numLessThan

+
+public static int numLessThan(float[] array,
+                              float valueOfMax)
+
+

Finds the number of elements strictly less than the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements strictly less than that value
+
+
+
+ +

+numGreaterThanOrEqualTo

+
+public static int numGreaterThanOrEqualTo(float[] array,
+                                          float valueOfMin)
+
+

Finds the number of elements greater than or equal to the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements ? that value
+
+
+
+ +

+numGreaterThan

+
+public static int numGreaterThan(float[] array,
+                                 float valueOfMin)
+
+

Finds the number of elements strictly greater than the specified value.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueOfMax - the maximum value +
Returns:
the number of elements strictly greater than that value
+
+
+
+ +

+uniqueElems

+
+public static float[] uniqueElems(float[] array)
+
+
Find the unique elements in a float array (uses HashSets) +

+

+
+
+
+
+
+
+
+ +

+indexOf

+
+public static int indexOf(boolean[] array,
+                          boolean valueToFind)
+
+

Finds the index of the given value in the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indexOf

+
+public static int indexOf(boolean[] array,
+                          boolean valueToFind,
+                          int startIndex)
+
+

Finds the index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex is treated as zero. A startIndex larger than the array + length will return PapayaConstants.INDEX_NOT_FOUND (-1).

+

+

+
+
+
+
Parameters:
array - the array to search through for the object, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null + array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(boolean[] array,
+                              boolean valueToFind)
+
+

Finds the last index of the given value within the array.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) if + null array input.

+

+

+
+
+
+
Parameters:
array - the array to travers backwords looking for the object, may be null
valueToFind - the object to find +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+lastIndexOf

+
+public static int lastIndexOf(boolean[] array,
+                              boolean valueToFind,
+                              int startIndex)
+
+

Finds the last index of the given value in the array starting at the given index.

+ +

This method returns PapayaConstants.INDEX_NOT_FOUND (-1) for a null input array.

+ +

A negative startIndex will return PapayaConstants.INDEX_NOT_FOUND (-1). A startIndex larger than + the array length will search from the end of the array.

+

+

+
+
+
+
Parameters:
array - the array to traverse for looking for the object, may be null
valueToFind - the value to find
startIndex - the start index to travers backwards from +
Returns:
the last index of the value within the array, + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(boolean[] array,
+                                boolean valueToFind)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+indicesWith

+
+public static int[] indicesWith(boolean[] array,
+                                boolean valueToFind,
+                                int startIndex)
+
+

Finds the indices containing the specified value in the array.

+ +

This method returns PapayaConstants.INDICES_NOT_FOUND (int[] = -1) for a null input array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value to find, may be null
valueToFind - the value to find
startIndex - the index to start searching at +
Returns:
the indices containing the value within the array, + PapayaConstants.INDICES_NOT_FOUND (int[] = -1) if not found or null array input
+
+
+
+ +

+numRepeats

+
+public static int numRepeats(boolean[] array,
+                             boolean valueToFind)
+
+

Finds the number of times a given value/object is present in an array.

+

+

+
+
+
+
Parameters:
array - the array to search through for the value/object
valueToFind - the object to find. +
Returns:
the number of times that value/object appears in the array + PapayaConstants.INDEX_NOT_FOUND (-1) if not found or null array input
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Frequency.html b/drawing/papaya/reference/papaya/Frequency.html new file mode 100644 index 0000000..141f54d --- /dev/null +++ b/drawing/papaya/reference/papaya/Frequency.html @@ -0,0 +1,502 @@ + + + + + + +Frequency (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Frequency

+
+java.lang.Object
+  extended by papaya.Frequency
+
+
+
+
public class Frequency
extends Object
+ + +

+Class for getting the frequency distribution, cumulative frequency distribution, and other + distribution-related parameters of a given array of floats or ints. + To initialize, use something like this: +

+ Frequency freq= new Frequency(dataArray, minimumVal,maximumVal,widthOfEachBin); + + Once initialized, it stores 3 things: +

    +
  • The array containing the number of elements in each of the histogram bins (getFrequency()). +
  • The number of bins. +
  • The length of the full data array. +
+ +

A number of different methods are available for computing other distribution-related parameters + (e.g. the relative frequency distribution, the cumulative frequency distribution, etc).

+ +

See the FrequencyExample in the examples folder for an example.

+

+ +

+

+
Author:
+
Adila Faruk
+
+
+ +

+ + + + + + + + + + + + + + +
+Constructor Summary
Frequency(float[] _inputDat, + float _minVal, + float _maxVal, + float _binWidth) + +
+          Initialize the class by setting the minimum value, maximum value, and the bin width.
Frequency(int[] _inputDat, + int _minVal, + int _maxVal, + int _binWidth) + +
+          Initialize the class by setting the minimum value, maximum value, and the bin width.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ float[]compCumFrequency() + +
+          Computes the cumulative frequency of the data.
+ float[]compRelCumFrequency() + +
+          Computes the cumulative relative frequency of the data.
+ float[]compRelCumFrequencyPct() + +
+          Computes the cumulative frequency of the data as a percentage.
+ float[]compRelFrequency() + +
+          Computes the fraction of the total data that's in each bin.
+ float[]compRelFrequencyPct() + +
+          Computes the percents of the total data that's in each bin.
+ float[]getFrequency() + +
+          Returns the pre-computed frequency array.
+ intgetLength() + +
+          returns the length of the dataset.
+ intgetNumBins() + +
+          Returns the number of bins.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Frequency

+
+public Frequency(float[] _inputDat,
+                 float _minVal,
+                 float _maxVal,
+                 float _binWidth)
+
+
Initialize the class by setting the minimum value, maximum value, and the bin width. + Upon initialization, the number of bins are determined and the + frequency distribution array is computed for the given input data and histogram bin width. + This frequency distribution can be accessed using the getFrequency() function. + Note that this is the only place where you can set the frequency distribution. + +

How is the number of bins computed? +
Like this: +
bins = floor[ (max - min) / binWidth ] +1 ,
+ as opposed to ceil[ (max - min) / binWidth ]. + Why? The latter algorithm is problematic when [ (max - min) / binWidth ] + is a whole number. + E.g. let min = 0.0, max = 100.0, and binWidth = 10.0. We get 10 bins with +

    +
  • 1st bin = bin[0] --> contains elements 0.0 - 9.999... +
  • 2nd bin = bin[1] --> contains elements 10.0 - 19.999... +
  • ... +
  • ... +
  • 10th bin = bin[9] --> contains elements 90.0-99.999... +
+ Poor 100. He's got nowhere to go but into an Array Index out of bound Exception! +

+

What element goes into what bin? +
Let value = data[i]; +
value will go into bin number floor( (_inputDat[i]-_minVal)/_binWidth ); +

+

+

+
Parameters:
_inputDat - the input data
_minVal - the minimum value in the array
_maxVal - the maximum value in the array
_binWidth - the width of each of the bins
+
+
+ +

+Frequency

+
+public Frequency(int[] _inputDat,
+                 int _minVal,
+                 int _maxVal,
+                 int _binWidth)
+
+
Initialize the class by setting the minimum value, maximum value, and the bin width. + Upon initialization, the number of bins are determined and the + frequency distribution array is computed for the given input data and histogram bin width. + This frequency distribution can be accessed using the getFrequency() function. + Note that this is the only place where you can set the frequency distribution. + +

See Frequency(float[] _inputDat, float _minVal, float _maxVal, float _binWidth) for + more details. +

+

+

+ + + + + + + + +
+Method Detail
+ +

+compRelFrequency

+
+public float[] compRelFrequency()
+
+
Computes the fraction of the total data that's in each bin. + This is similar to dividing the number in each bin by the total + number of elements in the data array. +

+

+
+
+
+
+ +

+compRelFrequencyPct

+
+public float[] compRelFrequencyPct()
+
+
Computes the percents of the total data that's in each bin. + This isimilar to dividing the number in each bin by the total + number of elements in the data array x 100% +

+

+
+
+
+
+ +

+compCumFrequency

+
+public float[] compCumFrequency()
+
+
Computes the cumulative frequency of the data. +

+

+
+
+
+
+ +

+compRelCumFrequency

+
+public float[] compRelCumFrequency()
+
+
Computes the cumulative relative frequency of the data. + This is similar to dividing the number in each bin of + the cumulative frequency array (compCumFrequency()) by + the number of elements in the data array. +

+

+
+
+
+
+ +

+compRelCumFrequencyPct

+
+public float[] compRelCumFrequencyPct()
+
+
Computes the cumulative frequency of the data as a percentage. + This is similar to dividing the number in each bin of + the cumulative frequency array (compCumFrequency()) by + the number of elements in the data array x 100%. +

+

+
+
+
+
+ +

+getFrequency

+
+public float[] getFrequency()
+
+
Returns the pre-computed frequency array. + An array of floats so division won't cause any surprises. +

+

+
+
+
+
+ +

+getNumBins

+
+public int getNumBins()
+
+
Returns the number of bins. +

+

+
+
+
+
+ +

+getLength

+
+public int getLength()
+
+
returns the length of the dataset. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Gamma.html b/drawing/papaya/reference/papaya/Gamma.html new file mode 100644 index 0000000..2d08a2e --- /dev/null +++ b/drawing/papaya/reference/papaya/Gamma.html @@ -0,0 +1,449 @@ + + + + + + +Gamma (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Gamma

+
+java.lang.Object
+  extended by papaya.Gamma
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class Gamma
extends Object
implements PapayaConstants
+ + +

+Gamma and Beta functions. +

+ Implementation: + The code is mostly adapted from the CERN + Jet Java libraries, which in turn was adapted from the Cephes Mathematical Library. As far a + as I can tell, Stephen L. Moshier wrote the original C++ code for CEPHES (1989, moshier@na-net.ornl.gov) + and Wolfgang Hoschek (at CERN, hats off to you mate!) then adapted it for the + Java platform, making some significant changes along the way. +
+

+ +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatbeta(double a, + double b) + +
+          Returns the beta function of the arguments.
+static doublegamma(double x) + +
+          Returns the Gamma function of the argument, Γ(x)
+static doubleincompleteBeta(double aa, + double bb, + double xx) + +
+          Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta.
+static doubleincompleteBetaInverse(double aa, + double bb, + double yy0) + +
+          Returns the inverse of the incomplete Beta integral.
+static doubleincompleteGamma(double a, + double x) + +
+          Returns the Incomplete Gamma function; formerly named igamma.
+static doubleincompleteGammaComplement(double a, + double x) + +
+          Returns the Complemented Incomplete Gamma function; formerly named igamc.
+static doublelogGamma(double x) + +
+          Returns the natural logarithm of the gamma function; formerly named lgamma.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+beta

+
+public static float beta(double a,
+                         double b)
+                  throws ArithmeticException
+
+
Returns the beta function of the arguments. +
+ 
+ beta( a, b )  = Γ(a) * Γ(b) ) Γ(a+b)
+
+ 
+

+

+
+
+
+ +
Throws: +
ArithmeticException
+
+
+
+ +

+gamma

+
+public static double gamma(double x)
+                    throws ArithmeticException
+
+
Returns the Gamma function of the argument, Γ(x) +

+

+
+
+
+ +
Throws: +
ArithmeticException
+
+
+
+ +

+incompleteBeta

+
+public static double incompleteBeta(double aa,
+                                    double bb,
+                                    double xx)
+                             throws ArithmeticException
+
+
Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta. +

+

+
+
+
+
Parameters:
aa - the alpha parameter of the beta distribution.
bb - the beta parameter of the beta distribution.
xx - the integration end point. +
Throws: +
ArithmeticException
+
+
+
+ +

+incompleteBetaInverse

+
+public static double incompleteBetaInverse(double aa,
+                                           double bb,
+                                           double yy0)
+
+
Returns the inverse of the incomplete Beta integral. + That is, given y, the function finds x such that +
+  incompleteBeta( a, b, x ) = y.
+
+ The routine performs interval halving until incompleteBeta(a,b,x) - y = 0, + to within roughly 10^-13 of the true solution. If this precision is not reached, the + method returns the current approximation of x, and prints a warning statement + specifying the current error. Typically, this is on the order of 10^-12. +

+

+
+
+
+
Parameters:
aa - the alpha parameter of the beta distribution.
bb - the beta parameter of the beta distribution.
yy0 - the value for which to solve for the corresponding x in the + incomplete Beta integral. +
Returns:
the value x such that incompleteBeta( a, b, x ) = y.
+
+
+
+ +

+incompleteGamma

+
+public static double incompleteGamma(double a,
+                                     double x)
+                              throws ArithmeticException
+
+
Returns the Incomplete Gamma function; formerly named igamma. +

+

+
+
+
+
Parameters:
a - the parameter of the gamma distribution.
x - the integration end point. +
Throws: +
ArithmeticException
+
+
+
+ +

+incompleteGammaComplement

+
+public static double incompleteGammaComplement(double a,
+                                               double x)
+                                        throws ArithmeticException
+
+
Returns the Complemented Incomplete Gamma function; formerly named igamc. +

+

+
+
+
+
Parameters:
a - the parameter of the gamma distribution.
x - the integration start point. +
Throws: +
ArithmeticException
+
+
+
+ +

+logGamma

+
+public static double logGamma(double x)
+                       throws ArithmeticException
+
+
Returns the natural logarithm of the gamma function; formerly named lgamma. +

+

+
+
+
+ +
Throws: +
ArithmeticException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/LU.html b/drawing/papaya/reference/papaya/LU.html new file mode 100644 index 0000000..da77217 --- /dev/null +++ b/drawing/papaya/reference/papaya/LU.html @@ -0,0 +1,449 @@ + + + + + + +LU (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class LU

+
+java.lang.Object
+  extended by papaya.LU
+
+
+
+
public class LU
extends Object
+ + +

+LU Decomposition. +

+For an m x n matrix A with m > n, the LU decomposition is an m x n +unit lower triangular matrix L, an n x n upper triangular matrix U, +and a permutation vector piv of length m so that A(piv,:) = L*U; +If m < n, then L is m x m and U is m x n. +

+The LU decomposition with pivoting always exists, even if the matrix is +singular, so the constructor will never fail. The primary use of the +LU decomposition is in the solution of square systems of simultaneous +linear equations. This will fail if isNonsingular() returns false. +

+Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +Cast.doubleToFloat(double[][]) if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
LU(float[][] A) + +
+          Constructor.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ doubledet() + +
+          Determinant
+ float[]getFloatPivot() + +
+          Return pivot permutation vector as a one-dimensional float array
+ double[][]getL() + +
+          Return lower triangular factor, L.
+ int[]getPivot() + +
+          Return pivot permutation vector
+ double[][]getU() + +
+          Return upper triangular factor, U
+ booleanisNonsingular() + +
+          Is the matrix nonsingular?
+ double[][]solve(float[][] B) + +
+          Solve A*X = B
+ double[]solve(float[] b, + boolean returnZeroesForSingularCase) + +
+          Solve A*x = b for x
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+LU

+
+public LU(float[][] A)
+
+
Constructor. Takes in a matrix and computes the LU matrix. Additional + parameters can be obtained by calling one of the available methods. +

+

+
See Also:
getL(), +getU(), +getPivot(), +getFloatPivot(), +det()
+
+ + + + + + + + +
+Method Detail
+ +

+isNonsingular

+
+public boolean isNonsingular()
+
+
Is the matrix nonsingular? +

+

+ +
Returns:
true if U, and hence A, is nonsingular.
+
+
+
+ +

+getL

+
+public double[][] getL()
+
+
Return lower triangular factor, L. +

+

+
+
+
+
+ +

+getU

+
+public double[][] getU()
+
+
Return upper triangular factor, U +

+

+
+
+
+
+ +

+getPivot

+
+public int[] getPivot()
+
+
Return pivot permutation vector +

+

+ +
Returns:
piv
+
+
+
+ +

+getFloatPivot

+
+public float[] getFloatPivot()
+
+
Return pivot permutation vector as a one-dimensional float array +

+

+ +
Returns:
piv
+
+
+
+ +

+det

+
+public double det()
+
+
Determinant +

+

+ +
Returns:
det(A) +
Throws: +
IllegalArgumentException - Matrix must be square
+
+
+
+ +

+solve

+
+public double[] solve(float[] b,
+                      boolean returnZeroesForSingularCase)
+
+
Solve A*x = b for x +

+

+
Parameters:
b - An array with as many elements as the number of rows in A. +
Returns:
x so that L*U*x = b(piv,:) +
Throws: +
IllegalArgumentException - Matrix row dimensions must agree. +
RuntimeException - Matrix is singular.
+
+
+
+ +

+solve

+
+public double[][] solve(float[][] B)
+
+
Solve A*X = B +

+

+
Parameters:
B - A Matrix with as many rows as A and any number of columns. +
Returns:
X so that L*U*X = B(piv,:) +
Throws: +
IllegalArgumentException - Matrix row dimensions must agree. +
RuntimeException - Matrix is singular.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Linear.BoxCox.html b/drawing/papaya/reference/papaya/Linear.BoxCox.html new file mode 100644 index 0000000..bdb3d05 --- /dev/null +++ b/drawing/papaya/reference/papaya/Linear.BoxCox.html @@ -0,0 +1,285 @@ + + + + + + +Linear.BoxCox (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Linear.BoxCox

+
+java.lang.Object
+  extended by papaya.Linear.BoxCox
+
+
+
Enclosing class:
Linear
+
+
+
+
public static class Linear.BoxCox
extends Object
+ + +

+Contains methods related to the Box-Cox transformation of a data set; useful in + determining the best transformation that will yield the best method for converting + a monotonic, non-linear relationship between x and y into + a linear one. +

Reference: +
Box, George E. P.; Cox, D. R. (1964). "An analysis of transformations". + Journal of the Royal Statistical Society, Series B 26 (2): 211?252. +
+ NIST/SEMATECH e-Handbook of Statistical Methods, EDA Section 1.3.3.6: Box-Cox Linearity Plots + (The reader's digest version of the original.) +

+ +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+static float[]correlation(float[] x, + float[] y, + float[] lambda) + +
+          Performs the box-cox transformation on y for a sequence of λ + and returns the array of linear correlation coefficients + between the x and the box-cox transformed y.
+static float[]transform(float[] data, + float lambda) + +
+          Performs the box-cox transformation, returning the transformed data.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+correlation

+
+public static float[] correlation(float[] x,
+                                  float[] y,
+                                  float[] lambda)
+
+
Performs the box-cox transformation on y for a sequence of λ + and returns the array of linear correlation coefficients + between the x and the box-cox transformed y. + at each value of λ . + The value of λ corresponding to the maximum correlation + (or minimum for negative correlation) is the optimal choice for + λ such that the relationship between x and T(y) is linear. +

Reference: +
+ NIST/SEMATECH e-Handbook of Statistical Methods, EDA Section 1.3.3.6: Box-Cox Linearity Plots +

+

+
Parameters:
x - the independent data array
y - the dependent data array
lambda - an array of lambda values +
Returns:
the array containing the linear correlation coefficients, r.
+
+
+
+ +

+transform

+
+public static float[] transform(float[] data,
+                                float lambda)
+
+
Performs the box-cox transformation, returning the transformed data. + That is, it computes and returns +
+ y[i](λ) = (y[i]^λ-1) / λ if λ ≠ 0
+ 
+ y[i](λ) = log(y[i])if λ = 0
+ 
+ Requirements: all elements of y are >0. +

+

+
Parameters:
data - the data to be transformed
lambda - the lambda value +
Returns:
the transformed data, or y(λ) above.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Linear.Significance.html b/drawing/papaya/reference/papaya/Linear.Significance.html new file mode 100644 index 0000000..2f8a36f --- /dev/null +++ b/drawing/papaya/reference/papaya/Linear.Significance.html @@ -0,0 +1,302 @@ + + + + + + +Linear.Significance (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Linear.Significance

+
+java.lang.Object
+  extended by papaya.Linear.Significance
+
+
+
Enclosing class:
Linear
+
+
+
+
public static class Linear.Significance
extends Object
+ + +

+Contains methods used to compute the significance, or pvalue of the input correlations. + The significance is computed using the normal of student-t approximations and hence are + not to be used for small datasets(i.e. size<20). +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
Linear.Significance() + +
+           
+  + + + + + + + + + + + + + + + +
+Method Summary
+static floatintercept(float intercept, + float interceptStdErr, + int df) + +
+          Returns the p-value, or significance, of the computed intercept under the null-hypothesis + of intercept = 0 (two-tailed test).
+static floatslope(float slope, + float slopeStdErr, + int df) + +
+          Returns the p-value, or significance, of the computed slope under the null-hypothesis + of slope = 0 (two-tailed test).
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Linear.Significance

+
+public Linear.Significance()
+
+
+ + + + + + + + +
+Method Detail
+ +

+slope

+
+public static float slope(float slope,
+                          float slopeStdErr,
+                          int df)
+
+
Returns the p-value, or significance, of the computed slope under the null-hypothesis + of slope = 0 (two-tailed test). The p-value is computed using the student-T distribution + with df degrees of freedom and test statistic +
 t = slope/slopeStdErr,
+

+

+
Parameters:
slope - the slope of the best fit linear line
slopeStdErr - the standard error of the slope
df - the degrees of freedom (typically (n-2), but could also be (n-1) if the + intercept was previously specified.
+
+
+
+ +

+intercept

+
+public static float intercept(float intercept,
+                              float interceptStdErr,
+                              int df)
+
+
Returns the p-value, or significance, of the computed intercept under the null-hypothesis + of intercept = 0 (two-tailed test). The p-value is computed using the student-T distribution + with df degrees of freedom and test statistic +
t=intercept/interceptStdErr
+

+

+
Parameters:
intercept - the intercept of the best fit linear line
interceptStdErr - the standard error of the intercept
df - the degrees of freedom (n-2)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Linear.StdErr.html b/drawing/papaya/reference/papaya/Linear.StdErr.html new file mode 100644 index 0000000..0d5bde2 --- /dev/null +++ b/drawing/papaya/reference/papaya/Linear.StdErr.html @@ -0,0 +1,299 @@ + + + + + + +Linear.StdErr (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Linear.StdErr

+
+java.lang.Object
+  extended by papaya.Linear.StdErr
+
+
+
Enclosing class:
Linear
+
+
+
+
public static class Linear.StdErr
extends Object
+ + +

+Contains methods related to computing the standard errors of the residuals, slope and intercept + associated with the best-fit linear line. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static floatintercept(float[] x, + float residualStdErr) + +
+          Returns the standard error of the computed slope given x and the + standard error in the residuals.
+static floatresidual(float[] residuals, + int df) + +
+          Returns the standard error of the residuals given the degrees of freedom.
+static floatslope(float[] x, + float residualStdErr) + +
+          Returns the standard error of the computed slope given x and the + standard error in the residuals.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+residual

+
+public static float residual(float[] residuals,
+                             int df)
+
+
Returns the standard error of the residuals given the degrees of freedom. + That is, +
+ residualStdErr = Sqrt ( Sum( (delta[i] - mean(delta))^2 ) / df )
+ 
+ where df is the degrees of freedom ( (n-1) if the y-intercept was pre-specified in the + best-fit line, (n-2) if neither slope nor intercept were specified.) +

+

+
Parameters:
residuals -
df - +
Returns:
standard error of the residual
+
+
+
+ +

+slope

+
+public static float slope(float[] x,
+                          float residualStdErr)
+
+
Returns the standard error of the computed slope given x and the + standard error in the residuals. That is, +
+ slopeStdErr = residualStdErr / Sum ( (x[i] - mean(x))^2 ).
+ 
+

+

+
Parameters:
x - the independent variable
residualStdErr - the standard error of the residual +
Returns:
the error in the slope.
+
+
+
+ +

+intercept

+
+public static float intercept(float[] x,
+                              float residualStdErr)
+
+
Returns the standard error of the computed slope given x and the + standard error in the residuals. That is, +
+ interceptStdErr = slopeStdErr / Sqrt( Sum(x[i]*x[i])/size ).
+ 
+ where the slopeStdErr is computed using the methods specified + in slope(float[], float). +

+

+
Parameters:
x - the independent variable
residualStdErr - the standard error of the residual +
Returns:
error in the slope.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Linear.html b/drawing/papaya/reference/papaya/Linear.html new file mode 100644 index 0000000..7ec2034 --- /dev/null +++ b/drawing/papaya/reference/papaya/Linear.html @@ -0,0 +1,433 @@ + + + + + + +Linear (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Linear

+
+java.lang.Object
+  extended by papaya.Linear
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class Linear
extends Object
implements PapayaConstants
+ + +

+Contains methods related to determining the linear linear + relationship between two datasets (of equal arrays) such as the + best-fit linear line parameters, box-cox transformations, etc. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + +
+Nested Class Summary
+static classLinear.BoxCox + +
+          Contains methods related to the Box-Cox transformation of a data set; useful in + determining the best transformation that will yield the best method for converting + a monotonic, non-linear relationship between x and y into + a linear one.
+static classLinear.Significance + +
+          Contains methods used to compute the significance, or pvalue of the input correlations.
+static classLinear.StdErr + +
+          Contains methods related to computing the standard errors of the residuals, slope and intercept + associated with the best-fit linear line.
+ + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
Linear() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[]bestFit(float[] x, + float[] y) + +
+          Returns the slope and y-intercept of the best fit linear line + z = slope*x + intercept by minimizing the sum of least squares + between z and the y.
+static floatbestFit(float[] x, + float[] y, + float intercept) + +
+          Returns the slope of the best fit linear line for the prescribed y-intercept.
+static float[]residuals(float[] x, + float[] y) + +
+          Compute and return the array of residuals given by + Delta_i = z_i - y_i, + where + z_i = (slope*x_i + intercept) is the best fit linear line.
+static float[]residuals(float[] x, + float[] y, + float slope, + float intercept) + +
+          Compute and return the array of residuals given by + Delta_i = z_i - y_i, + where + z_i = (slope*x_i + intercept) is the best fit linear line.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Linear

+
+public Linear()
+
+
+ + + + + + + + +
+Method Detail
+ +

+bestFit

+
+public static float[] bestFit(float[] x,
+                              float[] y)
+
+
Returns the slope and y-intercept of the best fit linear line + z = slope*x + intercept by minimizing the sum of least squares + between z and the y. +

+

+
+
+
+
Parameters:
x - the x data
y - the y data +
Returns:
a 2-by-1 array with the first element coeff[0]corresponding to + the slope, and the second element coeff[1] equal to the y-intercept.
+
+
+
+ +

+bestFit

+
+public static float bestFit(float[] x,
+                            float[] y,
+                            float intercept)
+
+
Returns the slope of the best fit linear line for the prescribed y-intercept. + That is, + z = slope*x + intercept, where the intercept is specified + by the user. E.g. intercept = 1 will result in z = slope*x+1. + The slope is computed by minimizing the sum of least squares + between z and the y. +

+

+
+
+
+
Parameters:
x - the x data
y - the y data
intercept - the intercept of the best-fit line with the y-axis. +
Returns:
the slope of the best-fit linear line.
+
+
+
+ +

+residuals

+
+public static float[] residuals(float[] x,
+                                float[] y,
+                                float slope,
+                                float intercept)
+
+
Compute and return the array of residuals given by + Delta_i = z_i - y_i, + where + z_i = (slope*x_i + intercept) is the best fit linear line. +

+

+
+
+
+
Parameters:
slope - the slope of the best-fit linear line
intercept - the y-intercept of the best fit linear line
+
+
+
+ +

+residuals

+
+public static float[] residuals(float[] x,
+                                float[] y)
+
+
Compute and return the array of residuals given by + Delta_i = z_i - y_i, + where + z_i = (slope*x_i + intercept) is the best fit linear line. + You'd basically use this to compute the spread of a best fit line (max - min) +

+

+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/MDS.html b/drawing/papaya/reference/papaya/MDS.html new file mode 100644 index 0000000..d9908be --- /dev/null +++ b/drawing/papaya/reference/papaya/MDS.html @@ -0,0 +1,253 @@ + + + + + + +MDS (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class MDS

+
+java.lang.Object
+  extended by papaya.MDS
+
+
+
+
public final class MDS
extends Object
+ + +

+Contains methods for performing but classical and non-classical multidimensional scaling. +

+ For an m-by-n input matrix with m observations and n variables, the output D is + the symmetric m-by-m matrix with zeros along the diagonals and element ij + specifying the distance between rows i and j. +

+ +

+


+ +

+ + + + + + + + + + + + +
+Method Summary
+static float[][]classical(float[][] D, + int p, + boolean showEigenvalues) + +
+          Performs classical (metric) multidimensional scaling, on an input matrix of Distances (computed + using e.g.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+classical

+
+public static float[][] classical(float[][] D,
+                                  int p,
+                                  boolean showEigenvalues)
+
+
Performs classical (metric) multidimensional scaling, on an input matrix of Distances (computed + using e.g. Distance ) and outputs the best-fitting p-dimensional configuration of points + (p<N). The output matrix Y has p columns with rows + giving the coordinates of the points chosen to represent the dissimilarities. + When D corresponds to the Euclidian distance matrix, the p + dimensional coordinates correspond exactly to the first p principal components. +

+ Remarks +

    +
  • If p > kwhere k is the number of + positive eigenvalues of Y*Y', then only the + first k columns of Y are computed. +
  • +
  • Set showEigenvalues to true to print the + values of the "scalar product matrix" Y*Y' to the screen. + (This is a good idea if you want to know how well the first p dimensions + captures most of the variation in D.
  • +
> +

+

+
Parameters:
D - the input distance matrix (see Distance)
p - the dimension (number of columns) of the output matrix.
showEigenvalues - whether to print the eigenvalues to the screen or otherwise. +
Returns:
Y, N-by-p (or N-by-k) matrix consisting of N points in each of the p (or k) dimensions.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Mat.html b/drawing/papaya/reference/papaya/Mat.html new file mode 100644 index 0000000..66a6207 --- /dev/null +++ b/drawing/papaya/reference/papaya/Mat.html @@ -0,0 +1,2622 @@ + + + + + + +Mat (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Mat

+
+java.lang.Object
+  extended by papaya.Mat
+
+
+
+
public final class Mat
extends Object
+ + +

+Static class for performing some basic matrix operations. +

+ Guidelines +
+ Methods that modify an array by a value always take the array as the first parameter, and + the value as the second. + For example, +

+ I try to follow that guiding principle with all methods that take in an input + array (e.g. swap(float[] array, int index1, int index2), + populate(float[] array, int[] indices)). +

+ Remarks +
+ Almost all the methods here take in float arrays or matrices, although I've also added in a few + methods that operate on integers. In addition, to avoid accidental array manipulation, + all methods return a new array or matrix instead of modifying the original one. E.g. +
C[i][j] = A[i][j]*B[i][j] return C +
as opposed to +
A[i][j] = A[i][j]*B[i][j], return A +
in dotMultiply(float[][],float[][]). + (If you find it performing to the contrary though, please let me know!) + +

+ Some non-trivial matrix-math related methods, including those for getting + the condition number, inverse, rank, and norms of a 2D input matrix are also included. + Making everything float-based instead of double-based naturally results in some precision loss but + the internal computations are done using doubles to minimize this. + +

+

+ +

+

+
See Also:
Cast, +Find, +NaNs, +Rank, +Sorting
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[]abs(float[] array) + +
+          Return absolute values of an array
+static int[]abs(int[] array) + +
+          Return absolute values of an array
+static floatceilToNearest(float currentVal, + int interval) + +
+          Function for ceiling a number to the closest interval.
+static float[]column(float[][] inputMat, + int columnIndex) + +
+          Function to get one column of a 2D matrix
+static float[][]column(float[][] inputMat, + int indexStart, + int indexEnd) + +
+          Function to get columns of a 2-D matrix.
+static int[]column(int[][] inputMat, + int columnIndex) + +
+           
+static floatcompare(float a, + float b) + +
+          Returns -1 if a is less than b, or 1 if a is greater than b, or 0.
+static intcompare(int a, + int b) + +
+          Returns -1 if a is less than b, or 1 if a is greater than b, or 0.
+static float[]concat(float[] a, + float[] b) + +
+          Concatenates two arrays a and b into a new array + c such that c = {a,b}.
+static int[]concat(int[] a, + int[] b) + +
+           
+static float[]constant(float constValue, + int size) + +
+          Returns an array with of length size with + each element equal to the specified constValue.
+static int[]constant(int constValue, + int size) + +
+          Returns an array with of length size with + each element equal to the specified constValue.
+static float[][]copy(float[][] data) + +
+          Make a deep copy of a matrix
+static float[]copyThenSort(float[] data) + +
+          Sorts and returns a copy of the input array in ascending order
+static float[]cross(float[] a, + float[] b) + +
+          vector cross product: c = a (cross) b
+static floatdet(float[][] data) + +
+          returns the determinant of the square input matrix.
+static float[][]divide(float[][] A, + float value) + +
+          Divides each element of the input matrix A by the input value
+static float[]divide(float[] data, + float value) + +
+          Divides all elements of input array by value.
+static float[]divide(float[] x, + float[] y) + +
+          Element by element division such that z[i] = x[i]/y[i].
+static float[][]dotDivide(float[][] A, + float[][] B) + +
+          Element by element matrix division such that C_ij = A_ij/B_ij.
+static float[][]dotMultiply(float[][] A, + float[][] B) + +
+          Element by element matrix multiplication such that C_ij = A_ij*B_ij.
+static floatdotProduct(float[] a, + float[] b) + +
+          dot product of two arrays such that z = sum(a_i*b_i)
+static floatfloorToNearest(float currentVal, + int interval) + +
+          Function for flooring a number to the closest interval.
+static float[][]identity(int dimension) + +
+          returns the identity matrix of the specified dimension
+static float[][]inverse(float[][] A) + +
+          Matrix inverse if A is square, pseudoinverse otherwise
+static float[]inverse(float[] data, + float replaceZeroWith) + +
+          Returns the array z[i] = 1/x[i]; If x[i] is zero, it sets z[i] + to the specified replaceZeroWith value instead.
+static booleanisConstant(float[] a) + +
+           
+static float[]linspace(float start, + float end, + float stepSize) + +
+           
+static int[]linspace(int start, + int end) + +
+          Returns the array of (end-start+1) points going from + start (inclusive) to end (inclusive): + y[0] = start; y[1] = start+1; ...
+static int[]linspace(int start, + int end, + int stepSize) + +
+           
+static float[]log(float[] data) + +
+          Returns an array with each element equal to the natural logarithm (the base-e logarithm) + the corresponding input array.
+static float[]log10(float[] data) + +
+          Returns an array with each element equal to the log 10 value (base 10 logarithm) + of the corresponding input array.
+static float[]logToBase(float[] data, + float base) + +
+          Returns an array with each element equal to the log A value + of the corresponding input array.
+static floatmag(float[] data) + +
+          Returns the magnitude of the input array = sqrt(x1^2 + x2^2 + ...
+static float[]map(float[] data, + float from, + float to) + +
+          Similar to map([] value, valueArrayMinimum, valueArrayMaximum, from, to)
+static float[]map(float[] data, + float low1, + float high1, + float low2, + float high2) + +
+          Function for mapping an input array of floats for plotting + Extends processing "map" function to accomodate + arrays.
+static floatmap(float data, + float low1, + float high1, + float low2, + float high2) + +
+          Convenience function to map a variable from one coordinate space to another.
+static float[][]multiply(float[][] A, + float a) + +
+          Multiplies the matrix A with the scalar a returning a*A = B + where B_ij = a*A_ij.
+static float[]multiply(float[][] A, + float[] x) + +
+          Multiplies the matrix A with the vector x returning A*x = y + where y_j= Sum(k=j to n) A_ij*x_j.
+static float[][]multiply(float[][] A, + float[][] B) + +
+          Multiplies two matrices A and B returning C = A*B + where C_ij = Sum(k=1 to n) A_ik*B_kj.
+static float[]multiply(float[] data, + float number) + +
+          Multiplies each element of an array by a number, and returns the multiplied array.
+static float[]multiply(float[] data1, + float[] data2) + +
+          Multiplies two arrays and returns the multiplied array.
+static floatnorm1(float[][] data) + +
+          Returns the norm1 of the input matrix, equal to the + maximum absolute column sum of the matrix.
+static floatnorm2(float[] data) + +
+          Returns the norm2 or magnitude of an array.
+static floatnorm2(float[][] data) + +
+          Returns the norm2 (or maximum singular value) of the input matrix.
+static float[]normalizeToMinMax(float[] data) + +
+          Returns an array with elements consisting of the data + normalized to the specified min/max; new data goes from 0 to 1.
+static float[]normalizeToSum(float[] data) + +
+          Returns an array with elements given by z[i] = data[i] / sum(data);
+static floatnormF(float[][] data) + +
+          /** Returns the Frobenius norm of the input matrix; + sqrt of sum of squares of all elements.
+static floatnormInf(float[][] data) + +
+          Returns the Infinity norm of the input matrix, equal to the + maximum row sum.
+static double[]populate(double[] fullDataset, + int[] indices) + +
+          Returns an array with each element corresponding to fullDataset[indices[i]].
+static float[]populate(float[] fullDataset, + int[] indices) + +
+          Returns an array with each element corresponding to fullDataset[indices[i]].
+static int[]populate(int[] fullDataset, + int[] indices) + +
+          Returns an array with each element corresponding to fullDataset[indices[i]].
+static String[]populate(String[] fullDataset, + int[] indices) + +
+          Returns an array with each element corresponding to fullDataset[indices[i]].
+static voidprint(double[][] data, + int d) + +
+          Print the matrix to the screen with each row of the + matrix taking up one line.
+static voidprint(double[][] data, + String[] columnLabels, + String[] rowLabels, + int d) + +
+          Print the matrix to the screen with the columns and rows labeled according to the + input strings.
+static voidprint(double[] data, + int d) + +
+          Print the array to the screen in a single line.
+static voidprint(float[][] data, + int d) + +
+          Print the matrix to the screen with each row of the + matrix taking up one line.
+static voidprint(float[][] data, + String[] columnLabels, + String[] rowLabels, + int d) + +
+          Print the matrix to the screen with the columns and rows labeled according to the + input strings.
+static voidprint(float[] data, + int d) + +
+          Print the array to the screen in a single line.
+static voidprint(int[][] data, + int d) + +
+          Print the matrix to the screen with each row of the + matrix taking up one line.
+static voidprint(int[][] data, + String[] columnLabels, + String[] rowLabels, + int d) + +
+          Print the matrix to the screen with the columns and rows labeled according to the + input strings.
+static voidprint(int[] data, + int d) + +
+          Print the array to the screen in a single line.
+static intrank(float[][] data) + +
+          Returns the effective numerical rank (obtained from SVD) + of the input matrix.
+static float[][]replace(float[][] A, + float oldValue, + float newValue) + +
+          Returns a new matrix B equal to A, except that all elements in A which are equal to oldValue with + the newValue.
+static float[]replace(float[] data, + float oldValue, + float newValue) + +
+          Returns a new array data2 which is similar to data, except that all elements in data + which are equal to oldValue are replaced with + the newValue.
+static float[][]reshape(float[][] arr, + int numRows, + int numColumns) + +
+          Reshapes a matrix into the new specified dimensions.
+static double[]reverse(double[] data) + +
+          reverses the order of the elements in an array.
+static float[]reverse(float[] data) + +
+          reverses the order of the elements in an array.
+static int[]reverse(int[] data) + +
+          reverses the order of the elements in an array.
+static floatroundToDecimalPlace(float number, + int decimal) + +
+          Function for rounding to a given decimal place.
+static float[][]skewSymmetric(float[][] data) + +
+          Returns the skew symmetric part of the input matrix ((A-A')/2).
+static ArrayList[]split(float[] sortedList, + float[] splitters) + +
+          Splits (partitions) an array into sublists such that each sublist contains the elements with a given range.
+static float[][]subMatrix(float[][] inputMat, + int[] rowIndices, + int[] columnIndices) + +
+          Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer).
+static float[][]subMatrix(float[][] inputMat, + int[] rowIndices, + int columnStart, + int columnEnd) + +
+          Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer).
+static float[][]subMatrix(float[][] inputMat, + int rowStart, + int rowEnd, + int[] columnIndices) + +
+          Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer).
+static float[][]subMatrix(float[][] inputMat, + int rowStart, + int rowEnd, + int columnStart, + int columnEnd) + +
+          Get a (2D) submatrix of a (2D) matrix (a copy, not a pointer).
+static int[][]subMatrix(int[][] inputMat, + int[] rowIndices, + int[] columnIndices) + +
+           
+static float[][]subtract(float[][] x, + float[][] y) + +
+          Returns the matrix z = x-y where each element of z[i][j] = x[i][j] - y[i][j]
+static float[]subtract(float[] x, + float[] y) + +
+          Returns the array z = x-y where each element of z[i] = x[i] - y[i]
+static floatsum(float[] data) + +
+          Returns the sum of a data sequence.
+static float[][]sum(float[][] x, + float[][] y) + +
+          Returns the matrix z = x+y where each element of z[i][j] = x[i][j] + y[i][j]
+static float[]sum(float[] data, + float number) + +
+          Sum of an array with a number.
+static float[]sum(float[] data1, + float[] data2) + +
+          Returns the sum of two data sequences.
+static intsum(int[] data) + +
+          Returns the sum of a data sequence.
+static int[]sum(int[] data, + int number) + +
+          Sum of an array with a number.
+static int[]sum(int[] data1, + int[] data2) + +
+          Returns the sum of two data sequences.
+static voidswap(float[] data, + int oldIndex, + int newIndex) + +
+          Swap function that swaps the values in an array
+static voidswap(int[] data, + int oldIndex, + int newIndex) + +
+          Swap function that swaps the values in an array (overload function)
+static float[][]symmetric(float[][] data) + +
+          Returns the symmetric part of the input matrix ((A+A')/2).
+static floattrace(float[][] data) + +
+          Returns the matrix trace or sum of the diagonal elements.
+static float[][]transpose(float[][] data) + +
+          Returns the transpose of the input matrix.
+static int[][]transpose(int[][] data) + +
+           
+static float[]within(float[] numbers, + float min, + float max) + +
+          returns an array containing all numbers within the min and max (inclusive).
+static booleanwithin(float number, + float min, + float max) + +
+          Checks to see if a number is in the range specified by [min,max].
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+abs

+
+public static float[] abs(float[] array)
+
+
Return absolute values of an array +

+

+
+
+
+
+ +

+abs

+
+public static int[] abs(int[] array)
+
+
Return absolute values of an array +

+

+
+
+
+
+ +

+column

+
+public static float[][] column(float[][] inputMat,
+                               int indexStart,
+                               int indexEnd)
+
+
Function to get columns of a 2-D matrix. +

+

+
Parameters:
inputMat - inputMatrix.
indexStart - index of the start column (inclusive)
indexEnd - index of the end column (inclusive) +
Returns:
outputMat consisting of the specified columns [indexStart, indexStart+1, ...., indexEnd]
+
+
+
+ +

+column

+
+public static float[] column(float[][] inputMat,
+                             int columnIndex)
+
+
Function to get one column of a 2D matrix +

+

+
Parameters:
inputMat - input matrix.
columnIndex - index of the column to get +
Returns:
outputColumn the specified column
+
+
+
+ +

+column

+
+public static int[] column(int[][] inputMat,
+                           int columnIndex)
+
+
+
+
+
+
+ +

+compare

+
+public static int compare(int a,
+                          int b)
+
+
Returns -1 if a is less than b, or 1 if a is greater than b, or 0. + This is the comparator function for natural order. +

+

+
+
+
+
+ +

+compare

+
+public static float compare(float a,
+                            float b)
+
+
Returns -1 if a is less than b, or 1 if a is greater than b, or 0. + This is the comparator function for natural order. +

+

+
+
+
+
+ +

+concat

+
+public static float[] concat(float[] a,
+                             float[] b)
+
+
Concatenates two arrays a and b into a new array + c such that c = {a,b}. +

+

+
+
+
+
+ +

+concat

+
+public static int[] concat(int[] a,
+                           int[] b)
+
+
+
+
+
+
+ +

+constant

+
+public static float[] constant(float constValue,
+                               int size)
+
+
Returns an array with of length size with + each element equal to the specified constValue. +

+

+
See Also:
Arrays.fill
+
+
+
+ +

+constant

+
+public static int[] constant(int constValue,
+                             int size)
+
+
Returns an array with of length size with + each element equal to the specified constValue. +

+

+
See Also:
Arrays.fill
+
+
+
+ +

+copy

+
+public static float[][] copy(float[][] data)
+
+
Make a deep copy of a matrix +

+

+
+
+
+
+ +

+copyThenSort

+
+public static float[] copyThenSort(float[] data)
+
+
Sorts and returns a copy of the input array in ascending order +

+

+ +
Returns:
a sorted copy of the input array.
+
+
+
+ +

+cross

+
+public static float[] cross(float[] a,
+                            float[] b)
+
+
vector cross product: c = a (cross) b +

+

+
+
+
+
+ +

+det

+
+public static float det(float[][] data)
+
+
returns the determinant of the square input matrix. +

+

+ +
Throws: +
IllegalArgumentException - if the matrix is not square.
+
+
+
+ +

+divide

+
+public static float[] divide(float[] data,
+                             float value)
+
+
Divides all elements of input array by value. + That is, z[i] = x[i] / value. +

+

+ +
Throws: +
IllegalArgumentException - if value is zero.
+
+
+
+ +

+divide

+
+public static float[] divide(float[] x,
+                             float[] y)
+
+
Element by element division such that z[i] = x[i]/y[i]. No checks are + done to see if any y[i] == 0 so make sure you know what + you're doing. +

+

+
+
+
+
+ +

+divide

+
+public static float[][] divide(float[][] A,
+                               float value)
+
+
Divides each element of the input matrix A by the input value +

+

+
+
+
+
+ +

+dotDivide

+
+public static float[][] dotDivide(float[][] A,
+                                  float[][] B)
+
+
Element by element matrix division such that C_ij = A_ij/B_ij. No checks are + done to see if the elements of B_ij == 0 so make sure you know what + you're doing. +

+

+
+
+
+
+ +

+dotMultiply

+
+public static float[][] dotMultiply(float[][] A,
+                                    float[][] B)
+
+
Element by element matrix multiplication such that C_ij = A_ij*B_ij. +

+

+
+
+
+
+ +

+dotProduct

+
+public static float dotProduct(float[] a,
+                               float[] b)
+
+
dot product of two arrays such that z = sum(a_i*b_i) +

+

+
+
+
+
+ +

+identity

+
+public static float[][] identity(int dimension)
+
+
returns the identity matrix of the specified dimension +

+

+
+
+
+
+ +

+inverse

+
+public static float[] inverse(float[] data,
+                              float replaceZeroWith)
+
+
Returns the array z[i] = 1/x[i]; If x[i] is zero, it sets z[i] + to the specified replaceZeroWith value instead. +

+

+
+
+
+
+ +

+inverse

+
+public static float[][] inverse(float[][] A)
+
+
Matrix inverse if A is square, pseudoinverse otherwise +

+

+ +
Returns:
inverse(A) if A is square, pseudoinverse otherwise.
+
+
+
+ +

+isConstant

+
+public static boolean isConstant(float[] a)
+
+
+
+
+
+
+ +

+log

+
+public static float[] log(float[] data)
+
+
Returns an array with each element equal to the natural logarithm (the base-e logarithm) + the corresponding input array. + This function expects the values greater than 0.0; No internal checks are done. +

+

+
+
+
+
+ +

+log10

+
+public static float[] log10(float[] data)
+
+
Returns an array with each element equal to the log 10 value (base 10 logarithm) + of the corresponding input array. + This function expects the values greater than 0.0; No internal checks are done. +

+

+
+
+
+
+ +

+logToBase

+
+public static float[] logToBase(float[] data,
+                                float base)
+
+
Returns an array with each element equal to the log A value + of the corresponding input array. This is + computed using the property log_A(x) = log(x) / log(A) where + log is the natural logarithm (base e), and A is the new log base. + This function expects the values greater than 0.0; No internal checks are done. +

+

+
Parameters:
base - the log base. E.g. to get log2, we would use logToBase(data,2).
+
+
+
+ +

+linspace

+
+public static int[] linspace(int start,
+                             int end)
+
+
Returns the array of (end-start+1) points going from + start (inclusive) to end (inclusive): + y[0] = start; y[1] = start+1; ... , y[n] = end;. +
+ For example, int[] ii = linspace(2,5); + produces the array ii = {2,3,4,5}; with length 4. +
+ It is similar to this:
+ 
+ for(int i=0; i<=end-start+1; i++){
+ 
    y[i] = i + start; +
} +
+
+

+

+
Parameters:
start - the start index (inclusive)
end - the end index (inclusive);
+
+
+
+ +

+linspace

+
+public static int[] linspace(int start,
+                             int end,
+                             int stepSize)
+
+
+
Parameters:
start - the start index (inclusive)
end - the end index (inclusive);
stepSize - the stepsize to take +
Returns:
array of length num = floor((end-start)/(float)stepSize) (meaning that it could end BEFORE 'end' if you + don't size your stepsize properly.
+
+
+
+ +

+linspace

+
+public static float[] linspace(float start,
+                               float end,
+                               float stepSize)
+
+
+
Parameters:
start - the start index (inclusive)
end - the end index (inclusive);
stepSize - the stepsize to take +
Returns:
array of length num = ((end-start)/stepSize)
+
+
+
+ +

+mag

+
+public static float mag(float[] data)
+
+
Returns the magnitude of the input array = sqrt(x1^2 + x2^2 + ... + xn^2) +

+

+
+
+
+
+ +

+map

+
+public static float map(float data,
+                        float low1,
+                        float high1,
+                        float low2,
+                        float high2)
+
+
Convenience function to map a variable from one coordinate space to another. + I.e. + map(value, low1, high1, low2, high2) = low2 + (value - low1) * ( (high2-low2) / (high1-low1) ) + +

Similar to Processing's "map" function.

+

+

+ +
Returns:
mapped data array
+
+
+
+ +

+map

+
+public static float[] map(float[] data,
+                          float from,
+                          float to)
+
+
Similar to map([] value, valueArrayMinimum, valueArrayMaximum, from, to) +

+

+ +
Returns:
mapped data array
+
+
+
+ +

+map

+
+public static float[] map(float[] data,
+                          float low1,
+                          float high1,
+                          float low2,
+                          float high2)
+
+
Function for mapping an input array of floats for plotting + Extends processing "map" function to accomodate + arrays. E.g. map(value, low1, high1, low2, high2) + is now + map([] value, low1, high1, low2, high2) +

+

+ +
Returns:
mapped data array
+
+
+
+ +

+multiply

+
+public static float[][] multiply(float[][] A,
+                                 float[][] B)
+
+
Multiplies two matrices A and B returning C = A*B + where C_ij = Sum(k=1 to n) A_ik*B_kj. + Precondition: Number of columns in A = number of rows in B. +

+

+
+
+
+
+ +

+multiply

+
+public static float[] multiply(float[][] A,
+                               float[] x)
+
+
Multiplies the matrix A with the vector x returning A*x = y + where y_j= Sum(k=j to n) A_ij*x_j. + Precondition: Number of columns in A = number of elements in x. +

+

+
+
+
+
+ +

+multiply

+
+public static float[][] multiply(float[][] A,
+                                 float a)
+
+
Multiplies the matrix A with the scalar a returning a*A = B + where B_ij = a*A_ij. +

+

+
+
+
+
+ +

+multiply

+
+public static float[] multiply(float[] data1,
+                               float[] data2)
+
+
Multiplies two arrays and returns the multiplied array. + That is, z[i] = x[i] * y[i]. +

+

+
+
+
+
+ +

+multiply

+
+public static float[] multiply(float[] data,
+                               float number)
+
+
Multiplies each element of an array by a number, and returns the multiplied array. + That is, z[i] = k * x[i] . +

+

+
+
+
+
+ +

+norm1

+
+public static float norm1(float[][] data)
+
+
Returns the norm1 of the input matrix, equal to the + maximum absolute column sum of the matrix. +

+

+
+
+
+
+ +

+norm2

+
+public static float norm2(float[][] data)
+
+
Returns the norm2 (or maximum singular value) of the input matrix. +

+

+
+
+
+
+ +

+norm2

+
+public static float norm2(float[] data)
+
+
Returns the norm2 or magnitude of an array. Similar to mag(float[]). +

+

+
+
+
+
+ +

+normF

+
+public static float normF(float[][] data)
+
+
/** Returns the Frobenius norm of the input matrix; + sqrt of sum of squares of all elements. +

+

+
+
+
+
+ +

+normInf

+
+public static float normInf(float[][] data)
+
+
Returns the Infinity norm of the input matrix, equal to the + maximum row sum. +

+

+
+
+
+
+ +

+normalizeToMinMax

+
+public static float[] normalizeToMinMax(float[] data)
+
+
Returns an array with elements consisting of the data + normalized to the specified min/max; new data goes from 0 to 1. +

+

+ +
Returns:
normalized data array
+
+
+
+ +

+normalizeToSum

+
+public static float[] normalizeToSum(float[] data)
+
+
Returns an array with elements given by z[i] = data[i] / sum(data); +

+

+ +
Returns:
normalized data array
+
+
+
+ +

+populate

+
+public static double[] populate(double[] fullDataset,
+                                int[] indices)
+
+
Returns an array with each element corresponding to fullDataset[indices[i]]. + That is, if the indices.length = n, then +
+ y[0] = fullDataset[ indices[0] ];
+ y[1] = fullDataset[ indices[1] ];
+ ...
+ ...
+ y[n-1] = fullDataset[ indices[n-1] ];
+ 
+

+

+
Parameters:
indices - the indices in the fullDataset you want to extract and store.
fullDataset - the full dataset.
+
+
+
+ +

+populate

+
+public static float[] populate(float[] fullDataset,
+                               int[] indices)
+
+
Returns an array with each element corresponding to fullDataset[indices[i]]. + That is, if the indices.length = n, then +
+ y[0] = fullDataset[ indices[0] ];
+ y[1] = fullDataset[ indices[1] ];
+ ...
+ ...
+ y[n-1] = fullDataset[ indices[n-1] ];
+ 
+

+

+
Parameters:
indices - the indices in the fullDataset you want to extract and store.
fullDataset - the full dataset.
+
+
+
+ +

+populate

+
+public static int[] populate(int[] fullDataset,
+                             int[] indices)
+
+
Returns an array with each element corresponding to fullDataset[indices[i]]. + That is, if the indices.length = n, then +
+ y[0] = fullDataset[ indices[0] ];
+ y[1] = fullDataset[ indices[1] ];
+ ...
+ ...
+ y[n-1] = fullDataset[ indices[n-1] ];
+ 
+

+

+
Parameters:
indices - the indices in the fullDataset you want to extract and store.
fullDataset - the full dataset.
+
+
+
+ +

+populate

+
+public static String[] populate(String[] fullDataset,
+                                int[] indices)
+
+
Returns an array with each element corresponding to fullDataset[indices[i]]. + That is, if the indices.length = n, then +
+ y[0] = fullDataset[ indices[0] ];
+ y[1] = fullDataset[ indices[1] ];
+ ...
+ ...
+ y[n-1] = fullDataset[ indices[n-1] ];
+ 
+

+

+
Parameters:
indices - the indices in the fullDataset you want to extract and store.
fullDataset - the full dataset.
+
+
+
+ +

+print

+
+public static void print(double[] data,
+                         int d)
+
+
Print the array to the screen in a single line. Similar to print, + except that the entire array is printed on a single line on the screen and + you can format the number of decimal digits directly instead of using Processing's + nf or one of the other variants of it. +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(double[][] data,
+                         int d)
+
+
Print the matrix to the screen with each row of the + matrix taking up one line. Similar to println, except that + each row of the matrix is printed on a single line on the screen and + you can format the number of decimal digits directly instead of using Processing's + nf or one of the other variants of it. +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(double[][] data,
+                         String[] columnLabels,
+                         String[] rowLabels,
+                         int d)
+
+
Print the matrix to the screen with the columns and rows labeled according to the + input strings. Output resembles what you'd see in a .txt file (assuming the matrix isn't + too large). +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(float[] data,
+                         int d)
+
+
Print the array to the screen in a single line. Similar to print, + except that the entire array is printed on a single line on the screen and + you can format the number of decimal digits directly instead of using Processing's + nf or one of the other variants of it. +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(float[][] data,
+                         int d)
+
+
Print the matrix to the screen with each row of the + matrix taking up one line. Similar to println, except that + each row of the matrix is printed on a single line on the screen and + you can format the number of decimal digits directly instead of using Processing's + nf or one of the other variants of it. +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(float[][] data,
+                         String[] columnLabels,
+                         String[] rowLabels,
+                         int d)
+
+
Print the matrix to the screen with the columns and rows labeled according to the + input strings. Output resembles what you'd see in a .txt file (assuming the matrix isn't + too large). +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(int[] data,
+                         int d)
+
+
Print the array to the screen in a single line. Similar to print, + except that the entire array is printed on a single line on the screen and + you can format the number of decimal digits directly instead of using Processing's + nf or one of the other variants of it. +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(int[][] data,
+                         int d)
+
+
Print the matrix to the screen with each row of the + matrix taking up one line. Similar to println, except that + each row of the matrix is printed on a single line on the screen and + you can format the number of decimal digits directly instead of using Processing's + nf or one of the other variants of it. +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+print

+
+public static void print(int[][] data,
+                         String[] columnLabels,
+                         String[] rowLabels,
+                         int d)
+
+
Print the matrix to the screen with the columns and rows labeled according to the + input strings. Output resembles what you'd see in a .txt file (assuming the matrix isn't + too large). +

+

+
Parameters:
data - the matrix to be printed.
d - Number of digits after the decimal to display..
+
+
+
+ +

+rank

+
+public static int rank(float[][] data)
+
+
Returns the effective numerical rank (obtained from SVD) + of the input matrix. + See Rank for ranking the elements of an input 1D array. +

+

+
+
+
+
+ +

+replace

+
+public static float[][] replace(float[][] A,
+                                float oldValue,
+                                float newValue)
+
+
Returns a new matrix B equal to A, except that all elements in A which are equal to oldValue with + the newValue. Useful, for example, in replacing zeros with + some other number (for dotDivide(float[][], float[][])), or for wall-street related book-keeping... +

+

+
+
+
+
+ +

+replace

+
+public static float[] replace(float[] data,
+                              float oldValue,
+                              float newValue)
+
+
Returns a new array data2 which is similar to data, except that all elements in data + which are equal to oldValue are replaced with + the newValue. Useful, for example, in replacing zeros with + some other number (for divide(float[], float[])), or for wall-street related book-keeping... +

+

+
+
+
+
+ +

+reshape

+
+public static float[][] reshape(float[][] arr,
+                                int numRows,
+                                int numColumns)
+
+
Reshapes a matrix into the new specified dimensions. +

+

+
+
+
+
+ +

+reverse

+
+public static double[] reverse(double[] data)
+
+
reverses the order of the elements in an array. +

+

+
+
+
+
+ +

+reverse

+
+public static float[] reverse(float[] data)
+
+
reverses the order of the elements in an array. +

+

+
+
+
+
+ +

+reverse

+
+public static int[] reverse(int[] data)
+
+
reverses the order of the elements in an array. +

+

+
+
+
+
+ +

+roundToDecimalPlace

+
+public static float roundToDecimalPlace(float number,
+                                        int decimal)
+
+
Function for rounding to a given decimal place. + Convenient for displaying text when Processing's nf,nfc,etc is insufficient. + Only works if the input number has got more decimal places than the + number to round to. +

+ Examples: +
roundToDecimalPlace(1.234567, 2) --> 1.23; +
roundToDecimalPlace(100, 2) --> 100; +

+

+

+
Parameters:
number - number to round.
decimal - decimal place to round to. +
Returns:
number rounded to the specified decimal place
+
+
+
+ +

+floorToNearest

+
+public static float floorToNearest(float currentVal,
+                                   int interval)
+
+
Function for flooring a number to the closest interval. Useful for + setting up the tick labels for plotting. +

+ Examples: +
floorToNearest(173.2,5) --> 170; +
floorToNearest(28,10) --> 20; +

+

+

+
Parameters:
currentVal - number to floor.
interval - to floor to. E.g. in fives, twos, tens, etc. +
Returns:
number.
+
+
+
+ +

+ceilToNearest

+
+public static float ceilToNearest(float currentVal,
+                                  int interval)
+
+
Function for ceiling a number to the closest interval. Useful for + setting up the tick labels for plotting. +

+ Examples: +
ceilToNearest(173.2,5) --> 175; +
ceilToNearest(28,10) --> 30; +

+

+

+
Parameters:
currentVal - number to ceil.
interval - to ceil to. E.g. in fives, twos, tens, etc. +
Returns:
number.
+
+
+
+ +

+split

+
+public static ArrayList[] split(float[] sortedList,
+                                float[] splitters)
+
+
Splits (partitions) an array into sublists such that each sublist contains the elements with a given range. + splitters=(a,b,c,...,y,z) defines the ranges [-inf,a), [a,b), [b,c), ..., [y,z), [z,inf]. +

Examples:
+

    + data = (1,2,3,4,5,8,8,8,10,11). +
    splitters=(2,8) yields 3 bins: (1), (2,3,4,5) (8,8,8,10,11). +
    splitters=() yields 1 bin: (1,2,3,4,5,8,8,8,10,11). +
    splitters=(-5) yields 2 bins: (), (1,2,3,4,5,8,8,8,10,11). +
    splitters=(100) yields 2 bins: (1,2,3,4,5,8,8,8,10,11), (). +
+

+

+
Parameters:
sortedList - the list to be partitioned (must be sorted ascending).
splitters - the points at which the list shall be partitioned (must be sorted ascending). +
Returns:
the sublists (an array with length == splitters.length + 1. + Each sublist is returned sorted ascending.
+
+
+
+ +

+subMatrix

+
+public static float[][] subMatrix(float[][] inputMat,
+                                  int rowStart,
+                                  int rowEnd,
+                                  int columnStart,
+                                  int columnEnd)
+
+
Get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +

+

+
Parameters:
inputMat - input matrix
rowStart - row to start at (inclusive)
rowEnd - row to end at (inclusive)
columnStart - column to start at (inclusive)
columnEnd - column to end at (inclusive) +
Returns:
submatrix containing (rowEnd-rowStart+1) rows and (columnEnd-columnStart+1) columns; + copy of A(rowStart:rowEnd, columnStart:columnEnd). +
Throws: +
IllegalArgumentException - if the rowStart, rowEnd, columnStart, or columnEnd parameters + are not within the inputMatrix size bounds.
+
+
+
+ +

+subMatrix

+
+public static float[][] subMatrix(float[][] inputMat,
+                                  int[] rowIndices,
+                                  int columnStart,
+                                  int columnEnd)
+
+
Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +

+

+
Parameters:
inputMat - input matrix
rowIndices - the row indices
columnStart - column to start at (inclusive)
columnEnd - column to end at (inclusive) +
Returns:
the submatrix containing a copy of the input matrix's specified rows from + columnStart to columnEnd; copy of A(rowIndices(:), columnStart:columnEnd). +
Throws: +
IllegalArgumentException - if the inputs are not within the inputMatrix size bounds.
+
+
+
+ +

+subMatrix

+
+public static float[][] subMatrix(float[][] inputMat,
+                                  int rowStart,
+                                  int rowEnd,
+                                  int[] columnIndices)
+
+
Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +

+

+
Parameters:
inputMat - input matrix
rowStart - row to start at (inclusive)
rowEnd - column to end at (inclusive)
columnIndices - the column indices +
Returns:
the submatrix containing the specified rows, and going from the original matrices + rowStart to rowEnd columns; copy of A(rowIndices(:), columnStart:columnEnd). +
Throws: +
IllegalArgumentException - if the inputs are not within the inputMatrix size bounds.
+
+
+
+ +

+subMatrix

+
+public static float[][] subMatrix(float[][] inputMat,
+                                  int[] rowIndices,
+                                  int[] columnIndices)
+
+
Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). +

+

+
Parameters:
inputMat - input matrix
rowIndices - the row indices
columnIndices - the column indices +
Returns:
the submatrix containing the specified rows, and going from the original matrices + rowStart to rowEnd columns; copy of A(rowIndices(:), columnStart:columnEnd). +
Throws: +
IllegalArgumentException - if the inputs are not within the inputMatrix size bounds.
+
+
+
+ +

+subMatrix

+
+public static int[][] subMatrix(int[][] inputMat,
+                                int[] rowIndices,
+                                int[] columnIndices)
+
+
+
+
+
+
+ +

+subtract

+
+public static float[] subtract(float[] x,
+                               float[] y)
+
+
Returns the array z = x-y where each element of z[i] = x[i] - y[i] +

+

+
+
+
+
+ +

+subtract

+
+public static float[][] subtract(float[][] x,
+                                 float[][] y)
+
+
Returns the matrix z = x-y where each element of z[i][j] = x[i][j] - y[i][j] +

+

+
+
+
+
+ +

+sum

+
+public static float sum(float[] data)
+
+
Returns the sum of a data sequence. + That is Sum( data[i] ). +

+

+
+
+
+
+ +

+sum

+
+public static float[] sum(float[] data1,
+                          float[] data2)
+
+
Returns the sum of two data sequences. + That is Sum( data[i] ). +

+

+
+
+
+
+ +

+sum

+
+public static float[] sum(float[] data,
+                          float number)
+
+
Sum of an array with a number. That is + Sum( data[i] + number). +

+

+ +
Returns:
array with each element equal to data[i] + number
+
+
+
+ +

+sum

+
+public static int sum(int[] data)
+
+
Returns the sum of a data sequence. + That is Sum( data[i] ). +

+

+
+
+
+
+ +

+sum

+
+public static int[] sum(int[] data1,
+                        int[] data2)
+
+
Returns the sum of two data sequences. + That is Sum( data[i] ). +

+

+
+
+
+
+ +

+sum

+
+public static int[] sum(int[] data,
+                        int number)
+
+
Sum of an array with a number. That is + Sum( data[i] + number). +

+

+ +
Returns:
array with each element equal to data[i] + number
+
+
+
+ +

+sum

+
+public static float[][] sum(float[][] x,
+                            float[][] y)
+
+
Returns the matrix z = x+y where each element of z[i][j] = x[i][j] + y[i][j] +

+

+
+
+
+
+ +

+swap

+
+public static void swap(float[] data,
+                        int oldIndex,
+                        int newIndex)
+
+
Swap function that swaps the values in an array +

+

+
Parameters:
data - is an array of floats
oldIndex -
newIndex - e.g. data[newIndex,oldIndex] = data[oldIndex,newIndex]
+
+
+
+ +

+swap

+
+public static void swap(int[] data,
+                        int oldIndex,
+                        int newIndex)
+
+
Swap function that swaps the values in an array (overload function) +

+

+
Parameters:
data - is an array of integers
oldIndex -
newIndex - e.g. data[newIndex,oldIndex] = data[oldIndex,newIndex]
+
+
+
+ +

+symmetric

+
+public static float[][] symmetric(float[][] data)
+
+
Returns the symmetric part of the input matrix ((A+A')/2). +

+

+
+
+
+
+ +

+skewSymmetric

+
+public static float[][] skewSymmetric(float[][] data)
+
+
Returns the skew symmetric part of the input matrix ((A-A')/2). +

+

+
+
+
+
+ +

+trace

+
+public static float trace(float[][] data)
+
+
Returns the matrix trace or sum of the diagonal elements. +

+

+
+
+
+
+ +

+transpose

+
+public static float[][] transpose(float[][] data)
+
+
Returns the transpose of the input matrix. +

+

+
+
+
+
+ +

+transpose

+
+public static int[][] transpose(int[][] data)
+
+
+ +
Returns:
the transpose of the input matrix
+
+
+
+ +

+within

+
+public static boolean within(float number,
+                             float min,
+                             float max)
+
+
Checks to see if a number is in the range specified by [min,max]. + Returns true if min ≤ number ≤ max). +

+

+
Parameters:
min - left-most limit (inclusive)
max - right-most limit (inclusive)
number - the value to check for. +
Returns:
true if the number is within the bounds, else false
+
+
+
+ +

+within

+
+public static float[] within(float[] numbers,
+                             float min,
+                             float max)
+
+
returns an array containing all numbers within the min and max (inclusive). + If nothing is within the min and max, an array of length 1 with the first element = -1 is returned +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/NaNs.html b/drawing/papaya/reference/papaya/NaNs.html new file mode 100644 index 0000000..2c83fb3 --- /dev/null +++ b/drawing/papaya/reference/papaya/NaNs.html @@ -0,0 +1,447 @@ + + + + + + +NaNs (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class NaNs

+
+java.lang.Object
+  extended by papaya.NaNs
+
+
+
+
public final class NaNs
extends Object
+ + +

+

Contains various methods for dealing with NaNs in your data.

+ Currently only accommodates float and double arrays. Java's Integer.isNaN doesn't + seem to exist or I'd include that as well. +

+ +

+

+
Author:
+
Adila Faruk
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static booleancontainsNaNs(double[] data) + +
+          Checks for presence of NaNs in the data array.
+static booleancontainsNaNs(float[] data) + +
+          Checks for presence of NaNs in the data array.
+static double[]eliminate(double[] data) + +
+          Eliminate the NaNs from the input array.
+static float[]eliminate(float[] data) + +
+          Eliminate the NaNs from the input array.
+static ArrayList<Integer>getNaNPositions(double[] data) + +
+          Returns an array list of indexes where data[i] is NaN.
+static ArrayList<Integer>getNaNPositions(float[] data) + +
+          Returns an array list of indexes where data[i] is NaN.
+static double[]replaceNewWith(double[] data, + double newNaN) + +
+          Returns a new array with NaN elements in the original data set replaced with the value + specified by newNaN.
+static float[]replaceNewWith(float[] data, + float newNaN) + +
+          Returns a new array with NaN elements in the original data set replaced with the value + specified by newNaN.
+static voidreplaceOriginalWith(double[] data, + double newNaN) + +
+          Modifies the original data array by replacing the NaN elements in the data set with the value + specified by newNaN.
+static voidreplaceOriginalWith(float[] data, + float newNaN) + +
+          Modifies the original data array by replacing the NaN elements in the data set with the value + specified by newNaN.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+eliminate

+
+public static double[] eliminate(double[] data)
+
+
Eliminate the NaNs from the input array. +

+

+
Parameters:
data - the array containing NaNs +
Returns:
the new array (with length < data.length) devoid + of NaNs.
+
+
+
+ +

+replaceNewWith

+
+public static double[] replaceNewWith(double[] data,
+                                      double newNaN)
+
+
Returns a new array with NaN elements in the original data set replaced with the value + specified by newNaN. +

+

+
Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with. +
Returns:
new array with NaNs replaced with the values specified by newNaN.
+
+
+
+ +

+replaceOriginalWith

+
+public static void replaceOriginalWith(double[] data,
+                                       double newNaN)
+
+
Modifies the original data array by replacing the NaN elements in the data set with the value + specified by newNaN. +

+

+
Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with.
+
+
+
+ +

+containsNaNs

+
+public static boolean containsNaNs(double[] data)
+
+
Checks for presence of NaNs in the data array. +

+

+
Parameters:
data - array to be searched for NaNs +
Returns:
true iff ranks contains one or more NaNs
+
+
+
+ +

+getNaNPositions

+
+public static ArrayList<Integer> getNaNPositions(double[] data)
+
+
Returns an array list of indexes where data[i] is NaN. +

+

+
Parameters:
data - array to search for NaNs +
Returns:
list of indexes i such that data[i] = NaN
+
+
+
+ +

+eliminate

+
+public static float[] eliminate(float[] data)
+
+
Eliminate the NaNs from the input array. +

+

+
Parameters:
data - the array containing NaNs +
Returns:
the new array (with length < data.length) devoid + of NaNs.
+
+
+
+ +

+replaceNewWith

+
+public static float[] replaceNewWith(float[] data,
+                                     float newNaN)
+
+
Returns a new array with NaN elements in the original data set replaced with the value + specified by newNaN. +

+

+
Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with. +
Returns:
new array with NaNs replaced with the values specified by newNaN.
+
+
+
+ +

+replaceOriginalWith

+
+public static void replaceOriginalWith(float[] data,
+                                       float newNaN)
+
+
Modifies the original data array by replacing the NaN elements in the data set with the value + specified by newNaN. +

+

+
Parameters:
data - the array containing NaNs
newNaN - the value to replace the NaNs with.
+
+
+
+ +

+containsNaNs

+
+public static boolean containsNaNs(float[] data)
+
+
Checks for presence of NaNs in the data array. +

+

+
Parameters:
data - array to be searched for NaNs +
Returns:
true iff ranks contains one or more NaNs
+
+
+
+ +

+getNaNPositions

+
+public static ArrayList<Integer> getNaNPositions(float[] data)
+
+
Returns an array list of indexes where data[i] is NaN. +

+

+
Parameters:
data - array to search for NaNs +
Returns:
list of indexes i such that data[i] = NaN
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Normality.Dago.html b/drawing/papaya/reference/papaya/Normality.Dago.html new file mode 100644 index 0000000..b56d605 --- /dev/null +++ b/drawing/papaya/reference/papaya/Normality.Dago.html @@ -0,0 +1,373 @@ + + + + + + +Normality.Dago (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Normality.Dago

+
+java.lang.Object
+  extended by papaya.Normality.Dago
+
+
+
Enclosing class:
Normality
+
+
+
+
public static class Normality.Dago
extends Object
+ + +

+Methods for computing the skewnewss, kurtosis, and D'Agostino-Peasrson K^2 "omnibus" test-statistics (that + combine the former two), and accompanying significance (or p-values) + for testing the underlying population normality. + +

Implementation: + +
Let mk denote the kth moment, + mk = ∑_(i=1 to n)(x_i - mean(x))/n. Then, we can define the following: +
Sample estimate of the third standardized moment: b1 = m3/(m2)^(3/2)
+
Sample estimate of the fourth standardized moment: b2 = m4/m2
+
The test statistics Z(b1), Z(b2) are approximately normally distributed under + the null hypothesis of population normality. Both Z(b1) and Z(b2) can be used to + test one-sided and two-sided alternative hypothesis. + +

+ D'Agostino and Pearson (1973) also introduced the following "omnibus" test statistic, +
K^2 = (Z(b1))^2 + (Z(b2))^2,
+ which is able to detect deviations from normality due to either skewness or kurtosis + This K^2 statistic has an approximately Chi-Squared distribution with 2 degrees of + freedom when the population is normally distributed. + Similar to Z(b1) and Z(b2), K^2 can be used to test one-sided and two-sided alternative hypothesis. + +

Requirements +
data set has to have more than 20 elements. An error is thrown otherwise since the normal + approximation is no longer valid (technically, the it is valid for Zb1, as long as n > 8, but + since we're computing everything, the requirement has been set a little higher. + +

Remarks: +

    +
  • + The normal approximation for the zb1 is only valid for sample sizes > 8. For smaller sample sizes, + it is suggested that you consult a look-up table. Likewise, the normal approximation for the +
  • + b1 and b2 differ from the Fisher g statistic parameters g1 + and g2 used in SAS, and SPSS but they are related by a linear transformation (see + cited paper for details). +
  • + For users familiar with the R software package, this class is analogous to the + R's dagoTest class in the fBasics library albeit with some implementation. +
+

+ References: +
D'Agostino, R., Albert Belanger, A., D'Agostino Jr, R., 1990 + A Suggestion for Using Powerful and Informative Tests of Normality + +
D?Agostino, R., Pearson, E., 1973. Tests for departures from normality. + Empirical results for the distribution of b1 and b2.Biometrika 60, 613?622. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[]chi2(float[] data) + +
+          Computes and returns an array containing the test statistic chi2, or the + "omnibus" test statistic, and the significance, or "p-value" of this test statistic.
+static float[]kurtosis(float[] data) + +
+          Computes and returns an array containing the test statistic zb2associated with + b2 and the significance, or "p-value" of the kurtosis test statistic zb2, assuming a + two-tailed null hypothesis as well as .
+static float[]pValues(float[] data) + +
+          Returns an array containing the three significance, or p-values, for testing normality.
+static float[]skew(float[] data) + +
+          Computes and returns an array containing the test statistic zb1associated with sqrt(b1) and + the significance, or "p-value" of the skew test statistic zb1, assuming a + two-tailed null hypothesis as well as .
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+skew

+
+public static float[] skew(float[] data)
+
+
Computes and returns an array containing the test statistic zb1associated with sqrt(b1) and + the significance, or "p-value" of the skew test statistic zb1, assuming a + two-tailed null hypothesis as well as . The first element of the output array is the + test statistic zb1 associated with sqrt(b1) = m3/m2^(3/2) where mk is + the kth momement as specified in Descriptive.moment(float[], int, float) and the second element is + the p-value for the two-tailed null hypothesis with +
+ pValueSkew = 2* ( 1-Probability.normcdf( zb1 ) ).
+ 
+ (D'Agostino et al. (1990)) . +

+

+
+
+
+
+ +

+kurtosis

+
+public static float[] kurtosis(float[] data)
+
+
Computes and returns an array containing the test statistic zb2associated with + b2 and the significance, or "p-value" of the kurtosis test statistic zb2, assuming a + two-tailed null hypothesis as well as . The first element of the output array is the + test statistic zb2 associated with b2 = m4/m2^2 where mk is + the kth momement as specified in Descriptive.moment(float[], int, float). and the second element is + the p-value for the two-tailed null hypothesis with +
+ pValueKurtosis = 2* ( 1-Probability.normcdf( zb2 ) ).
+ 
+ (D'Agostino et al. (1990)) . +

+

+
+
+
+
+ +

+chi2

+
+public static float[] chi2(float[] data)
+
+
Computes and returns an array containing the test statistic chi2, or the + "omnibus" test statistic, and the significance, or "p-value" of this test statistic. + The first element of the output array is the test statistic the ombibus test + statistic chi2 and the second element is + the p-value: +
+ pValueChiSquared = ( 1-Probability.chi2cdf( chi2 ) ).
+ 
+ (D'Agostino et al. (1990)) . +

+

+
+
+
+
+ +

+pValues

+
+public static float[] pValues(float[] data)
+
+
Returns an array containing the three significance, or p-values, for testing normality. + The first element corresponds to the p-value associated with D'Agostino's Chi-Squared + test statistic (or omnibus test, chi2(float[])), the second corresponds to D'Agostino's + skew test (skew(float[])), and the + third corresponds to D'Agostino's kurtosis test (kurtosis(float[])). +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Normality.html b/drawing/papaya/reference/papaya/Normality.html new file mode 100644 index 0000000..a3291d3 --- /dev/null +++ b/drawing/papaya/reference/papaya/Normality.html @@ -0,0 +1,289 @@ + + + + + + +Normality (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Normality

+
+java.lang.Object
+  extended by papaya.Normality
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class Normality
extends Object
implements PapayaConstants
+ + +

+Contains various utilities for checking if the dataset comes from a normal distribution. +

+ +

+


+ +

+ + + + + + + + + + + +
+Nested Class Summary
+static classNormality.Dago + +
+          Methods for computing the skewnewss, kurtosis, and D'Agostino-Peasrson K^2 "omnibus" test-statistics (that + combine the former two), and accompanying significance (or p-values) + for testing the underlying population normality.
+ + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + + +
+Method Summary
+static float[]normalProbability(float[] data) + +
+          Return the Normal order statistic medians (N) necessary to produce a Q-Q plot + for a normal distribution (or normal probability plot).
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+normalProbability

+
+public static float[] normalProbability(float[] data)
+
+
Return the Normal order statistic medians (N) necessary to produce a Q-Q plot + for a normal distribution (or normal probability plot). + That is, given a data array, this method computes the Normal order statistic medians + and the ordered response values or z-scores of the input. + A plot of the N vs z should form an approximate straight line if the + data is normally distributed; + departures from this straight line indicate departures from normality with the shape of the line + providing clues as to the distribution of the data. +

+ The normal order statistic medians are computed as +
N[i] = Probability.norminv(U[i]) + where U[i] are the uniform order statistic medians, given by +

    +
    U[i] = 1 - U(n) for i = 1 +
    U[i] = (i - 0.3175)/(n + 0.365) for i = 2, 3, ..., n-1 +
    U[i] = 0.5^(1/n) for i = n +
+

Reference: + NIST/SEMATECH e-Handbook of Statistical Methods, EDA Section 1.3.3.21: Normal Probability Plots +

+

+
+
+
+
Parameters:
data - the data array +
Returns:
the Normal order statistic medians
See Also:
Descriptive.zScore(float[],float,float)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/OneWayAnova.html b/drawing/papaya/reference/papaya/OneWayAnova.html new file mode 100644 index 0000000..e23cef2 --- /dev/null +++ b/drawing/papaya/reference/papaya/OneWayAnova.html @@ -0,0 +1,441 @@ + + + + + + +OneWayAnova (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class OneWayAnova

+
+java.lang.Object
+  extended by papaya.OneWayAnova
+
+
+
+
public class OneWayAnova
extends Object
+ + +

+Computes the one-way ANOVA p-value to test the equality of two or more sample + means by analyzing the sample variances using the test statistic + F = variance between samples / variance within samples. + Once initialized, the following values are computed and stored: +

    +
  • dfbg: degrees of freedom between the groups (dfbg()). +
  • ssbg: sum of squared deviates between the groups (ssbg()). +
  • dfwg: degrees of freedom within the groups, or "Error" dfs (dfwg()). +
  • sswg: sum of squared deviates within the groups (sswg()). +
  • F: the test statistic, computed as (ssbg/dfbg) / (sswg/dfwg) (F()). +
  • pValue: the p-value, or significance level, corresponding to a two-tailed + null hypothesis of no difference between the samples (pValue()). +
+ +

Preconditions:

    +
  • The categoryData Collection must contain + float[] arrays.
  • +
  • There must be at least two float[] arrays in the + categoryData collection and each of these arrays must + contain at least two values.

+ +

This implementation is based on a description provided in Chapter 13 of the VassarStats + online textbook + Mean values are not computed directly in the algorithm as this tends to cause round-off error. + Rather, we use the more stable SumOfSquares - Sum^2: +

+ Sum_(i=1 to n) (x_i - mean(x) )^2 = Sum_(i=1 to n)(x_i)^2 - (Sum_(i=1 to n) x_i)^2/n.
+ 
+

+

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
OneWayAnova(Collection<float[]> categoryData) + +
+          Performs an Analysis of Variance (ANOVA) for a collection of float arrays.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intdfbg() + +
+          Returns the degrees of freedom between groups.
+ intdfwg() + +
+          Returns the degrees of freedom within each group.
+ floatetasqrd() + +
+          Computes eta^2: a measure of the strength of the curvilinear relationship + between the independent and dependent variable.
+ floatF() + +
+          Returns the test statistic F.
+ floatpValue() + +
+          Returns the significance, or "p-value" of the test statistic F().
+ floatssbg() + +
+          Returns the sum of squared deviates between each group.
+ floatsswg() + +
+          Returns the sum of squared deviates of the data within each group.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OneWayAnova

+
+public OneWayAnova(Collection<float[]> categoryData)
+
+
Performs an Analysis of Variance (ANOVA) for a collection of float arrays. +

+

+
Parameters:
categoryData - the data coresponding to the different groups
See Also:
Collection
+
+ + + + + + + + +
+Method Detail
+ +

+etasqrd

+
+public float etasqrd()
+
+
Computes eta^2: a measure of the strength of the curvilinear relationship + between the independent and dependent variable. Useful in the context of + one-way ANOVAs of independent samples. For example, the independent + variable could be the amount of papaya consumed by 4 different groups + (0, 1, 2, or 3 papayas/dar) and the dependent variable could be a measurement of their + satisfaction with life. +

+

+
+
+
+
+ +

+dfbg

+
+public int dfbg()
+
+
Returns the degrees of freedom between groups. That is, + if there are k groups, dfbg = k-1; +

+

+
+
+
+
+ +

+dfwg

+
+public int dfwg()
+
+
Returns the degrees of freedom within each group. That is, + if there are k groups, and each have got n_i elements, + dfwg = (n_1-1) + (n_2 -1) + ... + (n_k - 1); +

+

+
+
+
+
+ +

+F

+
+public float F()
+
+
Returns the test statistic F. That is, +
 
+ F = (ssbg/dfbg) / (sswg/dfwg);
+ 
+

+

+
+
+
+
+ +

+pValue

+
+public float pValue()
+
+
Returns the significance, or "p-value" of the test statistic F(). + That is, +
 
+ p = 1 - Probability.fcdf(F,dfbg,dfwg);
+ 
+

+

+
+
+
+
+ +

+sswg

+
+public float sswg()
+
+
Returns the sum of squared deviates of the data within each group. That is, + if there are k groups, and each have got n_i elements, +
+ sswg = Sum_(i=1 to n1) (xi1-mean(x1))^2 + Sum_(i=1 to n2) (xi2-mean(xk))^2 + ... + Sum_(i=1 to nk) (xik-mean(xk))^2;
+ 
+

+

+
+
+
+
+ +

+ssbg

+
+public float ssbg()
+
+
Returns the sum of squared deviates between each group. That is, + if there are k groups, each with mean value y_i, then +
+ ssbg = Sum_(i=1 to k) (y_i)-mean(y))
+ 
+

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/PapayaConstants.html b/drawing/papaya/reference/papaya/PapayaConstants.html new file mode 100644 index 0000000..ef05b0c --- /dev/null +++ b/drawing/papaya/reference/papaya/PapayaConstants.html @@ -0,0 +1,602 @@ + + + + + + +PapayaConstants (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Interface PapayaConstants

+
+
All Known Implementing Classes:
BoxPlot, Comparison, Correlation, CorrelationPlot, Find, Gamma, Linear, Normality, Probability, ScatterPlot, SubPlot, Visuals
+
+
+
+
public interface PapayaConstants
+ + +

+PapayaConstants stores some of the constants used in plotting. + I try to follow processing's conventions where possible + as specified in processing.core.PConstants + The Processing Javadoc has more details. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intBASELINE + +
+           
+static doublebig + +
+           
+static doublebiginv + +
+           
+static intBOTTOM + +
+           
+static intCENTER + +
+           
+static intCORNER + +
+           
+static StringFONTNAME + +
+          Default font used.
+static int[]GRAY + +
+           
+static intINDEX_NOT_FOUND + +
+          Index to return if a given value/object is not found in the Cast function.
+static int[]INDICES_NOT_FOUND + +
+          Index array to return if a given value/object is not found in the Cast function.
+static intLEFT + +
+           
+static doubleLOGPI + +
+           
+static doubleMACHEP + +
+          machine constants
+static doubleMAXGAM + +
+           
+static doubleMAXLOG + +
+           
+static doubleMINLOG + +
+           
+static intRIGHT + +
+           
+static doubleSQRTH + +
+           
+static doubleSQTPI + +
+           
+static float[]STROKEWEIGHT + +
+           
+static int[]TEXTSIZE + +
+           
+static intTOP + +
+           
+  +

+ + + + + + + + +
+Field Detail
+ +

+BASELINE

+
+static final int BASELINE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+CORNER

+
+static final int CORNER
+
+
+
See Also:
Constant Field Values
+
+
+ +

+BOTTOM

+
+static final int BOTTOM
+
+
+
See Also:
Constant Field Values
+
+
+ +

+CENTER

+
+static final int CENTER
+
+
+
See Also:
Constant Field Values
+
+
+ +

+LEFT

+
+static final int LEFT
+
+
+
See Also:
Constant Field Values
+
+
+ +

+TOP

+
+static final int TOP
+
+
+
See Also:
Constant Field Values
+
+
+ +

+RIGHT

+
+static final int RIGHT
+
+
+
See Also:
Constant Field Values
+
+
+ +

+FONTNAME

+
+static final String FONTNAME
+
+
Default font used. +

+

+
See Also:
Constant Field Values
+
+
+ +

+STROKEWEIGHT

+
+static final float[] STROKEWEIGHT
+
+
+
+
+
+ +

+GRAY

+
+static final int[] GRAY
+
+
+
+
+
+ +

+TEXTSIZE

+
+static final int[] TEXTSIZE
+
+
+
+
+
+ +

+INDEX_NOT_FOUND

+
+static final int INDEX_NOT_FOUND
+
+
Index to return if a given value/object is not found in the Cast function. +

+

+
See Also:
Constant Field Values
+
+
+ +

+INDICES_NOT_FOUND

+
+static final int[] INDICES_NOT_FOUND
+
+
Index array to return if a given value/object is not found in the Cast function. +

+

+
+
+
+ +

+MACHEP

+
+static final double MACHEP
+
+
machine constants +

+

+
See Also:
Constant Field Values
+
+
+ +

+MAXLOG

+
+static final double MAXLOG
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MINLOG

+
+static final double MINLOG
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MAXGAM

+
+static final double MAXGAM
+
+
+
See Also:
Constant Field Values
+
+
+ +

+SQTPI

+
+static final double SQTPI
+
+
+
See Also:
Constant Field Values
+
+
+ +

+SQRTH

+
+static final double SQRTH
+
+
+
See Also:
Constant Field Values
+
+
+ +

+LOGPI

+
+static final double LOGPI
+
+
+
See Also:
Constant Field Values
+
+
+ +

+big

+
+static final double big
+
+
+
See Also:
Constant Field Values
+
+
+ +

+biginv

+
+static final double biginv
+
+
+
See Also:
Constant Field Values
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Polynomial.html b/drawing/papaya/reference/papaya/Polynomial.html new file mode 100644 index 0000000..c1d7f79 --- /dev/null +++ b/drawing/papaya/reference/papaya/Polynomial.html @@ -0,0 +1,347 @@ + + + + + + +Polynomial (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Polynomial

+
+java.lang.Object
+  extended by papaya.Polynomial
+
+
+
+
public final class Polynomial
extends Object
+ + +

+Static Class for casting one variable type to another. +

+ +

+

+
Author:
+
Nur Adila Faruk Senan
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static double[]polyval(double[] x, + double[] coeff) + +
+          y = polyval(x,coeff) returns the array values of a polynomial of degree n evaluated at + each element of x.
+static doublepolyval(double x, + double[] coeff) + +
+          y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x.
+static float[]polyval(float[] x, + float[] coeff) + +
+          y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x.
+static floatpolyval(float x, + float[] coeff) + +
+          y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+polyval

+
+public static double polyval(double x,
+                             double[] coeff)
+                      throws ArithmeticException
+
+
y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. + The input argument coeff is an array of length n+1 whose elements are the coefficients + in descending powers of the polynomial to be evaluated. +

+ y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. +

+

+ E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. +

+

+

+
Parameters:
x - argument to the polynomial.
coeff - the coefficients of the polynomial. +
Throws: +
ArithmeticException
+
+
+
+ +

+polyval

+
+public static double[] polyval(double[] x,
+                               double[] coeff)
+                        throws ArithmeticException
+
+
y = polyval(x,coeff) returns the array values of a polynomial of degree n evaluated at + each element of x. + The input argument coeff is an array of length n+1 whose elements are the coefficients + in descending powers of the polynomial to be evaluated. +

+ y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. +

+

+ E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. +

+

+

+
Parameters:
x - array argument to the polynomial.
coeff - the coefficients of the polynomial. +
Throws: +
ArithmeticException
+
+
+
+ +

+polyval

+
+public static float polyval(float x,
+                            float[] coeff)
+                     throws ArithmeticException
+
+
y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. + The input argument coeff is an array of length n+1 whose elements are the coefficients + in descending powers of the polynomial to be evaluated. +

+ y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. +

+

+ E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. +

+

+

+
Parameters:
x - argument to the polynomial.
coeff - the coefficients of the polynomial. +
Throws: +
ArithmeticException
+
+
+
+ +

+polyval

+
+public static float[] polyval(float[] x,
+                              float[] coeff)
+                       throws ArithmeticException
+
+
y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. + The input argument coeff is an array of length n+1 whose elements are the coefficients + in descending powers of the polynomial to be evaluated. +

+ y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. +

+

+ E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. +

+

+

+
Parameters:
x - array argument to the polynomial.
coeff - the coefficients of the polynomial. +
Throws: +
ArithmeticException
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Probability.html b/drawing/papaya/reference/papaya/Probability.html new file mode 100644 index 0000000..4646e21 --- /dev/null +++ b/drawing/papaya/reference/papaya/Probability.html @@ -0,0 +1,1262 @@ + + + + + + +Probability (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Probability

+
+java.lang.Object
+  extended by papaya.Probability
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class Probability
extends Object
implements PapayaConstants
+ + +

+Cumulative distribution functions and corresponding inverses of certain probability distributions. +

+ Description: +
...cdf signifies the cumulative distribution function and is similar to + the q... functions in R and the ...cdf functions in + MATLAB. The cdf represent the integral, from -infinity to 0 of the + corresponding continuous probability density function (pdf), or, the sum from 0 to
x
+ of an associated finite pdf.
+ +
...inv signifies the inverse of the cumulative distribution function and is similar to + the p... functions in R and the ...inv functions in + MATLAB.
+ +

Implementation: +

    +
  • Direct application examples: +
    normcdf(1.96) = 0.975 --> 97.5% of the curve is within +/-1.96 of 0. +
    norminv(0.975) = 1.96 --> finds the point x (=1.96) such that normcdf(x) = .975. +
    norminv( normcdf(x) ) = x +
  • Significance tests: +
    Two-tailed significance test with alpha = 0.05 and H_0: μ=0 + --> p = 1-alpha/2 = 0.975 + --> Reject null hypothesis μ=0 if + the test statistic is greater or less than than +/-1.96 (= +/- norminv(p) ). + +
    One-tailed significance test with alpha = 0.05 and H_0: μ < 0 + --> p = 1-alpha = 0.95 + --> Reject null hypothesis μ < 0 if + the test statistic is greater than 1.645 (= norminv(p) ). +
    One-tailed significance test with alpha = 0.05 and H_0: μ > 0 + --> p = 1-alpha = 0.95 + --> Reject null hypothesis μ > 0 if + the test statistic is less than -1.645 (= -norminv(p) ). +
+

+ + + The code is partially adapted from the CERN Jet Java libraries, which in turn was adapted from the + Cephes Mathematical Library. As far a as I can tell, Stephen L. Moshier wrote the original C++ code for + CEPHES (1989, moshier@na-net.ornl.gov), Gedeck (at Novartis) and Wolfgang Hoschek (at CERN, hats off to you mate!) + then adapted it for the Java platform, making some significant changes along the way. +
+ 2012 rolls along, and Adila (hello!) finds the library and makes even more changes, increasing the + probability (ha.ha.) of things going massively wrong (pValue<.0001). +

+ +

+


+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static doublebetacdf(double x, + double a, + double b) + +
+          Returns the area from zero to x under the beta density + function.
+static doublebetacdfComplemented(double x, + double a, + double b) + +
+          Returns the area under the right hand tail (from x to + infinity) of the beta density function.
+static doublebetainv(double p, + double a, + double b) + +
+          Returns the inverse of the beta cumulative distribution function.
+static doublebinomcdf(double p, + int k, + int n) + +
+          Returns the sum of the terms 0 through k of the Binomial + probability density.
+static doublebinomcdfComplemented(double p, + int k, + int n) + +
+          Returns the sum of the terms k+1 through n of the Binomial + probability density.
+static doublebinominv(double y, + int k, + int n) + +
+          Finds the event probability p such that the sum of the + terms 0 through k of the Binomial probability density + is equal to the given cumulative probability y.
+static doublechi2cdf(double x, + double v) + +
+          Returns the area under the left hand tail (from 0 to x) + of the Chi square probability density function with + v degrees of freedom.
+static doublechi2cdfComplemented(double x, + double v) + +
+          Returns the area under the right hand tail (from x to + infinity) of the Chi square probability density function + with v degrees of freedom.
+static doubleerf(double x) + +
+          Returns the error function of the normal distribution.
+static doubleerfComplemented(double a) + +
+          Returns the complementary Error function of the normal distribution; formerly named erfc.
+static doublefcdf(double x, + int df1, + int df2) + +
+          Returns the area from zero to x under the F density + function (also known as Snedcor's density or the + variance ratio density); formerly named fdtr.
+static doublefcdfComplemented(double x, + int df1, + int df2) + +
+          Returns the area from x to infinity under the F density + function (also known as Snedcor's density or the + variance ratio density); formerly named fdtrc.
+static doublefinv(double p, + int df1, + int df2) + +
+          Finds the F density argument x such that the integral + from 0 to x of the F density is equal to p; formerly named fdtri.
+static doublegammacdf(double x, + double a, + double b) + +
+          Returns the integral from zero to x of the gamma probability + density function.
+static doublegammacdfComplemented(double x, + double a, + double b) + +
+          Returns the integral from x to infinity of the gamma + probability density function:
+static doublenbinomcdf(double p, + int k, + int n) + +
+          Returns the sum of the terms 0 through k of the Negative Binomial Distribution.
+static doublenbinomcdfComplemented(double p, + int k, + int n) + +
+          Returns the sum of the terms k+1 to infinity of the Negative + Binomial distribution.
+static doublenormcdf(double a) + +
+          Returns the area under the Normal (Gaussian) probability density + function, integrated from minus infinity to x (assumes mean is zero, variance is one).
+static doublenormcdf(double x, + double mean, + double variance) + +
+          Returns the area under the Normal (Gaussian) probability density + function, integrated from minus infinity to x when the + data has not been standardized (i.e.
+static doublenorminv(double y0) + +
+          Returns the value, x, for which the area under the + Normal (Gaussian) probability density function (integrated from + minus infinity to x) is equal to the argument y + (assumes mean is zero, variance is one); formerly named ndtri.
+static doublepoissoncdf(double mean, + int k) + +
+          Returns the sum of the first k terms of the Poisson distribution.
+static doublepoissoncdfComplemented(int k, + double mean) + +
+          Returns the sum of the terms k+1 to Infinity of the Poisson distribution.
+static doubletcdf(double t, + double k) + +
+          Returns the integral from minus infinity to t of the Student-t + distribution with k > 0 degrees of freedom.
+static doubletinv(double p, + double k) + +
+          Returns the value, t, for which the area under the + Student-t probability density function (integrated from + minus infinity to t) is equal to p.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+betacdf

+
+public static double betacdf(double x,
+                             double a,
+                             double b)
+
+
Returns the area from zero to x under the beta density + function. +
+ 
+ P(x) = Γ(a+b) / [ Γ(a) * Γ(b)  ] * Integral_(0 to x) [  t^(a-1) * (1-t)^(b-1) ] dt
+
+ 
+ This function is identical to the incomplete beta + integral function + + Gamma.incompleteBeta(a, b, x). + + The complemented function is betacdfComplemented, specified by + + 1 - P(1-x) = Gamma.incompleteBeta( b, a, x ); +

+

+
+
+
+
+
+
+
+ +

+betacdfComplemented

+
+public static double betacdfComplemented(double x,
+                                         double a,
+                                         double b)
+
+
Returns the area under the right hand tail (from x to + infinity) of the beta density function. + + This function is identical to the incomplete beta + integral function Gamma.incompleteBeta(b, a, x). +

+

+
+
+
+
+
+
+
+ +

+betainv

+
+public static double betainv(double p,
+                             double a,
+                             double b)
+
+
Returns the inverse of the beta cumulative distribution function. + That is, given p, the function finds x such that +
+  Gamma.incompleteBeta( a, b, x ) = beta(x, a, b) = p;
+
+ + This function is identical to the incomplete beta inverse + function Gamma.incompleteBetaInverse(aa, bb, yy0). +

+

+
+
+
+
Parameters:
a - the alpha parameter of the beta distribution.
b - the beta parameter of the beta distribution.
p - the value for which to solve for the corresponding x in the + incomplete Beta integral. +
Returns:
the value x such that beta( a, b, x ) = p.
+
+
+
+ +

+binomcdf

+
+public static double binomcdf(double p,
+                              int k,
+                              int n)
+
+
Returns the sum of the terms 0 through k of the Binomial + probability density. +
+ 
+ Sum_(j=0 to k)  [ (n!)/(j!*(n-j)! ]  *  [ p^j * (1-p)^(n-j) ]
+
+ 
+ The terms are not summed directly; instead the incomplete + beta integral is employed, according to the formula +

+ y = binomcdf( p, k, n) = Gamma.incompleteBeta( n-k, k+1, 1-p ). +

+ All arguments must be positive, +

+

+
+
+
+
Parameters:
k - end term.
n - the number of trials.
p - the probability of success (must be in (0.0,1.0)).
+
+
+
+ +

+binomcdfComplemented

+
+public static double binomcdfComplemented(double p,
+                                          int k,
+                                          int n)
+
+
Returns the sum of the terms k+1 through n of the Binomial + probability density. +
+ 
+ Sum_(j=k+1 to n)  [ (n!)/(j!*(n-j)! ]  *  [ p^j * (1-p)^(n-j) ]
+
+ 
+ The terms are not summed directly; instead the incomplete + beta integral is employed, according to the formula +

+ y = binomcdfComplemented( p, k, n ) = Gamma.incompleteBeta( k+1, n-k, p ). +

+ All arguments must be positive, +

+

+
+
+
+
Parameters:
k - (start-1) term.
n - the number of trials.
p - the probability of success (must be in (0.0,1.0)).
+
+
+
+ +

+binominv

+
+public static double binominv(double y,
+                              int k,
+                              int n)
+
+
Finds the event probability p such that the sum of the + terms 0 through k of the Binomial probability density + is equal to the given cumulative probability y. That is, +
+ binomcdf( p, k, n ) = y;
+
+ This is accomplished using the inverse beta integral + function and the relation +

+ 1 - p = Gamma.incompleteBetaInverse( n-k, k+1, y ). +

+ All arguments must be positive. +

+

+
+
+
+
Parameters:
k - end term.
n - the number of trials.
y - the value to solve for such that binomcdf( p, k, n ) = y.
+
+
+
+ +

+chi2cdf

+
+public static double chi2cdf(double x,
+                             double v)
+                      throws ArithmeticException
+
+
Returns the area under the left hand tail (from 0 to x) + of the Chi square probability density function with + v degrees of freedom. +
+ 
+ P( x | v ) = 1/ [ 2^(v/2) * Γ(v/2)  ] * Integral_(from 0 to x) [ t^(v/2-1) * e^(-t/2) ] dt
+                                  
+ 
+ where x is the Chi-square variable. +

+ The incomplete gamma integral is used, according to the + formula +

+ y = chi2cdf( x, v ) = Gamma.incompleteGamma( v/2.0, x/2.0 ). +

+ The arguments must both be positive. +

+

+
+
+
+
Parameters:
v - degrees of freedom.
x - integration end point. +
Throws: +
ArithmeticException
+
+
+
+ +

+chi2cdfComplemented

+
+public static double chi2cdfComplemented(double x,
+                                         double v)
+                                  throws ArithmeticException
+
+
Returns the area under the right hand tail (from x to + infinity) of the Chi square probability density function + with v degrees of freedom. +
+ 
+ P( x | v ) = 1/ [ 2^(v/2) * Γ(v/2)  ] * Integral_(from x to infinity) [ t^(v/2-1) * e^(-t/2) ] dt
+
+ 
+ where x is the Chi-square variable. + + The incomplete gamma integral is used, according to the + formula + + y = chi2cdfComplemented( x, v ) = incompleteGammaComplement( v/2.0, x/2.0 ). + + The arguments must both be positive. +

+

+
+
+
+
Parameters:
v - degrees of freedom.
x - integration start point. +
Throws: +
ArithmeticException
+
+
+
+ +

+erf

+
+public static double erf(double x)
+                  throws ArithmeticException
+
+
Returns the error function of the normal distribution. + The integral is +
+ 
+ erf(x) = 2/sqrt(PI) * Integral_(0 to x) [ e^(-t^2) ] dt
+                           
+ 
+ Implementation: + For 0 <= |x| < 1, erf(x) = x * P4(x^2)/Q5(x^2) ; otherwise + erf(x) = 1 - erfc(x). +

+

+

+
+
+
+
Parameters:
x - the integral end point. +
Throws: +
ArithmeticException
+
+
+
+ +

+erfComplemented

+
+public static double erfComplemented(double a)
+                              throws ArithmeticException
+
+
Returns the complementary Error function of the normal distribution; formerly named erfc. +
+ 
+  erfc(x) = 2/sqrt(PI) * Integral_(x to inf) [ e^(-t^2) ] dt
+                = 1 - 2/sqrt(PI) * Integral_(0 to x) [ e^(-t^2) ] dt
+                = 1 - erf(x).
+                          
+ 
+ Implementation: + For small x, erfc(x) = 1 - erf(x); otherwise rational + approximations are computed. +

+

+

+
+
+
+
Parameters:
a - corresponds to x above. An internal check is performed to see if + a is < 0 or otherwise. If a < 0 --> x = -a. Else, x = a. +
Throws: +
ArithmeticException
+
+
+
+ +

+fcdf

+
+public static double fcdf(double x,
+                          int df1,
+                          int df2)
+
+
Returns the area from zero to x under the F density + function (also known as Snedcor's density or the + variance ratio density); formerly named fdtr. + Corresponds to the left hand tail of the F-distribution. + + The incomplete beta integral is used, according to the formula +
+
+ P(x) = Gamma.incompleteBeta( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
+
+ 
+

+

+
+
+
+
Parameters:
df1 - ( greater than or equal to 1 )
df2 - ( greater than or equal to 1 )
x - the integration end point (greater than or equal to 0).
+
+
+
+ +

+fcdfComplemented

+
+public static double fcdfComplemented(double x,
+                                      int df1,
+                                      int df2)
+
+
Returns the area from x to infinity under the F density + function (also known as Snedcor's density or the + variance ratio density); formerly named fdtrc. + Corresponds to the right hand tail of the F-distribution ( and + to the values presented in F-distribution tables). + + The incomplete beta integral is used, according to the + relation +
+ 
+ P(x) = Gamma.incompleteBeta( df2/2, df1/2, (df2/(df2 + df1*x) )
+ 
+ 
+

+

+
+
+
+
Parameters:
df1 - df1 ( greater than or equal to 1 )
df2 - df2 ( greater than or equal to 1 )
x - the left integration point. Corresponds to the F value in look-up tables. +
Returns:
The area from x to inf. under the F density function.
+
+
+
+ +

+finv

+
+public static double finv(double p,
+                          int df1,
+                          int df2)
+
+
Finds the F density argument x such that the integral + from 0 to x of the F density is equal to p; formerly named fdtri. + That is, it solves for the value of x, given p such that +
+ fcdf(x,df1,df2) - p = 0.
+ 
+ + This is accomplished using the inverse beta integral + function and the relations +
+ z = incompleteBetaInverse( df2/2, df1/2, p ),
+ x = 1 - df2 * (1-z) / (df1 z),
+
+ if p > Gamma.incompleteBeta( 0.5*df1, 0.5*df2, 0.5 );, or p < 0.001 and, +
+ z = incompleteBetaInverse( df1/2, df2/2, p ),
+ x = 1 - df2 * z / (df1 (1-z)),
+ 
+ otherwise. + The significance level for a one-sided test (or α in look-up tables) is then 1-x +

+

+
+
+
+
Parameters:
df1 - degrees of freedom of the first dataset
df2 - degrees of freedom of the second dataset
p - the fcdf value for which to solve for x +
Returns:
the point x such that fcdf(x,df1,df2) = p. +
Throws: +
IllegalArgumentException - if df1 or df2 are less than 1, or p is not in (0,1].
+
+
+
+ +

+gammacdf

+
+public static double gammacdf(double x,
+                              double a,
+                              double b)
+
+
Returns the integral from zero to x of the gamma probability + density function. +
+ 
+ y = a^b / Γ(b) * Integral_(0 to x) [ t^(b-1) e^(-a*t) ]dt
+
+ 
+ The incomplete gamma integral is used, according to the + relation + + y = Gamma.incompleteGamma( b, a*x ). +

+

+
+
+
+
Parameters:
a - the paramater a (alpha) of the gamma distribution.
b - the paramater b (beta, lambda) of the gamma distribution.
x - integration end point. +
Returns:
y the integral from zero to x of the gamma pdf.
+
+
+
+ +

+gammacdfComplemented

+
+public static double gammacdfComplemented(double x,
+                                          double a,
+                                          double b)
+
+
Returns the integral from x to infinity of the gamma + probability density function: +
+ 
+ y = a^b / Γ(b) * Integral_(from x to infinity) [t^(b-1) * e^(-a*t) ] dt
+
+ 
+ The incomplete gamma integral is used, according to the + relation +

+ y = Gamma.incompleteGammaComplement( b, a*x ). +

+

+
+
+
+
Parameters:
a - the paramater a (alpha) of the gamma distribution.
b - the paramater b (beta, lambda) of the gamma distribution.
x - integration start point.
+
+
+
+ +

+nbinomcdf

+
+public static double nbinomcdf(double p,
+                               int k,
+                               int n)
+
+
Returns the sum of the terms 0 through k of the Negative Binomial Distribution. +
+ 
+ Sum_(from j=0 to k)  [ (n+j-1)! / ( j! * (n-1)! ) ] * [ p^n* (1-p)^j ]
+   
+ 
+ In a sequence of Bernoulli trials, this is the probability + that k or fewer failures precede the n-th success. +

+ The terms are not computed individually; instead the incomplete + beta integral is employed, according to the formula +

+ y = nbinomcdf( p, k, n ) = Gamma.incompleteBeta( n, k+1, p ). + + All arguments must be positive, +

+

+
+
+
+
Parameters:
k - end term.
n - the number of trials.
p - the probability of success (must be in (0.0,1.0)).
+
+
+
+ +

+nbinomcdfComplemented

+
+public static double nbinomcdfComplemented(double p,
+                                           int k,
+                                           int n)
+
+
Returns the sum of the terms k+1 to infinity of the Negative + Binomial distribution. +
+ 
+ Sum_(from j=k+1 to inf)  [ (n+j-1)! / ( j! * (n-1)! ) ] * [ p^n* (1-p)^j ]
+ 
+ 
+ The terms are not computed individually; instead the incomplete + beta integral is employed, according to the formula +

+ y = nbinomcdfComplemented( p, k, n ) = Gamma.incompleteBeta( k+1, n, 1-p ). + + All arguments must be positive, +

+

+
+
+
+
Parameters:
k - (start-1) term.
n - the number of trials.
p - the probability of success (must be in (0.0,1.0)).
+
+
+
+ +

+normcdf

+
+public static double normcdf(double a)
+                      throws ArithmeticException
+
+
Returns the area under the Normal (Gaussian) probability density + function, integrated from minus infinity to x (assumes mean is zero, variance is one). +
+ 
+ normcdf(x) = 1/sqrt(2pi) * Integral_(-inf to x) [ e^(-t^2/2) ] dt
+           =  ( 1 + erf(z) ) / 2
+           =  erfc(z) / 2
+           
+ 
+ where z = x/sqrt(2). + Computation is via the functions erf and erfComplement. +

+ Relation to alpha value (or confidence level): +

    +
    Two tailed test: alpha = 2*( 1-normcdf(x) ).
    +
    one-tailed test: alpha = ( 1-normcdf(x) ).
    +
+

+

+

+
+
+
+
Parameters:
a - x in the equation above. +
Throws: +
ArithmeticException
+
+
+
+ +

+normcdf

+
+public static double normcdf(double x,
+                             double mean,
+                             double variance)
+                      throws ArithmeticException
+
+
Returns the area under the Normal (Gaussian) probability density + function, integrated from minus infinity to x when the + data has not been standardized (i.e. mean ≠0, variance ≠1). +
+  
+ normcdf(x,mean,variance) = 1/sqrt(2pi*v) * Integral_(-inf to x) [ e^(-(t-mean)^2 / 2v) ] dt
+
+ 
+ where v = variance. + Computation is via the functions erf. +

+

+
+
+
+
Parameters:
mean - the mean of the normal distribution.
variance - the variance of the normal distribution.
x - the integration limit. +
Throws: +
ArithmeticException
+
+
+
+ +

+norminv

+
+public static double norminv(double y0)
+                      throws ArithmeticException
+
+
Returns the value, x, for which the area under the + Normal (Gaussian) probability density function (integrated from + minus infinity to x) is equal to the argument y + (assumes mean is zero, variance is one); formerly named ndtri. + That is, +

+ normcdf(x) = y0. +

+

+ For small arguments 0 < y < exp(-2), the program computes + z = sqrt( -2.0 * log(y) ); then the approximation is + x = z - log(z)/z - (1/z) P(1/z) / Q(1/z). + There are two rational functions P/Q, one for 0 < y < exp(-32) + and the other for y up to exp(-2). + For larger arguments, + w = y - 0.5, and x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)). + Finally, this returns -infinity for y0 = 0 + and +infinity for y0 = 1. +

+

+
+
+
+
Parameters:
y0 - the argument to the function +
Throws: +
ArithmeticException
+
+
+
+ +

+poissoncdf

+
+public static double poissoncdf(double mean,
+                                int k)
+                         throws ArithmeticException
+
+
Returns the sum of the first k terms of the Poisson distribution. +
+ 
+ Sum_(j=0 to k) [ e^(-m) *  m^j /j! ]
+
+ 
+ The terms are not summed directly; instead the incomplete + gamma integral is employed, according to the relation +

+ y = poissoncdf( mean, k m ) = Gamma.incompleteGammaComplement( k+1, mean ). + + The arguments must both be positive. +

+

+
+
+
+
Parameters:
k - number of terms.
mean - the mean of the poisson distribution. +
Throws: +
ArithmeticException
+
+
+
+ +

+poissoncdfComplemented

+
+public static double poissoncdfComplemented(int k,
+                                            double mean)
+                                     throws ArithmeticException
+
+
Returns the sum of the terms k+1 to Infinity of the Poisson distribution. +
+  
+ Sum_(j=k+1 to inf.) [ e^(-m) *  m^j /j! ]
+ 
+ 
+ The terms are not summed directly; instead the incomplete + gamma integral is employed, according to the formula +

+ y = poissoncdfComplemented( k, m ) = Gamma.incompleteGamma( k+1, m ). + + The arguments must both be positive. +

+

+
+
+
+
Parameters:
k - (start-1) term.
mean - the mean of the poisson distribution. +
Throws: +
ArithmeticException
+
+
+
+ +

+tcdf

+
+public static double tcdf(double t,
+                          double k)
+                   throws ArithmeticException
+
+
Returns the integral from minus infinity to t of the Student-t + distribution with k > 0 degrees of freedom. +
+ 
+ Γ((k+1)/2) / [ sqrt(k*pi) * Γ(k/2)  ] * Integral_(-inf to t) [  ( 1+x^2/k )^( (-k+1)/2 ) ] dx
+ 
+ 
+ Relation to incomplete beta integral: +

+
tcdf(t,k) = 0.5 * Gamma.incompleteBeta( k/2, 1/2, z ), when t < 0,
+
tcdf(t,k) = 1-0.5 * Gamma.incompleteBeta( k/2, 1/2, z ), when t > 0,
+

+ where z = k/(k + t^2). + Relation to alpha value (or confidence level): +
    +
    Two tailed test: alpha = 2*( 1-tcdf(t,k) ).
    +
    one-tailed test: alpha = ( 1-tcdf(t,k) ).
    +
+

+

+
+
+
+
Parameters:
k - degrees of freedom.
t - integration end point. +
Throws: +
ArithmeticException
+
+
+
+ +

+tinv

+
+public static double tinv(double p,
+                          double k)
+
+
Returns the value, t, for which the area under the + Student-t probability density function (integrated from + minus infinity to t) is equal to p. + The function uses the tcdf function to determine the return + value iteratively. +

+

+
+
+
+
Parameters:
p - the fcdf value for which to solve for x
k - the degrees of freedom
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/QR.html b/drawing/papaya/reference/papaya/QR.html new file mode 100644 index 0000000..effc2b8 --- /dev/null +++ b/drawing/papaya/reference/papaya/QR.html @@ -0,0 +1,398 @@ + + + + + + +QR (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class QR

+
+java.lang.Object
+  extended by papaya.QR
+
+
+
+
public class QR
extends Object
+ + +

+QR Decomposition. +

+ For an m-by-n matrix A with m ≥ n, the QR decomposition is an m-by-n + orthogonal matrix Q and an n-by-n upper triangular matrix R so that + A = Q*R. +

+ The QR decompostion always exists, even if the matrix does not have + full rank, so the constructor will never fail. The primary use of the + QR decomposition is in the least squares solution of nonsquare systems + of simultaneous linear equations. This will fail if isFullRank() + returns false. +

+Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +Cast.doubleToFloat(double[][]) if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
QR(float[][] A) + +
+          QR Decomposition, computed by Householder reflections.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ double[][]getH() + +
+          Return the Householder vectors
+ double[][]getQ() + +
+          Generate and return the (economy-sized) orthogonal factor
+ double[][]getR() + +
+          Return the upper triangular factor
+ booleanisFullRank() + +
+          Is the matrix full rank?
+ double[]solve(float[] b) + +
+          Least squares solution of A*X = b
+ double[][]solve(float[][] B) + +
+          Least squares solution of A*X = B
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+QR

+
+public QR(float[][] A)
+
+
QR Decomposition, computed by Householder reflections. +

+

+
Parameters:
A - Rectangular matrix
+
+ + + + + + + + +
+Method Detail
+ +

+isFullRank

+
+public boolean isFullRank()
+
+
Is the matrix full rank? +

+

+ +
Returns:
true if R, and hence A, has full rank.
+
+
+
+ +

+getH

+
+public double[][] getH()
+
+
Return the Householder vectors +

+

+ +
Returns:
Lower trapezoidal matrix whose columns define the reflections
+
+
+
+ +

+getR

+
+public double[][] getR()
+
+
Return the upper triangular factor +

+

+ +
Returns:
R
+
+
+
+ +

+getQ

+
+public double[][] getQ()
+
+
Generate and return the (economy-sized) orthogonal factor +

+

+ +
Returns:
Q
+
+
+
+ +

+solve

+
+public double[] solve(float[] b)
+
+
Least squares solution of A*X = b +

+

+
Parameters:
b - An array with the same length as the number of rows in A. +
Returns:
x that minimizes the two norm of Q*R*x-b. +
Throws: +
IllegalArgumentException - Matrix row dimensions must agree. +
RuntimeException - Matrix is rank deficient.
+
+
+
+ +

+solve

+
+public double[][] solve(float[][] B)
+
+
Least squares solution of A*X = B +

+

+
Parameters:
B - A Matrix with as many rows as A and any number of columns. +
Returns:
X that minimizes the two norm of Q*R*X-B. +
Throws: +
IllegalArgumentException - Matrix row dimensions must agree. +
RuntimeException - Matrix is rank deficient.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Rank.html b/drawing/papaya/reference/papaya/Rank.html new file mode 100644 index 0000000..7648e92 --- /dev/null +++ b/drawing/papaya/reference/papaya/Rank.html @@ -0,0 +1,464 @@ + + + + + + +Rank (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Rank

+
+java.lang.Object
+  extended by papaya.Rank
+
+
+
+
public class Rank
extends Object
+ + +

+

Ranking based on the natural ordering on floats for a sequence of data that may also + contain NaNs.

+

When present, NaNs are treated according to the configured NaNStrategy constants and ties + are handled using the configured tiesStrategy constants as follows: + +

Strategies for handling NaN values in rank transformations. +

    +
  • 0 (REMOVED, default) - NaNs are removed before the rank transform is applied
  • +
  • 1 (MINIMAL) - NaNs are treated as minimal in the ordering, equivalent to + (that is, tied with) Float.NEGATIVE_INFINITY.
  • +
  • 2 (MAXIMAL) - NaNs are treated as maximal in the ordering, equivalent to + Float.POSITIVE_INFINITY
  • +
  • 3 (FIXED) - NaNs are left "in place," that is the rank transformation is + applied to the other elements in the input array, but the NaN elements + are returned unchanged.
  • +
+

+ +

Strategies for handling tied values in rank transformations: +

    +
  • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
  • +
  • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
  • +
  • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
  • +
  • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + for example (1,3,4,3) is ranked as (1,2,4,3)
  • +
+

+ + The defaults are 0 (REMOVED) and 0 (AVERAGE) for the NaNStrategy and TiesStrategy respectively. + +

Examples: + + + + + + + + + + + + + + + + + + + + + + + +
+ Input data: (20, 17, 30, 42.3, 17, 50, Float.NaN, Float.NEGATIVE_INFINITY, 17) +
NaNStrategyTiesStrategyrank(data)
0 (default = NaNs removed)0 (default = ties averaged)(5, 3, 6, 7, 3, 8, 1, 3)
0 (default = NaNs removed)1 (MINIMUM)(5, 2, 6, 7, 2, 8, 1, 2)
1 (MINIMAL)0 (default = ties averaged)(6, 4, 7, 8, 4, 9, 1.5, 1.5, 4)
1 (MINIMAL)2 (MAXIMUM)(6, 5, 7, 8, 5, 9, 2, 2, 5)
2 (MAXIMAL)2 (MAXIMUM)/td> + (5, 4, 6, 7, 4, 8, 9, 1, 4)

+ + (Code adapted from the org.apache.commons.math.stat.ranking package, and modified extensively). +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static float[]rank(float[] data, + int tiesStrategy) + +
+          Rank an array (with no NaNs) using the natural ordering on Floats with ties + resolved using tiesStrategy.
+static float[]rank(float[] data, + int tiesStrategy, + int nanStrategy) + +
+          Rank an array containing NaN values using the natural ordering on Floats, with + NaN values handled according to nanStrategy and ties + resolved using tiesStrategy.
+static float[]rank(int[] data, + int tiesStrategy) + +
+          Rank an array (with no NaNs) using the natural ordering on Floats with ties + resolved using tiesStrategy.
+static float[]rank(int[] data, + int tiesStrategy, + int nanStrategy) + +
+          Rank an array containing NaN values using the natural ordering on Floats, with + NaN values handled according to nanStrategy and ties + resolved using tiesStrategy.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+rank

+
+public static float[] rank(int[] data,
+                           int tiesStrategy,
+                           int nanStrategy)
+
+
Rank an array containing NaN values using the natural ordering on Floats, with + NaN values handled according to nanStrategy and ties + resolved using tiesStrategy. + +

Input values that specify which strategy to use for handling tied values in the + rank transformations: +

    +
  • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
  • +
  • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
  • +
  • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
  • +
  • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + for example (1,3,4,3) is ranked as (1,2,4,3)
  • +
+

+ +

Input values that specify which strategy to use for handling NaN values in the + rank transformations: +

    +
  • 0 (REMOVED, default) - NaNs are removed before the rank transform is applied
  • +
  • 1 (MINIMAL) - NaNs are treated as minimal in the ordering, equivalent to + (that is, tied with) Float.NEGATIVE_INFINITY.
  • +
  • 2 (MAXIMAL) - NaNs are treated as maximal in the ordering, equivalent to + Float.POSITIVE_INFINITY
  • +
  • 3 (FIXED) - NaNs are left "in place," that is the rank transformation is + applied to the other elements in the input array, but the NaN elements + are returned unchanged.
  • +
+

+ If the data array has no NaN values, use rank(float[], int) instead. It is quicker. +

+

+
Parameters:
data - array to be ranked. This is cast to a float array prior to ranking.
nanStrategy - 0,1,2 or 3 corresponding to the NaN strategy to employ.
tiesStrategy - 0,1,2 or 3 corresponding to the ties strategy to employ. +
Returns:
array of ranks
+
+
+
+ +

+rank

+
+public static float[] rank(float[] data,
+                           int tiesStrategy,
+                           int nanStrategy)
+
+
Rank an array containing NaN values using the natural ordering on Floats, with + NaN values handled according to nanStrategy and ties + resolved using tiesStrategy. + +

Input values that specify which strategy to use for handling tied values in the + rank transformations: +

    +
  • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
  • +
  • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
  • +
  • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
  • +
  • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + for example (1,3,4,3) is ranked as (1,2,4,3)
  • +
+

+ +

Input values that specify which strategy to use for handling NaN values in the + rank transformations: +

    +
  • 0 (REMOVED, default) - NaNs are removed before the rank transform is applied
  • +
  • 1 (MINIMAL) - NaNs are treated as minimal in the ordering, equivalent to + (that is, tied with) Float.NEGATIVE_INFINITY.
  • +
  • 2 (MAXIMAL) - NaNs are treated as maximal in the ordering, equivalent to + Float.POSITIVE_INFINITY
  • +
  • 3 (FIXED) - NaNs are left "in place," that is the rank transformation is + applied to the other elements in the input array, but the NaN elements + are returned unchanged.
  • +
+

+ If the data array has no NaN values, use rank(float[], int) instead. It is quicker. +

+

+
Parameters:
data - array to be ranked
nanStrategy - 0,1,2 or 3 corresponding to the NaN strategy to employ.
tiesStrategy - 0,1,2 or 3 corresponding to the ties strategy to employ. +
Returns:
array of ranks
+
+
+
+ +

+rank

+
+public static float[] rank(int[] data,
+                           int tiesStrategy)
+
+
Rank an array (with no NaNs) using the natural ordering on Floats with ties + resolved using tiesStrategy. +

Input values that specify which strategy to use for handling NaN values in the + rank transformations: +

    +
  • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
  • +
  • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
  • +
  • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
  • +
  • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + for example (1,3,4,3) is ranked as (1,2,4,3)
  • +
+

+

+

+
Parameters:
data - array to be ranked. The array is cast to a float array prior to ranking
tiesStrategy - the strategy to employ for ties. +
Returns:
array of ranks
+
+
+
+ +

+rank

+
+public static float[] rank(float[] data,
+                           int tiesStrategy)
+
+
Rank an array (with no NaNs) using the natural ordering on Floats with ties + resolved using tiesStrategy. +

Input values that specify which strategy to use for handling NaN values in the + rank transformations: +

    +
  • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
  • +
  • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
  • +
  • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
  • +
  • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + for example (1,3,4,3) is ranked as (1,2,4,3)
  • +
+

+

+

+
Parameters:
data - array to be ranked.
tiesStrategy - the strategy to employ for ties. +
Returns:
array of ranks
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/SVD.html b/drawing/papaya/reference/papaya/SVD.html new file mode 100644 index 0000000..aab308c --- /dev/null +++ b/drawing/papaya/reference/papaya/SVD.html @@ -0,0 +1,417 @@ + + + + + + +SVD (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class SVD

+
+java.lang.Object
+  extended by papaya.SVD
+
+
+
+
public class SVD
extends Object
+ + +

+Singular Value Decomposition. +

+For an m x n matrix A with m > n, +the singular value decomposition is an m-by-n orthogonal matrix +U, an n-by-n diagonal matrix S, and +an n-by-n orthogonal matrix V so that A = U*S*V'. +

+The singular values, sigma[k] = S[k][k], are ordered so that +sigma[0] > sigma[1] > ... > sigma[n-1]. +

+The singular value decompostion always exists, so the constructor will +never fail. The matrix condition number and the effective numerical +rank can be computed from this decomposition. +

+Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +Cast.doubleToFloat(double[][]) if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
SVD(float[][] AA) + +
+          Construct the singular value decomposition.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ doublecond() + +
+          Two norm condition number
+ double[][]getS() + +
+          Return the diagonal matrix of singular values
+ double[]getSingularValues() + +
+          Return the one-dimensional array of singular values
+ double[][]getU() + +
+          Return the left singular vectors
+ double[][]getV() + +
+          Return the right singular vectors
+ doublenorm2() + +
+          Two norm
+ intrank() + +
+          Effective numerical matrix rank
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+SVD

+
+public SVD(float[][] AA)
+
+
Construct the singular value decomposition. At the end of this call, + U, V, and S have been computed. +

+

+
Parameters:
AA - Rectangular matrix
+
+ + + + + + + + +
+Method Detail
+ +

+getU

+
+public double[][] getU()
+
+
Return the left singular vectors +

+

+ +
Returns:
U
+
+
+
+ +

+getV

+
+public double[][] getV()
+
+
Return the right singular vectors +

+

+ +
Returns:
V
+
+
+
+ +

+getSingularValues

+
+public double[] getSingularValues()
+
+
Return the one-dimensional array of singular values +

+

+ +
Returns:
diagonal of S.
+
+
+
+ +

+getS

+
+public double[][] getS()
+
+
Return the diagonal matrix of singular values +

+

+ +
Returns:
S
+
+
+
+ +

+norm2

+
+public double norm2()
+
+
Two norm +

+

+ +
Returns:
max(S)
+
+
+
+ +

+cond

+
+public double cond()
+
+
Two norm condition number +

+

+ +
Returns:
max(S)/min(S)
+
+
+
+ +

+rank

+
+public int rank()
+
+
Effective numerical matrix rank +

+

+ +
Returns:
Number of nonnegligible singular values.
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/ScatterPlot.html b/drawing/papaya/reference/papaya/ScatterPlot.html new file mode 100644 index 0000000..f58a4bf --- /dev/null +++ b/drawing/papaya/reference/papaya/ScatterPlot.html @@ -0,0 +1,609 @@ + + + + + + +ScatterPlot (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class ScatterPlot

+
+java.lang.Object
+  extended by papaya.Visuals
+      extended by papaya.ScatterPlot
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class ScatterPlot
extends Visuals
+ + +

+A simple class to plot x vs y data as a + scatter plot. Default is to draw the points as ellipses, + but you can also use rectangles, and connect the points with + lines. +

+ +

+

+
Author:
+
Adila Faruk
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+ booleanasConnectedLines + +
+           
+ booleanasEllipses + +
+           
+ booleanasRectangles + +
+           
+ floatbottomBound + +
+          Specifies the space on the bottom, between the plot area and the bounding + rectangle.
+ booleandrawAxes + +
+          Specifies whether to draw the axes
+ booleandrawRectangle + +
+          Specifies whether to draw the bounding rectangle around the plot.
+ floatleftBound + +
+          Specifies the space on the left between the plot area, and the + bounding rectangle.
+ floatrightBound + +
+          Specifies the space on the right betweent the plot area, and the + bounding rectangle.
+ floattopBound + +
+          Specifies the space on the top, between the plot area and the bounding + rectangle.
+ boolean[]XYLabels + +
+           
+ boolean[]XYTicks + +
+           
+ + + + + + + +
Fields inherited from class papaya.Visuals
bgColor
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
ScatterPlot(PApplet _theParent, + float _plotLeft, + float _plotTop, + float _plotWidth, + float _plotHeight) + +
+           
+  + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiddrawRectangle() + +
+          Draws a rectangle around the plot.
+ voiddrawScatterPlot(float[] _xDat, + float[] _yDat, + float _sWeight, + int _sColor) + +
+          Parent function to plot scatter plot of the data.
+ voidsetDataExtremes(float _minXDat, + float _maxXDat, + float _minYDat, + float _maxYDat) + +
+          Set the minimum/maximum values on the x and y axis to nice numbers.
+ + + + + + + +
Methods inherited from class papaya.Visuals
drawAxes, drawRect, drawRect, getBottom, getHeight, getLeft, getRight, getTop, getWidth, horizLine, legendHoriz, legendVert, line, mapXData, mapXData, mapYData, mapYData, setBackgroundColor, setHeight, setLeft, setTop, setupFont, setupFont, setWidth, vertLine, writeLabels, writeLabels, writeLabels, writeLabels, writeLabels, writeTitle, xLabels, xLabels, xTicks, yLabels, yLabels, YLines, yTicks
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+asConnectedLines

+
+public boolean asConnectedLines
+
+
+
+
+
+ +

+asRectangles

+
+public boolean asRectangles
+
+
+
+
+
+ +

+asEllipses

+
+public boolean asEllipses
+
+
+
+
+
+ +

+XYLabels

+
+public boolean[] XYLabels
+
+
+
+
+
+ +

+XYTicks

+
+public boolean[] XYTicks
+
+
+
+
+
+ +

+drawRectangle

+
+public boolean drawRectangle
+
+
Specifies whether to draw the bounding rectangle around the plot. +

+

+
+
+
+ +

+drawAxes

+
+public boolean drawAxes
+
+
Specifies whether to draw the axes +

+

+
+
+
+ +

+leftBound

+
+public float leftBound
+
+
Specifies the space on the left between the plot area, and the + bounding rectangle. That is, the left-most point of + the rectangle is given by plotLeft-leftBound. +

+

+
+
+
+ +

+rightBound

+
+public float rightBound
+
+
Specifies the space on the right betweent the plot area, and the + bounding rectangle. That is, the right-most point of + the rectangle is given by plotLeft+plotWidth+rightBound. +

+

+
+
+
+ +

+topBound

+
+public float topBound
+
+
Specifies the space on the top, between the plot area and the bounding + rectangle. That is, the top-most point of the rectangle is given by + plotTop - topBound. +

+

+
+
+
+ +

+bottomBound

+
+public float bottomBound
+
+
Specifies the space on the bottom, between the plot area and the bounding + rectangle. That is, the bottom-most point of the rectangle is given by + plotTop + plotHeight + bottomBound. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+ScatterPlot

+
+public ScatterPlot(PApplet _theParent,
+                   float _plotLeft,
+                   float _plotTop,
+                   float _plotWidth,
+                   float _plotHeight)
+
+
+ + + + + + + + +
+Method Detail
+ +

+setDataExtremes

+
+public void setDataExtremes(float _minXDat,
+                            float _maxXDat,
+                            float _minYDat,
+                            float _maxYDat)
+
+
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. + It'll try do it automatically for you, if you don't set it here, + but no guarantees on the result being a nice number. For example, it might + go from 61 to 89 instead of 60 to 90. +

+

+
Parameters:
_minXDat - the minimum x value to use. Set to more than the x data minimum.
_maxXDat - the maximum x value to use. Set to more than the x data maximum.
_minYDat - the minimum y value to use. Set to more than the y data minimum.
_maxYDat - the maximum y value to use. Set to more than the y data maximum.
+
+
+
+ +

+drawRectangle

+
+public void drawRectangle()
+
+
Draws a rectangle around the plot. +
    +
  • Left most point: plotLeft-leftBound
  • +
  • Top most point: plotTop-topBound
  • +
  • Width: plotWidth+leftBound+rightBound
  • +
  • Height: plotHeight+topBound+bottomBound
  • +
+

+

+
+
+
+
+ +

+drawScatterPlot

+
+public void drawScatterPlot(float[] _xDat,
+                            float[] _yDat,
+                            float _sWeight,
+                            int _sColor)
+
+
Parent function to plot scatter plot of the data. +

+

+
Parameters:
_xDat - x Data array
_yDat - y Data array
_sWeight - stroke weight
_sColor - stroke color
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Sorting.html b/drawing/papaya/reference/papaya/Sorting.html new file mode 100644 index 0000000..08646bf --- /dev/null +++ b/drawing/papaya/reference/papaya/Sorting.html @@ -0,0 +1,521 @@ + + + + + + +Sorting (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Sorting

+
+java.lang.Object
+  extended by papaya.Sorting
+
+
+
+
public final class Sorting
extends Object
+ + +

+Class for getting the array of indices that can be used to sort the array in ascending or + descending order. This is especially useful if you want to preserve the ordering of + your original array, or if you want to manipulate more than one array according to the + sorted order of only one of them. +

+ For example, assume we have three arrays X, Y and Z. We want to sort all three arrays by + X (or some arbitrary comparison function). For example, we have
+ X={3, 2, 1}, Y={3.0, 1.0, 2.0}, Z={6.0, 7.0, 8.0}. The output should + be +
+ X={1, 2, 3}, Y={2.0, 1.0, 3.0}, Z={8.0, 7.0, 6.0}
. + To do this, we can use the indices corresponding to the elements of X sorted + in ascending order: +

+ X={3,2,1} so indicesForSorting = {2,1,0} + (X[2] holds the smallest value of X, + X[1] holds the next smallest value of X, and X[0] + holds the largest value of X). + The indicesForSorting can then be used to arrange Y and Z + in the same order. + +

+ The algorithm used to obtain these indices is a modified version of the + tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + Sort Function", Software-Practice and Experience, Vol. 23(11) + P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + to sort arrays). +

It is a modified version in the sense that the original array remains unsorted. Instead, + a copy of the original array is used in the sorting routine, and the array of + indices [0,1,2,...N-1] sorted concurrently with the array being sorted. +

+ +

+

+
Author:
+
Adila Faruk
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static int[]indices(double[] a, + boolean isAscending) + +
+           
+static int[]indices(double[] a, + int fromIndex, + int toIndex, + boolean isAscending) + +
+           
+static int[]indices(float[] a, + boolean isAscending) + +
+          Gets the array of indices that can be used to sort the array in ascending or + descending order.
+static int[]indices(float[] a, + int fromIndex, + int toIndex, + boolean isAscending) + +
+          Gets the array of indices that can be used to sort the section of the + input array going from fromIndex(inclusive) to toIndex(exclusive) + in ascending or descending order.
+static int[]indices(int[] a, + boolean isAscending) + +
+           
+static int[]indices(int[] a, + int fromIndex, + int toIndex, + boolean isAscending) + +
+           
+static voidtwoArrays(double[] x, + double[] y, + int fromIndex, + int toIndex, + boolean isAscending) + +
+           
+static voidtwoArrays(float[] x, + float[] y, + int fromIndex, + int toIndex, + boolean isAscending) + +
+          Sorts the input x and y arrays according to + x and going from fromIndex(inclusive) to toIndex(exclusive) + in ascending or descending order.
+static voidtwoArrays(int[] x, + int[] y, + int fromIndex, + int toIndex, + boolean isAscending) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+indices

+
+public static int[] indices(float[] a,
+                            boolean isAscending)
+
+
Gets the array of indices that can be used to sort the array in ascending or + descending order. + +

+ The algorithm used to obtain these indices is a modified version of the + tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + Sort Function", Software-Practice and Experience, Vol. 23(11) + P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + to sort arrays). +

It is a modified version in the sense that the original array remains unsorted. Instead, + a copy of the original array is used in the sorting routine, and the array of + indices [0,1,2,...N-1] sorted concurrently with the array being sorted. +

+

+
Parameters:
a - the input array
isAscending - true for data sorted in increasing order. +
Returns:
integar array of indices (with length=data.length) that can be used + to sort the data from low to high or vice-versa.. + * @throws IllegalArgumentException if fromIndex > toIndex +
Throws: +
ArrayIndexOutOfBoundsException - if fromIndex < 0 or + toIndex > a.length
+
+
+
+ +

+indices

+
+public static int[] indices(double[] a,
+                            boolean isAscending)
+
+
+
+
+
+
+ +

+indices

+
+public static int[] indices(int[] a,
+                            boolean isAscending)
+
+
+
+
+
+
+ +

+indices

+
+public static int[] indices(float[] a,
+                            int fromIndex,
+                            int toIndex,
+                            boolean isAscending)
+
+
Gets the array of indices that can be used to sort the section of the + input array going from fromIndex(inclusive) to toIndex(exclusive) + in ascending or descending order. + +

+ The algorithm used to obtain these indices is a modified version of the + tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + Sort Function", Software-Practice and Experience, Vol. 23(11) + P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + to sort arrays). +

It is a modified version in the sense that the original array remains unsorted. Instead, + a copy of the original array is used in the sorting routine, and the array of + indices [fromIndex,fromIndex+1, ... , toIndex-1] sorted concurrently with the array being sorted. +

+

+
Parameters:
a - the array to be sorted.
fromIndex - the index of the first element (inclusive) to be + sorted.
toIndex - the index of the last element (exclusive) to be sorted.
isAscending - true for data sorted in increasing order. +
Throws: +
IllegalArgumentException - if fromIndex > toIndex +
ArrayIndexOutOfBoundsException - if fromIndex < 0 or + toIndex > a.length
+
+
+
+ +

+indices

+
+public static int[] indices(double[] a,
+                            int fromIndex,
+                            int toIndex,
+                            boolean isAscending)
+
+
+
+
+
+
+ +

+indices

+
+public static int[] indices(int[] a,
+                            int fromIndex,
+                            int toIndex,
+                            boolean isAscending)
+
+
+
+
+
+
+ +

+twoArrays

+
+public static void twoArrays(float[] x,
+                             float[] y,
+                             int fromIndex,
+                             int toIndex,
+                             boolean isAscending)
+
+
Sorts the input x and y arrays according to + x and going from fromIndex(inclusive) to toIndex(exclusive) + in ascending or descending order. + +

+ The algorithm used to obtain these indices is a modified version of the + tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + Sort Function", Software-Practice and Experience, Vol. 23(11) + P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + to sort arrays). +

It is a modified version in the sense that two arrays are sorted according to the first + array. At the end of the method, the section of both arrays going from + fromIndex (inclusive) to toIndex(exclusive) are sorted according + to the first array's order. Use a copy of both arrays if you want to preserve the natural order of + the original arrays. +

+

+
Parameters:
x - the array to sort.
y - the second array, to sort according to x.
fromIndex - the index of the first element (inclusive) to be + sorted.
toIndex - the index of the last element (exclusive) to be sorted.
isAscending - true for data sorted in increasing order. +
Throws: +
IllegalArgumentException - if fromIndex > toIndex +
ArrayIndexOutOfBoundsException - if fromIndex < 0 or + toIndex > a.length
See Also:
Arrays.sort(float[])
+
+
+
+ +

+twoArrays

+
+public static void twoArrays(double[] x,
+                             double[] y,
+                             int fromIndex,
+                             int toIndex,
+                             boolean isAscending)
+
+
+
+
+
+
+ +

+twoArrays

+
+public static void twoArrays(int[] x,
+                             int[] y,
+                             int fromIndex,
+                             int toIndex,
+                             boolean isAscending)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/SubPlot.html b/drawing/papaya/reference/papaya/SubPlot.html new file mode 100644 index 0000000..a037029 --- /dev/null +++ b/drawing/papaya/reference/papaya/SubPlot.html @@ -0,0 +1,793 @@ + + + + + + +SubPlot (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class SubPlot

+
+java.lang.Object
+  extended by papaya.Visuals
+      extended by papaya.SubPlot
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
+
public class SubPlot
extends Visuals
+ + +

+Convenient class for drawing multiple scatter plots. +

+ +

+

+
Author:
+
Adila Faruk
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+ floatbottomBound + +
+          Specifies the space on the bottom, between the plot area and the bounding + rectangle.
+ booleandrawAxes + +
+          Specifies whether to draw the axes
+ booleandrawRectangle + +
+          Specifies whether to draw the bounding rectangle around the plot.
+ floatleftBound + +
+          Specifies the space on the left between the plot area, and the + bounding rectangle.
+ floatrightBound + +
+          Specifies the space on the right betweent the plot area, and the + bounding rectangle.
+ ScatterPlot[][]s + +
+           
+ floattopBound + +
+          Specifies the space on the top, between the plot area and the bounding + rectangle.
+ float[][]xLefts + +
+           
+ floatxSpacing + +
+           
+ floatxW + +
+           
+ floatyH + +
+           
+ floatySpacing + +
+           
+ float[][]yTops + +
+           
+ + + + + + + +
Fields inherited from class papaya.Visuals
bgColor
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
SubPlot(PApplet theParent, + float xLeft, + float yTop, + float xWidth, + float yHeight, + int numX, + int numY) + +
+          Creates numX*numY plots, each of with xWidth, and height yHeight.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiddrawScatterPlot(float[] xDat, + float[] yDat, + int fColor, + int xnum, + int ynum) + +
+          Draws the scatterplot for subplot(xnum,ynum) by calling ScatterPlot.drawScatterPlot(float[], float[], float, int).
+ voidlegendHoriz(String where, + int[] colors, + String[] labels) + +
+          Draws a legend going to the right with the first element situated at (x,y).
+ voidlegendVert(float x, + float y, + int[] colors, + String[] labels) + +
+          Draws a legend going downwards with the first element situated at (x,y).
+ voidsetDataExtremes(float minXDat, + float maxXDat, + float minYDat, + float maxYDat, + int xnum, + int ynum) + +
+          Sets the data extremes for subplot(xnum,ynum) by calling ScatterPlot.setDataExtremes(float, float, float, float)
+ voidwriteTitle(PFont pFont, + String title, + int xnum, + int ynum) + +
+          Writes the title for subplot(xnum,ynum).
+ voidwriteTitle(String title, + int xnum, + int ynum) + +
+          Writes the title for subplot(xnum,ynum).
+ voidxLabels(int _numDiv, + int xnum, + int ynum) + +
+          Writes the x labels for subplot(xnum,ynum).
+ voidyLabels(int _numDiv, + int xnum, + int ynum) + +
+          Writes the y labels for subplot(xnum,ynum).
+ + + + + + + +
Methods inherited from class papaya.Visuals
drawAxes, drawRect, drawRect, getBottom, getHeight, getLeft, getRight, getTop, getWidth, horizLine, legendHoriz, line, mapXData, mapXData, mapYData, mapYData, setBackgroundColor, setHeight, setLeft, setTop, setupFont, setupFont, setWidth, vertLine, writeLabels, writeLabels, writeLabels, writeLabels, writeLabels, writeTitle, xLabels, xLabels, xTicks, yLabels, yLabels, YLines, yTicks
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+drawRectangle

+
+public boolean drawRectangle
+
+
Specifies whether to draw the bounding rectangle around the plot. +

+

+
+
+
+ +

+drawAxes

+
+public boolean drawAxes
+
+
Specifies whether to draw the axes +

+

+
+
+
+ +

+leftBound

+
+public float leftBound
+
+
Specifies the space on the left between the plot area, and the + bounding rectangle. That is, the left-most point of + the rectangle is given by plotLeft-leftBound. +

+

+
+
+
+ +

+rightBound

+
+public float rightBound
+
+
Specifies the space on the right betweent the plot area, and the + bounding rectangle. That is, the right-most point of + the rectangle is given by plotLeft+plotWidth+rightBound. +

+

+
+
+
+ +

+topBound

+
+public float topBound
+
+
Specifies the space on the top, between the plot area and the bounding + rectangle. That is, the top-most point of the rectangle is given by + plotTop - topBound. +

+

+
+
+
+ +

+bottomBound

+
+public float bottomBound
+
+
Specifies the space on the bottom, between the plot area and the bounding + rectangle. That is, the bottom-most point of the rectangle is given by + plotTop + plotHeight + bottomBound. +

+

+
+
+
+ +

+xLefts

+
+public float[][] xLefts
+
+
+
+
+
+ +

+yTops

+
+public float[][] yTops
+
+
+
+
+
+ +

+xW

+
+public float xW
+
+
+
+
+
+ +

+yH

+
+public float yH
+
+
+
+
+
+ +

+ySpacing

+
+public float ySpacing
+
+
+
+
+
+ +

+xSpacing

+
+public float xSpacing
+
+
+
+
+
+ +

+s

+
+public ScatterPlot[][] s
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+SubPlot

+
+public SubPlot(PApplet theParent,
+               float xLeft,
+               float yTop,
+               float xWidth,
+               float yHeight,
+               int numX,
+               int numY)
+
+
Creates numX*numY plots, each of with xWidth, and height yHeight. + subplot(1,1) has its top left corner situated at xLeft, yTop. + subplot(1,2) has its top left corner situated at xLeft, yTop + yHeight + yInterval. + ... + ... + subplot(1,numY) has its top left corner situated at xLeft, yTop + (numY-1)*(yHeight+ySpacing) +

+

+ + + + + + + + +
+Method Detail
+ +

+setDataExtremes

+
+public void setDataExtremes(float minXDat,
+                            float maxXDat,
+                            float minYDat,
+                            float maxYDat,
+                            int xnum,
+                            int ynum)
+
+
Sets the data extremes for subplot(xnum,ynum) by calling ScatterPlot.setDataExtremes(float, float, float, float) +

+

+
+
+
+
+ +

+drawScatterPlot

+
+public void drawScatterPlot(float[] xDat,
+                            float[] yDat,
+                            int fColor,
+                            int xnum,
+                            int ynum)
+
+
Draws the scatterplot for subplot(xnum,ynum) by calling ScatterPlot.drawScatterPlot(float[], float[], float, int). For + more control, use s[xnum][ynum].drawScatterPlot directly. +

+

+
+
+
+
+ +

+writeTitle

+
+public void writeTitle(PFont pFont,
+                       String title,
+                       int xnum,
+                       int ynum)
+
+
Writes the title for subplot(xnum,ynum). For more control over the placement, color, size, + I highly recommend you do this yourself. :) +

+

+
+
+
+
+ +

+writeTitle

+
+public void writeTitle(String title,
+                       int xnum,
+                       int ynum)
+
+
Writes the title for subplot(xnum,ynum). For more control over the placement, color, size, + I highly recommend you do this yourself. :) +

+

+
+
+
+
+ +

+legendVert

+
+public void legendVert(float x,
+                       float y,
+                       int[] colors,
+                       String[] labels)
+
+
Draws a legend going downwards with the first element situated at (x,y). + 100% similar to Visuals.legendVert(float, float, int[], java.lang.String[]). +

+

+
Overrides:
legendVert in class Visuals
+
+
+
Parameters:
colors - the legend colors
labels - labels that go with each color
+
+
+
+ +

+legendHoriz

+
+public void legendHoriz(String where,
+                        int[] colors,
+                        String[] labels)
+
+
Draws a legend going to the right with the first element situated at (x,y). + Useful for situations where you are plotting more than one dataset. +

+

+
Parameters:
where - "top" if you want to place the legend at the top, otherwise, it + will default to placing it at the bottom of the plots.
colors - the legend colors
labels - labels that go with each color
+
+
+
+ +

+yLabels

+
+public void yLabels(int _numDiv,
+                    int xnum,
+                    int ynum)
+
+
Writes the y labels for subplot(xnum,ynum). For more control, call the + underlying scatterplot directly using s[xnum][ynum].yLabels. +

+

+
+
+
+
+ +

+xLabels

+
+public void xLabels(int _numDiv,
+                    int xnum,
+                    int ynum)
+
+
Writes the x labels for subplot(xnum,ynum). For more control, call the + underlying scatterplot directly using s[xnum][ynum].xLabels. +

+

+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Unique.html b/drawing/papaya/reference/papaya/Unique.html new file mode 100644 index 0000000..4673b9b --- /dev/null +++ b/drawing/papaya/reference/papaya/Unique.html @@ -0,0 +1,338 @@ + + + + + + +Unique (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Unique

+
+java.lang.Object
+  extended by papaya.Unique
+
+
+
+
public class Unique
extends Object
+ + +

+Class for getting and storing an unsorted array's unique elements, + the indices of these elements, and the number of times the elements occur. +

This class is overkill if: +
+ you want to store only the unique elements. Use a Java + Set instead. +
+ you don't want to store everything in a class. Use the + Descriptive.frequencies(float[], java.util.ArrayList, java.util.ArrayList) method instead. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + +
+Field Summary
+ ArrayList<Integer>frequencies + +
+          ArrayList containing the frequencies of the corresponding unique value
+ int[][]idx + +
+          Class containing the integer arrays that hold the indices of each unique value.
+ ArrayList<Float>values + +
+          ArrayList containing the unique values
+  + + + + + + + + + + +
+Constructor Summary
Unique(float[] data, + boolean storeIndices) + +
+          Class for storing the unique values in an unsorted data array.
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+values

+
+public ArrayList<Float> values
+
+
ArrayList containing the unique values +

+

+
+
+
+ +

+frequencies

+
+public ArrayList<Integer> frequencies
+
+
ArrayList containing the frequencies of the corresponding unique value +

+

+
+
+
+ +

+idx

+
+public int[][] idx
+
+
Class containing the integer arrays that hold the indices of each unique value. +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+Unique

+
+public Unique(float[] data,
+              boolean storeIndices)
+
+
Class for storing the unique values in an unsorted data array. Does essentially the same + thing as the Descriptive.frequencies method would, except: +


+ - The input data array is unsorted. +
+
+ - You can choose to store the indices of each unique value as well by setting the @param storeIndices + to true. +
+
+ - It (currently) only works for float arrays. +
+

Example:

+

+ data = (8,5,6,7,8,5,5) --> values = (5,6,7,8), frequencies = (3,1,1,2), + idx[0] = {1,5,6}, idx[1] = {2}, idx[2] = {3}, idx[3] = {0,4} +

+

+

+
Parameters:
data - the data array
storeIndices - set to true if you want to store the indices, + else set to false +
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/Visuals.html b/drawing/papaya/reference/papaya/Visuals.html new file mode 100644 index 0000000..73ea0dd --- /dev/null +++ b/drawing/papaya/reference/papaya/Visuals.html @@ -0,0 +1,1404 @@ + + + + + + +Visuals (Javadocs: papaya) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +papaya +
+Class Visuals

+
+java.lang.Object
+  extended by papaya.Visuals
+
+
+
All Implemented Interfaces:
PapayaConstants
+
+
+
Direct Known Subclasses:
BoxPlot, CorrelationPlot, ScatterPlot, SubPlot
+
+
+
+
public class Visuals
extends Object
implements PapayaConstants
+ + +

+Visuals is the parent class behind most of the other plotting classes. + +

+ It: +
+ 1. Contains some useful functions for the visual representation + of your data (e.g. setting up your font, writing labels, mapping + arrays to the plot right-left-top-bottom parameters, xTicks, yTicks, + etc.) that should help you reduce the amount of code you end up + writing. +
+ 2. Is extended by the available "Plotting" classes used to quickly give a + visual snapshot of your data. +

+

+ +

+


+ +

+ + + + + + + + + + + +
+Field Summary
+ intbgColor + +
+          Specifies the plot background color
+ + + + + + + +
Fields inherited from interface papaya.PapayaConstants
BASELINE, big, biginv, BOTTOM, CENTER, CORNER, FONTNAME, GRAY, INDEX_NOT_FOUND, INDICES_NOT_FOUND, LEFT, LOGPI, MACHEP, MAXGAM, MAXLOG, MINLOG, RIGHT, SQRTH, SQTPI, STROKEWEIGHT, TEXTSIZE, TOP
+  + + + + + + + + + + +
+Constructor Summary
Visuals(PApplet _theParent, + float _plotLeft, + float _plotTop, + float _plotWidth, + float _plotHeight) + +
+          The parent class behind the other plotting classes.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiddrawAxes(int _sColor, + float _sWeight) + +
+          Draws the plot axes using a line with color _sColor, and weight _sWeight
+ voiddrawRect() + +
+          Draw the plot background rectangle using the default plot + dimensions and background color.
+ voiddrawRect(float _left, + float _top, + float _width, + float _height, + int _rectColor) + +
+          Draws the plot background rectangle using the input dimensions and + background color.
+ floatgetBottom() + +
+           
+ floatgetHeight() + +
+           
+ floatgetLeft() + +
+           
+ floatgetRight() + +
+           
+ floatgetTop() + +
+           
+ floatgetWidth() + +
+           
+ voidhorizLine(float _xFrom, + float _xTo, + float _y, + int _sColor, + float _sWeight) + +
+          draws a horizonal line with color _sColor, and weight _sWeight
+ voidlegendHoriz(float x, + float y, + int[] colors, + String[] labels) + +
+          Draws a legend going to the right with the first element situated at (x,y).
+ voidlegendVert(float x, + float y, + int[] colors, + String[] labels) + +
+          Draws a legend going downwards with the first element situated at (x,y).
+ voidline(float _x1, + float _y1, + float _x2, + float _y2, + int _sColor, + float _sWeight) + +
+          Draws a straight line going from (x[0],y[0]) to (x[1],y[1]) + with color _sColor, and weight _sWeight
+ float[]mapXData(float[] data) + +
+          Maps the x-data from the range min(data) to max(data) to + the plotLeft and plotLeft+plotWidth.
+ float[]mapXData(float[] data, + float minXDat, + float maxXDat) + +
+          Maps the x-data from the range minXDat to maxXDat to + the plotLeft and plotRight.
+ float[]mapYData(float[] data) + +
+          Maps the y-data from the range min(data) to max(data) to + the plotBottom and plotTop.
+ float[]mapYData(float[] data, + float minYDat, + float maxYDat) + +
+          Maps the y-data from the range minYDat to maxYDat to + the plotBottom and plotTop.
+ voidsetBackgroundColor(int _backgroundColor) + +
+           
+ voidsetHeight(float _plotHeight) + +
+           
+ voidsetLeft(float _plotLeft) + +
+           
+ voidsetTop(float _plotTop) + +
+           
+ voidsetupFont(String _fontName, + int _xAlign, + int _yAlign, + int _tSize) + +
+          function for setting the font up for writing the labels
+ voidsetupFont(String _fontName, + int _xAlign, + int _yAlign, + int _tSize, + int _fontColor) + +
+          overload setupFont function that takes in font color
+ voidsetWidth(float _plotWidth) + +
+           
+ voidvertLine(float _yFrom, + float _yTo, + float _x, + int _sColor, + float _sWeight) + +
+          draws a vertical line with color _sColor, and weight _sWeight
+ voidwriteLabels(float _text, + float _xPos, + float _yPos) + +
+           
+ voidwriteLabels(PFont _plotFont, + float _text, + float _xPos, + float _yPos) + +
+           
+ voidwriteLabels(PFont _plotFont, + String[] _text, + float[] _xPos, + float[] _yPos) + +
+           
+ voidwriteLabels(PFont _plotFont, + String _text, + float _xPos, + float _yPos) + +
+           
+ voidwriteLabels(String _text, + float _xPos, + float _yPos) + +
+           
+ voidwriteTitle(String _title, + PFont _plotFont) + +
+          titles the plot given the String _title and the PFont
+ voidxLabels(float _left, + float _width, + float _xDatMin, + float _xDatMax, + int _numDiv) + +
+          Write the x-axis labels.
+ voidxLabels(float _left, + float _width, + String[] _xLabels) + +
+          Write the x-axis labels.
+ voidxTicks(float _left, + float _width, + int _numDiv, + int _tickHeight) + +
+          Draws the x-axis tickmarks.
+ voidyLabels(float _top, + float _height, + float _yDatMin, + float _yDatMax, + int _numDiv) + +
+          Write the y-axis labels.
+ voidyLabels(float _top, + float _height, + String[] _yLabels) + +
+          Write the y-axis labels.
+ voidYLines(int _numDiv) + +
+          Draws horizontal y-lines on the plot
+ voidyTicks(float _top, + float _height, + int _numDiv, + int _tickWidth) + +
+          Draws the y-axis tickmarks.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+bgColor

+
+public int bgColor
+
+
Specifies the plot background color +

+

+
+
+ + + + + + + + +
+Constructor Detail
+ +

+Visuals

+
+public Visuals(PApplet _theParent,
+               float _plotLeft,
+               float _plotTop,
+               float _plotWidth,
+               float _plotHeight)
+
+
The parent class behind the other plotting classes. + +

+ Visuals contains some useful functions for the (elementary!) visual representation + of your data (e.g. setting up your font, writing labels, mapping + arrays to the plot right-left-top-bottom parameters, xTicks, yTicks,legends, + etc). Nothing very fancy like writing x-labels at an angle or computing your + tax returns for you though so don't get your hopes up. Sorry. +

+

+
Parameters:
_theParent - the Processing papplet. Just "this" in your sketch.
_plotLeft - the plot left
_plotTop - the plot top (in Processing coordinates!)
_plotWidth - the plot width
_plotHeight - the plot height. +

The bottom of the plot area is then given by _plotTop + _plotHeight + while the right is _plotLeft + _plotWidth.

+
+ + + + + + + + +
+Method Detail
+ +

+mapXData

+
+public float[] mapXData(float[] data)
+
+
Maps the x-data from the range min(data) to max(data) to + the plotLeft and plotLeft+plotWidth. That is, + mappedData[i] = plotLeft + (data[i] - min) / (max-min) * plotWidth. + This is not done directly though, but rather, the + Mat.map(float[] data, float low1, float high1, float low2, float high2) + function is used. +

+

+
+
+
+
Parameters:
data - the x data to map. +
Returns:
the mapped data.
+
+
+
+ +

+mapXData

+
+public float[] mapXData(float[] data,
+                        float minXDat,
+                        float maxXDat)
+
+
Maps the x-data from the range minXDat to maxXDat to + the plotLeft and plotRight. That is, + mappedData[i] = plotLeft + (data[i] - minXDat) / (maxXDat-minXDat) * plotWidth. + This is not done directly though, but rather, the + Mat.map(float[] data, float low1, float high1, float low2, float high2) + function is used. +

+ Note: No internal checks are done to make sure that the min/max values are in the + data range. +

+

+

+
+
+
+
Parameters:
data - the x data to map.
minXDat - the minimum value to use in the data mapping.
maxXDat - the maximum value to use in the data mapping. +
Returns:
the mapped data.
+
+
+
+ +

+mapYData

+
+public float[] mapYData(float[] data)
+
+
Maps the y-data from the range min(data) to max(data) to + the plotBottom and plotTop. That is, + mappedData[i] = plotBottom + (data[i] - min) / (max-min) * (-plotHeight). + (The minus sign above accounts for the difference in Processing's coordinate system + and what we associate with Top/Bottom). + The computation above is not done directly though, but rather, the + Mat.map(float[] data, float low1, float high1, float low2, float high2) + function is used. +

+

+
+
+
+
Parameters:
data - the y data to map. +
Returns:
the mapped data.
+
+
+
+ +

+mapYData

+
+public float[] mapYData(float[] data,
+                        float minYDat,
+                        float maxYDat)
+
+
Maps the y-data from the range minYDat to maxYDat to + the plotBottom and plotTop. That is, + mappedData[i] = plotBottom + (data[i] - minYDat) / (maxYDat-minYDat) * (-plotHeight). + (The minus sign above accounts for the difference in Processing's coordinate system + and what we associate with Top/Bottom). + The computation above is not done directly though, but rather, the + Mat.map(float[] data, float low1, float high1, float low2, float high2) + function is used. +

+ Note: No internal checks are done to make sure that the min/max values are in the + data range. +

+

+

+
+
+
+
Parameters:
data - the x data to map.
minYDat - the minimum value to use in the data mapping.
maxYDat - the maximum value to use in the data mapping. +
Returns:
the mapped data.
+
+
+
+ +

+drawAxes

+
+public void drawAxes(int _sColor,
+                     float _sWeight)
+
+
Draws the plot axes using a line with color _sColor, and weight _sWeight +

+

+
+
+
+
+
+
+
+ +

+drawRect

+
+public void drawRect()
+
+
Draw the plot background rectangle using the default plot + dimensions and background color. + +
  • Left most point: plotLeft
  • +
  • Top most point: plotTop
  • +
  • Width: plotWidth
  • +
  • Height: plotHeight
  • + +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +drawRect

    +
    +public void drawRect(float _left,
    +                     float _top,
    +                     float _width,
    +                     float _height,
    +                     int _rectColor)
    +
    +
    Draws the plot background rectangle using the input dimensions and + background color. +

    +

    +
    +
    +
    +
    Parameters:
    _left - the left-most point of the rectangle
    _top - the top-most point of the rectangle
    _width - the width of the rectangle
    _height - the height of the rectangle
    _rectColor - the rectangle color.
    +
    +
    +
    + +

    +legendVert

    +
    +public void legendVert(float x,
    +                       float y,
    +                       int[] colors,
    +                       String[] labels)
    +
    +
    Draws a legend going downwards with the first element situated at (x,y). + Useful for situations where you are plotting more than one dataset. +

    +

    +
    +
    +
    +
    Parameters:
    colors - the legend colors
    labels - labels that go with each color
    +
    +
    +
    + +

    +legendHoriz

    +
    +public void legendHoriz(float x,
    +                        float y,
    +                        int[] colors,
    +                        String[] labels)
    +
    +
    Draws a legend going to the right with the first element situated at (x,y). + Useful for situations where you are plotting more than one dataset. +

    +

    +
    +
    +
    +
    Parameters:
    colors - the legend colors
    labels - labels that go with each color
    +
    +
    +
    + +

    +xTicks

    +
    +public void xTicks(float _left,
    +                   float _width,
    +                   int _numDiv,
    +                   int _tickHeight)
    +
    +
    Draws the x-axis tickmarks. +

    +

    +
    +
    +
    +
    Parameters:
    _left - left most tick position. Set to negative to make it default + to the plotLeft)
    _width - (_left + _width) = right most tick position. Set to negative
    _numDiv - the number of divisions. The number of tick marks drawn = _numDiv+1.
    _tickHeight - the height of the tick mark.
    +
    +
    +
    + +

    +xLabels

    +
    +public void xLabels(float _left,
    +                    float _width,
    +                    float _xDatMin,
    +                    float _xDatMax,
    +                    int _numDiv)
    +
    +
    Write the x-axis labels. +

    +

    +
    +
    +
    +
    Parameters:
    _left - left most label position. Set to negative to make it default + to the plotLeft)
    _width - (_left + _width) = right most label position. Set to negative + to make it default to the plotWidth
    _xDatMin - minimum data value to show in the label
    _xDatMax - maximum data value to show in the label
    _numDiv - the number of divisions.
    +
    +
    +
    + +

    +xLabels

    +
    +public void xLabels(float _left,
    +                    float _width,
    +                    String[] _xLabels)
    +
    +
    Write the x-axis labels. +

    +

    +
    +
    +
    +
    Parameters:
    _left - left most label position. Set to negative to make it default + to the plotLeft)
    _width - (_left + _width) = right most label position. Set to negative + to make it default to the plotWidth
    _xLabels - the String array of labels.
    +
    +
    +
    + +

    +yTicks

    +
    +public void yTicks(float _top,
    +                   float _height,
    +                   int _numDiv,
    +                   int _tickWidth)
    +
    +
    Draws the y-axis tickmarks. +

    +

    +
    +
    +
    +
    Parameters:
    _top - top most tick position in Processing's coordinate system. + Set to negative to make it default to the plotTop)
    _height - (top + height) = bottom most label position in Processing's coordinate system. + Set to negative to make it default to the plotHeight.
    _numDiv - the number of divisions. The number of tick marks drawn = _numDiv+1.
    _tickWidth - the width of the tick mark.
    +
    +
    +
    + +

    +yLabels

    +
    +public void yLabels(float _top,
    +                    float _height,
    +                    float _yDatMin,
    +                    float _yDatMax,
    +                    int _numDiv)
    +
    +
    Write the y-axis labels. +

    +

    +
    +
    +
    +
    Parameters:
    _top - top most label position in Processing's coordinate system. + Set to negative to make it default to the plotTop)
    _height - (top + height) = bottom most label positionin Processing's coordinate system. + Set to negative to make it default to the plotHeight.
    _yDatMin - minimum data value to show in the label
    _yDatMax - maximum data value to show in the label
    _numDiv - the number of divisions.
    +
    +
    +
    + +

    +yLabels

    +
    +public void yLabels(float _top,
    +                    float _height,
    +                    String[] _yLabels)
    +
    +
    Write the y-axis labels. +

    +

    +
    +
    +
    +
    Parameters:
    _top - top most label position in Processing's coordinate system. + Set to negative to make it default to the plotTop)
    _height - (top + height) = bottom most label positionin Processing's coordinate system. + Set to negative to make it default to the plotHeight.
    _yLabels - the String array of labels.
    +
    +
    +
    + +

    +YLines

    +
    +public void YLines(int _numDiv)
    +
    +
    Draws horizontal y-lines on the plot +

    +

    +
    +
    +
    +
    Parameters:
    _numDiv - number of divisions. The number of lines drawn = numDiv+1
    +
    +
    +
    + +

    +horizLine

    +
    +public void horizLine(float _xFrom,
    +                      float _xTo,
    +                      float _y,
    +                      int _sColor,
    +                      float _sWeight)
    +
    +
    draws a horizonal line with color _sColor, and weight _sWeight +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +vertLine

    +
    +public void vertLine(float _yFrom,
    +                     float _yTo,
    +                     float _x,
    +                     int _sColor,
    +                     float _sWeight)
    +
    +
    draws a vertical line with color _sColor, and weight _sWeight +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +line

    +
    +public void line(float _x1,
    +                 float _y1,
    +                 float _x2,
    +                 float _y2,
    +                 int _sColor,
    +                 float _sWeight)
    +
    +
    Draws a straight line going from (x[0],y[0]) to (x[1],y[1]) + with color _sColor, and weight _sWeight +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +writeTitle

    +
    +public void writeTitle(String _title,
    +                       PFont _plotFont)
    +
    +
    titles the plot given the String _title and the PFont +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +writeLabels

    +
    +public void writeLabels(PFont _plotFont,
    +                        String[] _text,
    +                        float[] _xPos,
    +                        float[] _yPos)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +writeLabels

    +
    +public void writeLabels(PFont _plotFont,
    +                        String _text,
    +                        float _xPos,
    +                        float _yPos)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +writeLabels

    +
    +public void writeLabels(PFont _plotFont,
    +                        float _text,
    +                        float _xPos,
    +                        float _yPos)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +writeLabels

    +
    +public void writeLabels(float _text,
    +                        float _xPos,
    +                        float _yPos)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +writeLabels

    +
    +public void writeLabels(String _text,
    +                        float _xPos,
    +                        float _yPos)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +setupFont

    +
    +public void setupFont(String _fontName,
    +                      int _xAlign,
    +                      int _yAlign,
    +                      int _tSize)
    +
    +
    function for setting the font up for writing the labels +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +setupFont

    +
    +public void setupFont(String _fontName,
    +                      int _xAlign,
    +                      int _yAlign,
    +                      int _tSize,
    +                      int _fontColor)
    +
    +
    overload setupFont function that takes in font color +

    +

    +
    +
    +
    +
    +
    +
    +
    + +

    +setBackgroundColor

    +
    +public void setBackgroundColor(int _backgroundColor)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +getLeft

    +
    +public float getLeft()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +getRight

    +
    +public float getRight()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +getTop

    +
    +public float getTop()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +getBottom

    +
    +public float getBottom()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +getWidth

    +
    +public float getWidth()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +getHeight

    +
    +public float getHeight()
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +setLeft

    +
    +public void setLeft(float _plotLeft)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +setWidth

    +
    +public void setWidth(float _plotWidth)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +setTop

    +
    +public void setTop(float _plotTop)
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +

    +setHeight

    +
    +public void setHeight(float _plotHeight)
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    + + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/package-frame.html b/drawing/papaya/reference/papaya/package-frame.html new file mode 100644 index 0000000..1f62577 --- /dev/null +++ b/drawing/papaya/reference/papaya/package-frame.html @@ -0,0 +1,119 @@ + + + + + + +papaya (Javadocs: papaya) + + + + + + + + + + + +papaya + + + + +
    +Interfaces  + +
    +PapayaConstants
    + + + + + + +
    +Classes  + +
    +BoxPlot +
    +Cast +
    +Comparison +
    +Comparison.TTest +
    +Correlation +
    +Correlation.Significance +
    +Correlation.Weighted +
    +CorrelationPlot +
    +Descriptive +
    +Descriptive.Mean +
    +Descriptive.Pooled +
    +Descriptive.Sum +
    +Descriptive.Weighted +
    +Distance +
    +Eigenvalue +
    +Find +
    +Frequency +
    +Gamma +
    +Linear +
    +Linear.BoxCox +
    +Linear.Significance +
    +Linear.StdErr +
    +LU +
    +Mat +
    +MDS +
    +NaNs +
    +Normality +
    +Normality.Dago +
    +OneWayAnova +
    +Polynomial +
    +Probability +
    +QR +
    +Rank +
    +ScatterPlot +
    +Sorting +
    +SubPlot +
    +SVD +
    +Unique +
    +Visuals
    + + + + diff --git a/drawing/papaya/reference/papaya/package-summary.html b/drawing/papaya/reference/papaya/package-summary.html new file mode 100644 index 0000000..99ad853 --- /dev/null +++ b/drawing/papaya/reference/papaya/package-summary.html @@ -0,0 +1,344 @@ + + + + + + +papaya (Javadocs: papaya) + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +
    + +
    + + + +
    +

    +Package papaya +

    + + + + + + + + + +
    +Interface Summary
    PapayaConstantsPapayaConstants stores some of the constants used in plotting.
    +  + +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +Class Summary
    BoxPlotBoxPlot class
    CastStatic Class for casting Object arrays to their corresponding primitive type.
    ComparisonContains a number of methods for comparing more than one dataset + against each other.
    Comparison.TTestMethods related to comparing two populations.
    CorrelationContains utilities related to computing covariances, as well as linear and rank correlation.
    Correlation.SignificanceContains methods used to compute the significance, or pvalue of the input correlations.
    Correlation.WeightedContains methods related to computing the correlation and covariance of weighted + datasets.
    CorrelationPlotTakes in a matrix and plots the data in each of the columns versus + each other.
    DescriptiveBasic descriptive statistics class for exploratory data analysis.
    Descriptive.MeanContains methods for computing the arithmetic, geometric, harmonic, trimmed, and winsorized + means (among others).
    Descriptive.PooledClass for computing the pooled mean and variance of data sequences
    Descriptive.SumMethods for computing various different sums of datasets such as sum of inversions, + logs, products, power deviations, squares, etc.
    Descriptive.WeightedContains methods related to weighted datasets.
    DistanceContains methods for computing various "distance" metrics for multidimensional scaling.
    EigenvalueEigenvalues and eigenvectors of a real matrix.
    FindStatic class for finding indices in an array corresponding to a given value/object.
    FrequencyClass for getting the frequency distribution, cumulative frequency distribution, and other + distribution-related parameters of a given array of floats or ints.
    GammaGamma and Beta functions.
    LinearContains methods related to determining the linear linear + relationship between two datasets (of equal arrays) such as the + best-fit linear line parameters, box-cox transformations, etc.
    Linear.BoxCoxContains methods related to the Box-Cox transformation of a data set; useful in + determining the best transformation that will yield the best method for converting + a monotonic, non-linear relationship between x and y into + a linear one.
    Linear.SignificanceContains methods used to compute the significance, or pvalue of the input correlations.
    Linear.StdErrContains methods related to computing the standard errors of the residuals, slope and intercept + associated with the best-fit linear line.
    LULU Decomposition.
    MatStatic class for performing some basic matrix operations.
    MDSContains methods for performing but classical and non-classical multidimensional scaling.
    NaNsContains various methods for dealing with NaNs in your data.
    NormalityContains various utilities for checking if the dataset comes from a normal distribution.
    Normality.DagoMethods for computing the skewnewss, kurtosis, and D'Agostino-Peasrson K^2 "omnibus" test-statistics (that + combine the former two), and accompanying significance (or p-values) + for testing the underlying population normality.
    OneWayAnovaComputes the one-way ANOVA p-value to test the equality of two or more sample + means by analyzing the sample variances using the test statistic + F = variance between samples / variance within samples.
    PolynomialStatic Class for casting one variable type to another.
    ProbabilityCumulative distribution functions and corresponding inverses of certain probability distributions.
    QRQR Decomposition.
    RankRanking based on the natural ordering on floats for a sequence of data that may also + contain NaNs.
    ScatterPlotA simple class to plot x vs y data as a + scatter plot.
    SortingClass for getting the array of indices that can be used to sort the array in ascending or + descending order.
    SubPlotConvenient class for drawing multiple scatter plots.
    SVDSingular Value Decomposition.
    UniqueClass for getting and storing an unsorted array's unique elements, + the indices of these elements, and the number of times the elements occur.
    VisualsVisuals is the parent class behind most of the other plotting classes.
    +  + +

    +

    +
    +
    + + + + + + + + + + + + + + + +
    + +
    + + + +
    + + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/papaya/package-tree.html b/drawing/papaya/reference/papaya/package-tree.html new file mode 100644 index 0000000..9bf13b7 --- /dev/null +++ b/drawing/papaya/reference/papaya/package-tree.html @@ -0,0 +1,166 @@ + + + + + + +papaya Class Hierarchy (Javadocs: papaya) + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +
    + +
    + + + +
    +
    +

    +Hierarchy For Package papaya +

    +
    +

    +Class Hierarchy +

    + +

    +Interface Hierarchy +

    + +
    + + + + + + + + + + + + + + + +
    + +
    + + + +
    + + + Processing library papaya by + Adila Faruk. (C) 2014 + + + + diff --git a/drawing/papaya/reference/resources/inherit.gif b/drawing/papaya/reference/resources/inherit.gif new file mode 100644 index 0000000000000000000000000000000000000000..c814867a13deb0ca7ea2156c6ca1d5a03372af7e GIT binary patch literal 57 zcmZ?wbhEHbIIT!9-C*e{wE9>Kx3D)-;0v)C; KYxQGgum%9JOA&7X literal 0 HcmV?d00001 diff --git a/drawing/papaya/reference/stylesheet.css b/drawing/papaya/reference/stylesheet.css new file mode 100644 index 0000000..7e746f8 --- /dev/null +++ b/drawing/papaya/reference/stylesheet.css @@ -0,0 +1,115 @@ +/* Javadoc style sheet */ +/* Define colors, fonts and other style attributes here to override the defaults */ +/* +To compile: +cd into folder +sass -s --watch stylesheet.scss:stylesheet.css +or, just use the Makefile! +*/ +/** colors */ +/* Page background color */ +body { + background-color: #FFFFFF; + color: #444444; + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; + max-width: 900px; } + +/* + #B0DAFF Light blue text + #1279C6 Blue background + #04469D Darker blue background + $steelblue Orange Text + #F1F1F1 Ligher gray +*/ +/* Headings */ +h1, h2, h3, h4, h5, h6 { + color: #1f77b4; } + +/* Links */ +a:link { + color: #1f77b4; + text-decoration: underline; } + +a:visited { + color: #72587f; } + +/*a:focus {font-weight:bold; color:#04469D; text-decoration:underline; }*/ +a:hover { + font-weight: bold; } + +/* HR and table borders*/ +hr { + border-style: solid 1px #666666; } + +table { + border-style: solid 1px #666666; + max-width: 100%; + overflow: wrap; } + +th { + border-style: none; } + +td { + padding: 4px; + -size: 0.9em; } + +code, +kbd, +pre, +samp { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; + font-size: 0.9em; } + +code { + padding: 2px 4px; + font-size: .9em; + color: #4a4a4a; + background-color: #f8f8f8; + border-radius: 4px; + border:1px solid #cacaca; +} +/* Table colors */ +.TableHeadingColor, .TableSubHeadingColor { + background: #222222; + color: #FFFFFF; + border-radius: 4px; } + +.TableRowColor { + background: #FFFFFF; + color: #666666; + font-size: 0.9em; } + +/* Font used in left-hand frame lists */ +.FrameTitleFont { + font-size: 100%; + font-family: Helvetica, Arial, sans-serif; + color: #1f77b4; } + +.FrameHeadingFont, .FrameItemFont { + font-size: 0.9em; + font-family: Helvetica, Arial, sans-serif; + color: #1f77b4; } + +/* Navigation bar fonts and colors */ +.NavBarCell1 { + background-color: #222222; + color: #222222; + border-radius: 4px; } + +.NavBarCell1Rev { + background-color: #1f77b4 !important; + color: #FFFFFF; + border-radius: 4px; } + +.NavBarFont1, .NavBarFont1Rev { + font-family: Arial, Helvetica, sans-serif; + color: #FFFFFF; } + +.NavBarFont1:hover { + color: #1f77b4; } + +.NavBarCell2, .NavBarCell3 { + font-family: Arial, Helvetica, sans-serif; + background-color: #FFFFFF; + color: #222222; } diff --git a/drawing/papaya/src/papaya/BoxPlot.java b/drawing/papaya/src/papaya/BoxPlot.java new file mode 100644 index 0000000..a886939 --- /dev/null +++ b/drawing/papaya/src/papaya/BoxPlot.java @@ -0,0 +1,166 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + */ +package papaya; + +import java.util.Arrays; +import java.io.*; +import java.lang.Object; +import java.lang.String; + +import processing.core.*; +import processing.core.PApplet; +import processing.core.PFont; + +/** + * BoxPlot class + * + */ + +public class BoxPlot extends Visuals{ + + private float[][] fiveNumArr; + private int numDataSets; + private float minVal,maxVal; + private PApplet myParent; + + + /** + * Specifies whether to draw the bounding rectangle around the plot. + */ + public boolean drawRectangle = true; + /** + * Specifies whether to draw the axes + */ + public boolean drawAxes = true; + /** + * Specifies the space on the left between the plot area, and the + * bounding rectangle. That is, the left-most point of + * the rectangle is given by plotLeft-leftBound. + */ + public float leftBound = 40; + /** + * Specifies the space on the right betweent the plot area, and the + * bounding rectangle. That is, the right-most point of + * the rectangle is given by plotLeft+plotWidth+rightBound. + */ + public float rightBound=20; + /** + * Specifies the space on the top, between the plot area and the bounding + * rectangle. That is, the top-most point of the rectangle is given by + * plotTop - topBound. + */ + public float topBound = 20; + /** + * Specifies the space on the bottom, between the plot area and the bounding + * rectangle. That is, the bottom-most point of the rectangle is given by + * plotTop + plotHeight + bottomBound. + */ + public float bottomBound=20; + //CENTER = 3; BOTTOM = 102; TOP = 101; BASELINE = 0; LEFT = 37; RIGHT = 39; + + public BoxPlot(PApplet _theParent, float _plotLeft, float _plotTop, float _plotWidth, float _plotHeight){ + super(_theParent,_plotLeft,_plotTop,_plotWidth,_plotHeight); + myParent = _theParent; + //bgColor = super.bgColor; + } + /** + * Sets the data to be plotted. + * @param _fiveNumArr array of five number box plot summaries + * with each row corresponding to a given data set. See {@link Descriptive#tukeyFiveNum} for more info. + * + * @param _minVal the minimum value to show in the plot + * @param _maxVal the maximum value to show in the plot + */ + public void setData(float[][] _fiveNumArr, float _minVal, float _maxVal){ + fiveNumArr = _fiveNumArr; + numDataSets = fiveNumArr.length; + minVal = _minVal; + maxVal = _maxVal; + } + /** + * + * @return the tukey five number array + */ + public float[][] getData(){ + return fiveNumArr; + } + + /** + * Plot the box plots. + * @param _labels labels for the box plot + * @param _sWeight the stroke weight to use for the lines. + * @param _fColor the fill color for the boxplots + */ + public void drawBoxPlot(String[] _labels, float _sWeight, int _fColor){ + + if(drawRectangle){ + drawRect(plotLeft-leftBound,plotTop-topBound,plotWidth+leftBound+rightBound,plotHeight+topBound+bottomBound,bgColor); + } + + // Draw the box plots. + float wEach = plotWidth/(numDataSets+1); + float wBox = wEach/4; + float xPos; + if(drawAxes){ + // map the minimum and maximum values + float[] minmax = Mat.map(new float[]{minVal,maxVal},minVal,maxVal,plotTop+plotHeight,plotTop); + vertLine(minmax[0],minmax[1], plotLeft, 50,.5f); + horizLine(plotLeft + .5f*wEach, plotLeft + (numDataSets+.5f)*wEach, plotTop + plotHeight, 50,.5f); + xLabels(plotLeft + wEach, numDataSets*wEach, _labels); + xTicks(plotLeft + wEach, numDataSets*wEach, numDataSets,5); + yLabels(plotTop, plotHeight, minVal,maxVal,5); + yTicks(plotTop, plotHeight, 5 ,10); + } + + for(int i=0; itoArray(T[] a)
    method specified in the java Collections + * interface, but for float[] and int[] arrays (as opposed to Float[] and Integer[]). + *

    + * + *

    + * @author Nur Adila Faruk Senan + */ +public final class Cast { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Cast(){ + } + + /** + * function for casting ArrayList to int[] + * @param _inputDat ArrayList array that needs to be cast to int[] + * @return the resulting int[] array + */ + public static int[] arrayListToInt(ArrayList _inputDat){ +// if(_inputDat.size()==0){ +// System.out.println("Warning: zero length array "); +// } + int[] outputDat = new int[_inputDat.size()]; + for(int i = 0; i<_inputDat.size(); i++) + outputDat[i] = _inputDat.get(i); + return outputDat; + } + + /** + * function for casting ArrayList to float[] + * @param _inputDat ArrayList array that needs to be cast to float[] + * @return the resulting float[] array + */ + public static float[] arrayListToFloat(ArrayList _inputDat){ + float[] outputDat = new float[_inputDat.size()]; + for(int i = 0; i<_inputDat.size(); i++){ + outputDat[i] = _inputDat.get(i); + } + return outputDat; + } + + /** + * function for casting float[][] to double[][] + * @param _inputDat float[][] 2d array + * @return deep copy of _inputDat with each element cast to a double + */ + public static double[][] floatToDouble(float[][] _inputDat){ + int numColumns = _inputDat[0].length; int numRows = _inputDat.length; + double[][] outputDat = new double[numRows][numColumns]; + for(int i = 0; i theSet) { + int[] a = new int[theSet.size()]; + int i = 0; + for (Integer val : theSet) a[i++] = val; + return a; + } + /** + * Function for casting a Set to float[] + */ + public static float[] setToFloat(Set theSet) { + float[] a = new float[theSet.size()]; + int i = 0; + for (Float val : theSet) a[i++] = val; + return a; + } + + /** + * Function for casting a Set to String array. This is really just one line of code, but it's + * much easier to have it as an external function rather than having to remember it + */ + public static String[] setToString(Set theSet) { + return (String[])theSet.toArray(new String[theSet.size()]); + } + + + /** + * function for casting Vector to int[] + * @param _inputDat Vector array that needs to be cast to int[] + * @return the resulting int[] array + */ + public static int[] vectorToInt(Vector _inputDat){ + int[] outputDat = new int[_inputDat.size()]; + for(int i = 0; i<_inputDat.size(); i++) + outputDat[i] = _inputDat.get(i); + return outputDat; + } + + /** + * function for casting Vector to float[] + * @param _inputDat Vector array that needs to be cast to float[] + * @return the resulting float[] array + */ + public static float[] vectorToFloat(Vector _inputDat){ + float[] outputDat = new float[_inputDat.size()]; + for(int i = 0; i<_inputDat.size(); i++){ + outputDat[i] = _inputDat.get(i); + } + return outputDat; + } + + /** + * Returns a PVector array with the x, y, and z coordinates set to the input values + * (technically not a cast, but a reorganization). + */ + public static PVector[] floatToPVector(float[] x, float[] y, float[] z){ + int size = x.length; + Check.equalLengths(size,y); Check.equalLengths(size, z); + PVector[] p = new PVector[size]; + for(int i=0; iU and p-value for + * assessing whether one of two samples of independent observations tends to have + * larger values than the other. That is, + *
    U = min(U1,U2)
    + * where + *
    +	 * U1 = Sum(Ranks1)  - n1*(n1+1)/2,   
    +	 * U2 = Sum(Ranks2) - n2*(n2+1)/2.
    +	 * 
    + * and the significance, or p-value is computed assuming + * a two-tailed null-hypothesis that both samples are similar. + * @param data1 the first dataset + * @param data2 the second dataset + * @return a 2 element array with first element corresponding to the test statistic, and second + * equal to the p-value or significance. + * @throws IllegalArgumentException if either of the sample sizes is less than 8 (the normal approximation + * is no longer valid in that case. Best to consult a table instead). + */ + public static float[] mannWhitney(float[] data1, float[] data2){ + int size1 = data1.length, size2 = data2.length; + if(size1 < 8 || size2 < 8) + throw new IllegalArgumentException("size1 and size2 need to be greater than 8."); + + float[] allData = Mat.concat(data1,data2); + float[] ranksAll = Rank.rank(allData,0); + + /* sum up the ranks of the first dataset*/ + float ranks1Sum = ranksAll[0]; + for(int i=1; ipaired
    samples from X and Y and is a convenient method + * as it makes very few assumptions about the nature of the distributions under test. + *

    + *

    To elaborate, the null hypothesis H0 states that given a random pair of measurements (X[i], Y[i]), + * X[i] and Y[i] are equally likely to be larger than the other. + * Now, let n be the number of pairs for which Y[i] ≠ X[i] and w + * be the number of pairs for which Y[i] - X[i] > 0. + * Assuming that H0 is true, then W follows a binomial distribution W ~ b(n, 0.5). + * + * This method returns the sum of the terms 0 through w of the Binomial + * probability density. + *

     
    +	 * Sum_(j=0 to w)  [ (n!)/(j!*(n-j)! ]  *  [ p^j * (1-p)^(n-j) ]
    +	 * from 0 to the test-statistic, or
    +	 * 

    + * p = Probability.binomcdf(.5,w,n). + *

    + * For n > 100, the normal distribution cdf is returned instead. + * If this is less than the critical value, then we can reject the null hypothesis that there + * is no difference between the samples X and Y. + * + * @param x data set containing 1st observation sequence + * @param y data set containing 2nd observation sequence + * @return the significance, or p-value, assuming a two-tailed null hypothesis (i.e. no difference) + */ + public static float signTest(float[] x, float[] y){ + int size = x.length; + Check.equalLengths(size,y); + int numMore=0,numLess=0; + for(int i=0; i0) numMore++; + else if (val<0) numLess++; + } + int numTotal = numMore + numLess; + double p; + int minOfTwo = Math.min(numMore,numLess); + if(numTotal<100){ + p = Probability.binomcdf(.5, minOfTwo, numTotal); + } else{ + double z = (2*minOfTwo + 1 - numTotal)/Math.sqrt(numTotal); + p = Probability.normcdf(z); + } + return (float)p; + } + + /** Methods related to comparing two populations. Each method returns an array with the + * first element containing the t-statistic, and the second corresponding to the + * p-value, or significance, of rejecting the null hypothesis. + *

    + * Tests can be:

      + *
    • One-sample or two-sample
    • + *
    • One-sided or two-sided
    • + *
    • Paired or unpaired (for two-sample tests)
    • + *
    • Homoscedastic (equal variance assumption) or heteroscedastic + * (for two sample tests)
    • + *
    • Fixed significance level (boolean-valued) or returning p-values. + *

    + *

    + * Test statistics are available for all tests. Methods including "Test" in + * in their names perform tests, all other methods return t-statistics. Among + * the "Test" methods, double-valued methods return p-values; + * boolean-valued methods perform fixed significance level tests. + * Significance levels are always specified as numbers between 0 and 0.5 + * (e.g. tests at the 95% level use alpha=0.05).

    + *

    + * + * Note: Inspired by the + * stats.inference.TTest class available in the Apache Commons math library. */ + public static class TTest{ + protected TTest(){} + + /** + * Returns the t-statistic and p-value for checking whether the means + * between the two datasets are different under the assumption that both + * datasets have equal variances. The p-value corresponds to the + * null hypothesis of no-difference (i.e. two-tailed). + * @return an array with the first element = t and the second element = p. + */ + public static float[] equalVar(float[] data1, float[] data2){ + int[] sizes = new int[]{data1.length,data2.length}; + float[] means = new float[]{Descriptive.mean(data1),Descriptive.mean(data2)}; + float[] variances = new float[]{Descriptive.var(data1,true),Descriptive.var(data2,true)}; + float pooledVariance = Descriptive.Pooled.var(variances,sizes,true); + float sizeSum = 1f/sizes[0] + 1f/sizes[1]; + double t = (means[0]-means[1])/Math.sqrt(pooledVariance*sizeSum); + int df = sizes[0] + sizes[1] - 2; + float p = (float)twoTailedStudentT(t,df); + return new float[]{(float)t,p}; + } + + /** Returns the t-statistic and p-value for checking whether the means + * between the two datasets are different under the assumption that both + * datasets have unequal variances. The p-value corresponds to the + * null hypothesis of no-difference (i.e. two-tailed). + * This is also known as Welch's t-test. + * @return an array with the first element = t and the second element = p. + */ + public static float[] unequalVar(float[] data1, float[] data2){ + int size1 = data1.length; int size2 = data2.length; + float mean1 = Descriptive.mean(data1); float mean2 = Descriptive.mean(data2); + float var1 = Descriptive.var(data1,true); float var2 = Descriptive.var(data2,true); + float var1n1 = var1/size1; float var2n2 = var2/size2; + // test statistic + double t = (mean1-mean2)/Math.sqrt(var1n1 + var2n2); + // df + double numerator = (var1n1 + var2n2)*(var1n1 + var2n2); + double denominator = var1n1*var1n1/(size1-1) + var2n2*var2n2/(size2-1); + double df = (numerator/denominator); + float p = (float)twoTailedStudentT(t,df); + return new float[]{(float)t,p}; + } + + /** + * Returns the t-statistic and p-value for checking a pair of dependent samples. + * That is, when there is only one sample that has been tested twice + * (repeated measures) or when there are two samples that have been + * matched or "paired". The p-value corresponds to the + * null hypothesis of no-difference in both measurements (i.e. two-tailed). + *

    Both datasets have to have equal lengths. + * @param before the dataset before treatment/measurement. + * @param after the dataset after treatment/measurement. + * @return an array with the first element = t and the second element = p. + */ + public static float[] paired(float[] before, float[] after){ + int size = before.length; + Check.equalLengths(size,after); + float[] diff =new float[size]; + float sum = 0; + for (int i = 0; i < size; i++) { + diff[i] += after[i]-before[i]; + sum+=diff[i]; + } + float mean = sum/size; + float sd = Descriptive.std(diff,false) / (float)Math.sqrt(size); + double t = mean/sd; + float p = (float)twoTailedStudentT(t,size-1); + return new float[]{(float)t,p}; + } + + + /** Returns the welch's t-test degree of freedom */ + protected static float welchdf(float[] data1, float[] data2){ + int size1 = data1.length; int size2 = data2.length; + float var1 = Descriptive.var(data1,true); + float var2 = Descriptive.var(data2,true); + float var1n1 = var1/size1; float var2n2 = var2/size2; + double numerator = (var1n1 + var2n2)*(var1n1 + var2n2); + double denominator = var1n1*var1n1/(size1-1) + var2n2*var2n2/(size2-1); + return (float)(numerator/denominator); + } + + } + private static double twoTailedNormal(double z){ + if(z>0) return ( 2*(1.0- (Probability.normcdf(z)) ) ); + else return (2 * (Probability.normcdf(z))); + } + + private static double twoTailedStudentT(double t, double df){ + if(t>0) return ( 2*(1.0- (Probability.tcdf(t,df)) ) ); + else return (2 * (Probability.tcdf(t,df))); + } + + + /** + * Non-parametric statistical hypothesis test used when comparing two related samples + * or repeated measurements on a single sample to assess whether their population mean + * ranks differ (i.e. it's a paired difference test). + * It can be used as an alternative to the paired Student's t-test when the + * population cannot be assumed to be normally distributed or the data is on the ordinal scale. + *

    Note: + * If we wish to make an inference about the mean (or about the median) difference, + * then we assume the distribution of the differences is symmetric. + * If we only want to test the hypothesis that the probability that the sum of a randomly + * chosen pair of differences exceeding zero is 0.5 then no distributional assumption is needed. + *

    + */ + //Wilcoxon signed-rank test + + /** A non-parametric method for testing whether samples originate from the same distribution. + * It is used for comparing more than two samples that are independent, or not related. + * The parametric equivalence of the Kruskal-Wallis test is the one-way analysis of variance (ANOVA). + * The factual null hypothesis is that the populations from which the samples originate, + * have the same median. + * When the Kruskal-Wallis test leads to significant results, + * then at least one of the samples is different from the other samples. + * The test does not identify where the differences occur or how many + * differences actually occur. + * It is an extension of the Mann?Whitney U test to 3 or more groups. + * The Mann-Whitney would help analyze the specific sample pairs for significant differences. + * + *
    Since it is a non-parametric method, the Kruskal?Wallis test does not assume a normal distribution, + * unlike the analogous one-way analysis of variance. + * However, the test does assume an identically-shaped and scaled distribution for each group, + * except for any difference in medians. + * */ + // Kruskal-Wallis test. + +} diff --git a/drawing/papaya/src/papaya/Correlation.java b/drawing/papaya/src/papaya/Correlation.java new file mode 100644 index 0000000..b094040 --- /dev/null +++ b/drawing/papaya/src/papaya/Correlation.java @@ -0,0 +1,546 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * Copyright 1999 CERN - European Organization for Nuclear Research. + * Copyright 1995 Stephen L.Moshier. + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ + +package papaya; +import java.util.*; +import java.io.*; +import processing.core.*; + +/** + * Contains utilities related to computing covariances, as well as linear and rank correlation. + * Methods relating to computing + *
      + *
    • normal correlations and covariances (biased or unbiased) are in the main class. + *
    • weighted correlation and covariances are in the {@link Weighted} subclass. + *
    • significance of the correlations (i.e. p-values) are in the {@link Significance} subclass. + *
    + * Whatever it is, remember that correlation does not always imply causation. + */ +public final class Correlation implements PapayaConstants { + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Correlation() {} + /** + * Computes the sample autocorrelation by removing the sample mean from the input series, + * then normalizing the sequence by the sample variance. That is, it returns + *
    +	 * R(lag) = E[ (X[t] - mu) * ( X[t+lag] - mu ) ] / variance(X).	
    +	 * where 
    +	 * E[ (X[t] - mu) * ( X[t+lag] - mu ) ]  = 1/size(X) * Sum_(i=0 to size-lag)( (X[t]-mu)*X[t+lag]-mu) ). 
    +	 * 
    + * Reference: Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. + * Time Series Analysis: Forecasting and Control. 3rd ed. + * Upper Saddle River, NJ: Prentice-Hall, 1994. + *

    + * @param data the array of data + * @param lag the lag value. Has to be smaller than the data sequence length + * @param mean the data mean + * @param variance the data variance + * @return the autocorrelation value + */ + public static float auto(float[] data, int lag, float mean, float variance) { + int size = data.length; + if (lag >= size) throw new IllegalArgumentException("Lag is too large"); + if(lag==0) return 1f; + double run = 0; + for( int i=0; i=1) return 1f; + if(autocorr<=-1) return -1f; + return autocorr; + } + + /** + * Returns the lag-1 autocorrelation of a dataset; + * Note that this method uses computations different from + * auto(data, 1, mean, variance). + */ + public static float autoLag1(float[] data, float mean) { + int size = data.length; + double r1 ; + double q = 0 ; + double v = (data[0] - mean) * (data[0] - mean) ; + + for (int i = 1; i < size ; i++) { + double delta0 = (data[i-1] - mean); + double delta1 = (data[i] - mean); + q += (delta0 * delta1 - q)/(i + 1); + v += (delta1 * delta1 - v)/(i + 1); + } + r1 = q / v ; + return (float)r1; + } + /** + * Returns the (Pearson Product Moment) correlation matrix between multiple columns of a matrix + * with each column corresponding to a dataset, and each row an observation. + * That is, given P columns, data1, data2, ... , dataP, + * each of length n, it computes and returns the P-by-P correlation + * matrix, C with each element CJK given by + *

    +	 * CJK = CKJ = corr(dataJ,dataK,unbiasedValue).
    +	 * 
    + * @param data The input data. Each column corresponds to a dataset; + * each row corresponds to an observation + * @param unbiased set to true to return the unbiased correlation, + * false to return the biased version. + * @return the correlation matrix (symmetric, by definition) + */ + public static float[][] linear(float[][] data, boolean unbiased){ + int numColumns = data[0].length; + int size = data.length; + float[][] corrMat = new float[numColumns][numColumns]; + float[] data1 = new float[size], data2 = new float[size]; + for(int c1=0; c1 + * corr = cov(x,y,unbiasedValue)/sqrt( cov(x,x, unbiasedValue)*cov(y,y,unbiasedValue) ) + *
    + * @param unbiased set to true to return the unbiased correlation, + * false to return the biased version. + */ + public static float linear(float[] data1, float[] data2, boolean unbiased) { + float denom = cov(data1,data1,unbiased)*cov(data2,data2,unbiased); + return cov(data1,data2,unbiased)/(float)Math.sqrt(denom); + } + + /** + * Computes Spearman's rank-correlation, or rho, between multiple columns of a matrix + * with each column corresponding to a dataset, and each row an observation. + * That is, each pair of columns are first converted to ranks rXJ, rXK + * and the correlation between the ranks computed using the Pearson correlation coefficient + * formula. + * @param unbiased set to true to return the unbiased correlation, + * false to return the biased version. + */ + public static float[][] spearman(float[][] data, boolean unbiased){ + + int numColumns = data[0].length; + int size = data.length; + float[][] corrMat = new float[numColumns][numColumns]; + float[] data1 = new float[size], data2 = new float[size]; + for(int c1=0; c1rho. + * That is, the raw dataset Xi,Yi are first converted to ranks rXi, rYi + * and the correlation between the ranks computed using the Pearson correlation coefficient + * formula. + * @param unbiased set to true to return the unbiased correlation, + * false to return the biased version. + */ + public static float spearman(float[] x, float[] y, boolean unbiased){ + int size = x.length; + Check.equalLengths(size,y); + float[] rX = Rank.rank(x,0); + float[] rY = Rank.rank(y,0); + float rs = linear(rX,rY,unbiased); + //System.out.print("\nx = \t"); Mat.print(x,1); + //System.out.print("\ny = \t"); Mat.print(y,1); + //System.out.println("\nrX = "); Mat.print(rX,1); + //System.out.println("\nrY = "); Mat.print(rY,1); + return rs; + } + /** + * Computes Kendall's rank correlation or tau between two datasets. + * That is, the raw dataset Xi,Yi are first converted to ranks rXi, rYi + * and tau computed as + *
    tau = (nC - nD)/(sqrt(n0-n1)*sqrt(n0-n2))
    + * where + *
    nC is the number of concordant pairs
    + *
    nD is the number of discordant pairs
    + *
    n0 is the sum of ranks = n*(n-1)/2
    + *
    n1 is the sum of tied ranks in dataset 1
    + *
    n2 is the sum of tied ranks in dataset 2
    + * @param unbiased set to true to return the unbiased correlation, + * false to return the biased version. + */ +// public static float kendall(float[] x, float[] y, boolean unbiased){ +// int size = x.length; +// Check.equalLengths(size,y); +// float[] rX = Rank.rank(x,0); +// float[] rY = Rank.rank(y,0); +// //int nConcordant = +// float rs = linear(rX,rY,unbiased); +// return rs; +// } + + /** + * Returns the covariance of two data sequences data1 and data2, + * each of length N. That is, + *
     
    +	 * cov(data1, data2) = E(  (data1[i] - mean(data1))* (data2[i] - mean(data2)) ),
    +	 * 
    + * where E is the mathematical expectation. + *

    + * cov(x,y,true) normalizes by N - 1, if N > 1, where N is the number of observations. + * This makes cov(x,y,true) the best unbiased estimate of the covariance matrix if the + * observations are from a normal distribution. For N = 1, cov(x,y,true) normalizes by N. + *

    + * cov(x,y,false) normalizes by N and produces the second moment matrix of the observations + * about their mean. + * @param data1 x + * @param data2 y + * @param unbiased set to true to return the unbiased covariance (division by N-1), + * false to return the biased version (division by N). + */ + public static float cov(float[] data1, float[] data2, boolean unbiased) { + int size = data1.length; + Check.equalLengths(size,data2); + Check.size0(size); + + float sumx = data1[0], sumy = data2[0], Sxy=0; + for (int i=1; iP columns, data1, data2, ... , dataP, + * each of length n, it computes and returns the P-by-P covariance + * matrix, S with each element SJK given by + *

    +	 * SJK = SKJ = cov(dataJ,dataK,bias).	
    +	 * 
    + * + * cov(data,true) normalizes by N - 1, if N > 1, where N is the number of observations + * (or the number of rows in the input matrix). + * This makes cov(data,true) the best unbiased estimate of the covariance matrix if the + * observations are from a normal distribution. For N = 1, cov(data) normalizes by N. + * + *

    + * cov(data,false) normalizes by N and produces the second moment matrix of the observations + * about their mean. + * @param data Each column corresponds to a dataset; each row corresponds to an observation + * @param unbiased set to true to return the unbiased covariance matrix, false to return the biased version. + */ + public static float[][] cov(float[][] data, boolean unbiased) { + int numColumns = data[0].length; + int size = data.length; + float[] data1 = new float[size], data2 = new float[size]; + float[][] covMat = new float[numColumns][numColumns]; + for(int c1=0; c1 + * C_JK = S_JK / sqrt(S_JJ,unbiasedValue)*sqrt(S_KK,unbiasedValue). + * + * See {@link Weighted#cov(float[][],boolean)}. + * @param data input matrix each column corresponding to a sample, each row an observation. + * @param weights the weights to use. + * @param unbiased set to true to return the unbiased weighted correlation matrix, false to return the biased version. + */ + public static float[][] corr(float[][] data, float[] weights, boolean unbiased){ + int size = data.length; + int numColumns = data[0].length; + float[][] corr= new float[numColumns][numColumns]; + float[][] cov = cov(data,weights,unbiased); + for(int c1=0; c1 + * The formula used to compute element S_JK of the unbiased covariance matrix is: + *

    +		 * S_JK = biasCorrection * Sum ( w[i] * ( dataJ[i] - mu_w(dataJ) )*( dataK[i] - mu_w(dataK) ) ) / Sum (w[i])
    +		 * 
    + * where mu_w corresponds to the weighted mean of the dataset + * and the biasCorrection term above is + *
    +		 * biasCorrection = ( Sum(w[i]) )^2  / ( ( Sum(w[i]) )^2 - Sum( w[i]^2 )  ).
    +		 * 
    + * The elements of the biased covariance matrix are computed sans the bias Correction factor. + *

    + * Reference: + * Covariance of weighted samples, wikipedia.org. + * @param data input matrix each column corresponding to a sample, each row an observation. + * @param weights the weights to use. + * @param unbiased set to true to return the unbiased weighted covariance matrix, false to return the biased version. + */ + public static float[][] cov(float[][] data, float[] weights, boolean unbiased){ + int size = data.length; + int numColumns = data[0].length; + float[][] cov = new float[numColumns][numColumns]; + for(int c1=0; c1not to be used for small datasets(i.e. size<20). + */ + public static class Significance{ + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Significance(){}; + /** + * + * The Durbin-Watson statistic is a test statistic used to detect the presence + * of autocorrelation ({@link Correlation#auto}) + * in the residuals (prediction errors) from a regression analysis. + *

    + * If e_t is the residual associated with the observation at time t, + * and there are T observations, then the test statistic, d is + *

    + *
    +		 * d =   Sum_{from t=2 to T} ( e_t - e_{t-1} )^2    /   Sum_{from t=1 to T} ( e_t )^2
    +		 * 
    + * @return d the Durbin Watson test statistic + */ + public static float durbinWatson(float[] data) { + int size = data.length; + if (size < 2) throw new IllegalArgumentException("data sequence must contain at least two values."); + + float run = 0; + float run_sq = 0; + run_sq = data[0] * data[0]; + for(int i=1; ir + * between two datasets under the null hypothesis of no correlation. + * That is, H_0: ρ=0 (No linear correlation; Two-tailed test). The p-value is + * computed by transforming the correlation to create a t-statistic + * having n-2 degrees of freedom: + *
     t = r * sqrt( (n-2)/(1-r^2) ),
    + * where n is the size of the corresponding datasets. + * @param r the linear correlation coefficient + * @param size the size of the corresponding datasets (i.e. number of rows/observations). + * @throws IllegalArgumentException if the size is less than 20. Below this, + * the student-T approximation is inaccurate. + */ + public static float linear(float r, int size){ + double t = studentT(r,size-2); + return (float)twoTailedStudentT(t,size-2); + + } + /** + * Returns the p-value, or significance level of the Spearman rank-correlation rho + * between two datasets under the null hypothesis of no correlation. + * That is, H_0: ρ_0=0 (No linear correlation; Two-tailed test). + * The p-value is computed by transforming the correlation to create a t-statistic + * having n-2 degrees of freedom: + *
     t = rho * sqrt( (n-2)/(1-rho^2) ),
    + * where n is the size of the corresponding datasets. + * @param rho the Spearman-correlation coefficient + * @param size the size of the corresponding datasets (i.e. number of rows/observations). + * @throws IllegalArgumentException if the size is less than 20. Below this, + * the student-T approximation is inaccurate. + */ + public static float spearman(float rho, int size){ + Check.size20(size); + double t = studentT(rho,size-2); + return (float)twoTailedStudentT(t,size-2); + } + + /** + * Returns the Fisher transformation of the input correlation coefficient. That is, + *
    F(r) = atanh(r);
    + * @param corrcoef the correlation coefficient, r + * @return F(r) + */ + private static double fisher(float corrcoef){ + if(corrcoef==1) return MAXLOG; + if(corrcoef==-1) return MINLOG; + if(corrcoef==0) return 0.0f; + double log = Math.log((1+corrcoef)/(1-corrcoef)); + return (.5*log); + } + /** + * Returns the Student-T test statistic of the input correlation coefficient. That is, + *
    t = abs(r) * sqrt( df/(1-r^2) ), 		df = size-2.
    + * @param corrcoef the correlation coefficient, r + * @param df the degrees of freedom. Corresponds to size-2 + */ + private static double studentT(float corrcoef, int df){ + if(corrcoef==1) return MAXLOG; + if(corrcoef==-1) return MINLOG; + if(corrcoef==0) return 0.0f; + return corrcoef*Math.sqrt( (df)/(1-corrcoef*corrcoef) ); + } + + private static double twoTailedNormal(double z){ + if(z>0) return ( 2*(1.0- (Probability.normcdf(z)) ) ); + else return (2 * (Probability.normcdf(z))); + } + + private static double twoTailedStudentT(double t, int df){ + if(t>0) return ( 2*(1.0- (Probability.tcdf(t,df)) ) ); + else return (2 * (Probability.tcdf(t,df))); + } + + /** + * Returns the z value of the Spearman rank-correlation. + * That is, + *
    z = sqrt((n-3)(1.06)) * F(r), 		F(r) = atanh(r);
    + * @param corrcoef the correlation coefficient, r + * @param size the size of the dataset + */ + private static double zSpearman(float corrcoef, int size){ + Check.size3(size); + double f = fisher(corrcoef); + return Math.sqrt((size-3)/1.06)*f; + } + }// end test class +}// end Correlation class diff --git a/drawing/papaya/src/papaya/CorrelationPlot.java b/drawing/papaya/src/papaya/CorrelationPlot.java new file mode 100644 index 0000000..75e49de --- /dev/null +++ b/drawing/papaya/src/papaya/CorrelationPlot.java @@ -0,0 +1,161 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; +import java.util.Arrays; +import java.io.*; +import java.lang.Object; +import java.lang.String; + +import processing.core.*; + +/** + * Takes in a matrix and plots the data in each of the columns versus + * each other. Each of the columns are normalized to their minimum and maximum values which + * can be a little misleading. For example, say you are looking at columns specifying the weight + * of different panda bears over 100 days. + * Panda bear A (Ling-Ling)'s weight varies from 650 to 970 pounds + * (she's an emotional eater), while panda bear B (Thomas)'s weight varies from 512 to 516 pounds + * (he's not a big fan of bamboo; also kind of metrosexual). The correlation plot will not show you + * this difference in magnitudes or ranges! + * There are many ways of addressing that, and all of them involve you writing your + * own code. :) + *

    If you absolutely insist on using this despite the warning above, then the (somewhat messy) hack + * around it is to pad each column of your data with 2 additional rows containing the + * minimum and maximum that you want to abide by. Just make sure it doesn't muck everything + * else up though! + */ +public class CorrelationPlot extends Visuals{ + + + protected PApplet myParent; + + /**width and height of the individual plots */ + private float w; + private float h; + private int numColumns; + + //CENTER = 3; BOTTOM = 102; TOP = 101; BASELINE = 0; LEFT = 37; RIGHT = 39; + + /** Setup the plot dimensions */ + public CorrelationPlot(PApplet _theParent, float _plotLeft, float _plotTop, float _plotWidth, float _plotHeight){ + super(_theParent,_plotLeft,_plotTop,_plotWidth,_plotHeight); + myParent = _theParent; + bgColor = super.bgColor; + } + + /** + * Plots the scatter plot of each of the columns of the input data matrix vs. the + * other columns. Each of the columns are normalized to their minimum and maximum values which + * can be a little misleading. For example, say you are looking at columns specifying the weight + * of different panda bears over 100 days. + * Panda bear A (Ling-Ling)'s weight varies from 450 to 670 pounds + * (she's an emotional eater), while panda bear B (Thomas)'s weight varies from 512 to 516 pounds + * (he's not a big fan of bamboo). The correlation plot will not show you this difference + * since both could follow the same sort of distribution. + * + * There are many ways of addressing that, and all of them involve you writing your + * own code. :) + *

    If you absolutely insist on using this despite the warning above, then the (very messy) hack + * around it is to pad each column of your data with 2 additional rows containing the + * minimum and maximum that you want to abide by. Just make sure it doesn't muck everything + * else up though! + * + * @param data the data array with each column corresponding to a dataset + * @param pos 0 for top right plots, 1 for bottom left plots + * @param fColor the fill color for the dots on the plot. + */ + public void drawPlot(float[][] data, int pos, int fColor){ + if(pos!=0 && pos!=1) + throw new IllegalArgumentException("Set pos to 0 for top right plots or 1 for bottom left plots."); + if(numColumns!=data[0].length) + throw new IllegalArgumentException("Number of categories doesn't match the number of columns in the matrix."); + + w = plotWidth/numColumns; + h = plotHeight/numColumns; + + float x,y; + + for(int r=0; r + * 2012 rolls along, and Adila (hello!) finds the library and modifies it for Processing, adding a + * number of new methods and updating some of the present ones, all while talking about + * herself in the third person. :) + */ + +package papaya; +import java.util.*; +import java.io.*; +import processing.core.*; + +/** + * Basic descriptive statistics class for exploratory data analysis. + * Methods for computing Correlations and Covariances are in the {@link Correlation} + * class. Where appropriate, methods with similar functions are grouped into + * static subclasses. For example, the {@link Sum} class contains the following + * methods: + *

      + *
    • {@link Sum#inversions} + *
    • {@link Sum#logs} + *
    • {@link Sum#products} + *
    • {@link Sum#powerDeviations} + *
    • {@link Sum#powers} + *
    • {@link Sum#squaredDeviations} + *
    • {@link Sum#squares} + *
    • {@link Sum#sum} + *
    + * while the {@link Mean} class has the + *
      + *
    • {@link Mean#columnMean} + *
    • {@link Mean#rowMean} + *
    • {@link Mean#arithmetic} + *
    • {@link Mean#geometric} + *
    • {@link Mean#harmonic} + *
    • {@link Mean#trimmed} + *
    + * utilities. + */ +public class Descriptive extends Object { + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Descriptive() {} + + /** + * Checks if the given range is within the contained array's bounds. + * @throws IndexOutOfBoundsException if to!=from-1 || from<0 || from>to || to>=size. + */ + protected static void checkRangeFromTo(int from, int to, int theSize) { + if (to==from-1) return; + if (from<0 || from>to || to>=theSize) + throw new IndexOutOfBoundsException("from: "+from+", to: "+to+", size="+theSize); + } + /** + * + * Computes the frequency (number of occurances, count) of each distinct value in the given sorted data. + * After this call, both distinctValues and frequencies have a new size (which is equal for both), + * which is the number of distinct values in the sorted data. + *

    + * Distinct values are filled into distinctValues, starting at index 0. + * The frequency of each distinct value is filled into frequencies, starting at index 0. + * As a result, the smallest distinct value (and its frequency) can be found at index 0, + * the second smallest distinct value (and its frequency) at index 1, ..., + * the largest distinct value (and its frequency) at index distinctValues.size()-1. + *

    + * Example: + *
    + * sortedData = (5,6,6,7,8,8) --> distinctValues = (5,6,7,8), frequencies = (1,2,1,2) + *

    + * Code-wise, you would write: + *
     
    +	 * ArrayList distinctValues = new ArrayList(); 
    +	 * 
    +	 * ArrayList frequencies = new ArrayList();  
    +	 * 
    +	 * frequencies(sortedData,distinctValues,frequencies);
    +	 * 
    + * + * @param sortedData the data; must be sorted ascending. + * @param distinctValues a ArrayList to be filled with the distinct values; can have any size. + * @param frequencies a ArrayList to be filled with the frequencies; can have any size; + * set this parameter to null to ignore it. + * + * @see Frequency + * @see Unique + */ + public static void frequencies(float[] sortedData, ArrayList distinctValues, ArrayList frequencies) { + distinctValues.clear(); + if (frequencies!=null) frequencies.clear(); + + int size = sortedData.length; + int i=0; + + while (i + * This method computes those updated values without needing to know the already recorded elements. + * This is interesting for interactive online monitoring and/or applications that cannot keep the entire huge data sequence in memory. + *

    + *
    Definition of sumOfSquares: sumOfSquares(data) = Sum ( data[i] * data[i] ). + * + * @param data the additional elements to be incorporated into min, max, etc. + * @param from the index of the first element within data to consider. + * @param to the index of the last element within data to consider. + * The method incorporates elements data[from], ..., data[to]. + * @param inOut the old values in the following format: + *

      + *
    • inOut[0] is the old minimum. + *
    • inOut[1] is the old maximum. + *
    • inOut[2] is the old sum. + *
    • inOut[3] is the old sum of squares. + *
    + * If no data sequence elements have so far been recorded set the values as follows + *
      + *
    • inOut[0] = Float.POSITIVE_INFINITY as the old minimum. + *
    • inOut[1] = Float.NEGATIVE_INFINITY as the old maximum. + *
    • inOut[2] = 0.0 as the old sum. + *
    • inOut[3] = 0.0 as the old sum of squares. + *
    + *

    + * @return the updated values filled into the inOut array. + */ + + public static void sumOfSquares(float[] data, int from, int to, double[] inOut) { + checkRangeFromTo(from,to,data.length); + + // read current values + double min = inOut[0]; + double max = inOut[1]; + double sum = inOut[2]; + double sumSquares = inOut[3]; + + for (int i=from; i<=to; i++) { + float element = data[i]; + sum += element; + sumSquares += element*element; + if (element < min) min = element; + if (element > max) max = element; + + /* + double oldDeviation = element - mean; + mean += oldDeviation / (N+1); + sumSquaredDeviations += (element-mean)*oldDeviation; // cool, huh? + */ + + /* + double oldMean = mean; + mean += (element - mean)/(N+1); + if (N > 0) { + sumSquaredDeviations += (element-mean)*(element-oldMean); // cool, huh? + } + */ + + } + + // store new values + inOut[0] = min; + inOut[1] = max; + inOut[2] = sum; + inOut[3] = sumSquares; + + // At this point of return the following postcondition holds: + // data.length-from elements have been consumed by this call. + } + + /** + * Incrementally maintains and updates various sums of powers of the form Sum(data[i]k). + * + * Assume we have already recorded some data sequence elements data[i] + * and know the values of Sum(data[i]from), Sum(data[i]from+1), ..., Sum(data[i]to). + * Assume further, we are to record some more elements + * and to derive updated values of these sums. + *

    + * This method computes those updated values without needing to know the already recorded elements. + * This is interesting for interactive online monitoring and/or applications that cannot keep the entire huge data sequence in memory. + * For example, the incremental computation of moments is based upon such sums of powers: + *

    + * The moment of k-th order with constant c of a data sequence, + * is given by Sum( (data[i]-c)k ) / data.size(). + * It can incrementally be computed by using the equivalent formula + *

    + * moment(k,c) = m(k,c) / data.size() where + *
    m(k,c) = Sum( -1i * b(k,i) * ci * sumOfPowers(k-i)) for i = 0 .. k and + *
    b(k,i) = {@link cern.jet.math.Arithmetic#binomial(long,long) binomial(k,i)} and + *
    sumOfPowers(k) = Sum( data[i]k ). + *

    + * @param data the additional elements to be incorporated into min, max, etc. + * @param from the index of the first element within data to consider. + * @param to the index of the last element within data to consider. + * The method incorporates elements data[from], ..., data[to]. + * + * @param inOut the old values of the sums in the following format: + *

      + *
    • sumOfPowers[0] is the old Sum(data[i]fromSumIndex). + *
    • sumOfPowers[1] is the old Sum(data[i]fromSumIndex+1). + *
    • ... + *
    • sumOfPowers[toSumIndex-fromSumIndex] is the old Sum(data[i]toSumIndex). + *
    + * If no data sequence elements have so far been recorded set all old values of the sums to 0.0. + * + * @return the updated values filled into the sumOfPowers array. + */ + public static void sumOfPowers(float[] data, int from, int to, int fromSumIndex, int toSumIndex, double[] sumOfPowers) { + int size = data.length; + int lastIndex = toSumIndex - fromSumIndex; + if (from > size || lastIndex+1 > sumOfPowers.length) throw new IllegalArgumentException(); + + // optimized for common parameters + if (fromSumIndex==1) { // handle quicker + if (toSumIndex==2) { + double sum = sumOfPowers[0]; + double sumSquares = sumOfPowers[1]; + for (int i=from-1; ++i<=to; ) { + float element = data[i]; + sum += element; + sumSquares += element*element; + //if (element < min) min = element; + //else if (element > max) max = element; + } + sumOfPowers[0] += sum; + sumOfPowers[1] += sumSquares; + return; + } + else if (toSumIndex==3) { + double sum = sumOfPowers[0]; + double sumSquares = sumOfPowers[1]; + double sum_xxx = sumOfPowers[2]; + for (int i=from-1; ++i<=to; ) { + float element = data[i]; + sum += element; + sumSquares += element*element; + sum_xxx += element*element*element; + //if (element < min) min = element; + //else if (element > max) max = element; + } + sumOfPowers[0] += sum; + sumOfPowers[1] += sumSquares; + sumOfPowers[2] += sum_xxx; + return; + } + else if (toSumIndex==4) { // handle quicker + double sum = sumOfPowers[0]; + double sumSquares = sumOfPowers[1]; + double sum_xxx = sumOfPowers[2]; + double sum_xxxx = sumOfPowers[3]; + for (int i=from-1; ++i<=to; ) { + float element = data[i]; + sum += element; + sumSquares += element*element; + sum_xxx += element*element*element; + sum_xxxx += element*element*element*element; + //if (element < min) min = element; + //else if (element > max) max = element; + } + sumOfPowers[0] += sum; + sumOfPowers[1] += sumSquares; + sumOfPowers[2] += sum_xxx; + sumOfPowers[3] += sum_xxxx; + return; + } + } + + if (fromSumIndex==toSumIndex || (fromSumIndex >= -1 && toSumIndex <= 5)) { // handle quicker + for (int i=fromSumIndex; i<=toSumIndex; i++) { + sumOfPowers[i-fromSumIndex] += Sum.powerDeviations(data,i,0.0f,from,to); + } + return; + } + // now the most general case: + // optimized for maximum speed, but still not quite quick + for (int i=from-1; ++i<=to; ) { + float element = data[i]; + double pow = Math.pow(element,fromSumIndex); + + int j=0; + for (int m=lastIndex; --m >= 0; ) { + sumOfPowers[j++] += pow; + pow *= element; + } + sumOfPowers[j] += pow; + } + // At this point of return the following postcondition holds: + // data.size()-fromIndex elements have been consumed by this call. + } + /** + * Incrementally maintains and updates sum and sum of squares of a weighted data sequence. + * + * Assume we have already recorded some data sequence elements + * and know their sum and sum of squares. + * Assume further, we are to record some more elements + * and to derive updated values of sum and sum of squares. + *

    + * This method computes those updated values without needing to know the already recorded elements. + * This is interesting for interactive online monitoring and/or applications that cannot keep the entire huge data sequence in memory. + *

    + *
    Definition of sum: sum = Sum ( data[i] * weights[i] ). + *
    Definition of sumOfSquares: sumOfSquares = Sum ( data[i] * data[i] * weights[i]). + * + * + * @param data the additional elements to be incorporated into min, max, etc. + * @param weights the weight of each element within data. + * @param from the index of the first element within data (and weights) to consider. + * @param to the index of the last element within data (and weights) to consider. + * The method incorporates elements data[from], ..., data[to]. + * @param inOut the old values in the following format: + *

      + *
    • inOut[0] is the old sum. + *
    • inOut[1] is the old sum of squares. + *
    + * If no data sequence elements have so far been recorded set the values as follows + *
      + *
    • inOut[0] = 0.0 as the old sum. + *
    • inOut[1] = 0.0 as the old sum of squares. + *
    + * + * @return the updated values filled into the inOut array. + */ + public static void sumOfSquaresWeighted(float[] data, float[] weights, int from, int to, float[] inOut) { + int dataSize = data.length; + checkRangeFromTo(from,to,dataSize); + if (dataSize != weights.length) throw new IllegalArgumentException("from="+from+", to="+to+", data.length="+dataSize+", weights.length="+weights.length); + + // read current values + float sum = inOut[0]; + float sumOfSquares = inOut[1]; + + for (int i=from-1; ++i<=to; ) { + float element = data[i]; + float weight = weights[i]; + float prod = element*weight; + + sum += prod; + sumOfSquares += element * prod; + } + + // store new values + inOut[0] = sum; + inOut[1] = sumOfSquares; + + // At this point of return the following postcondition holds: + // data.size()-from elements have been consumed by this call. + } + + }// end IncrUpdate class + /** + * Returns the kurtosis (aka excess) of a data sequence. + * @param moment4 the fourth central moment, which is moment(data,4,mean). + * @param standardDeviation the standardDeviation. + */ + public static float kurtosis(float moment4, float standardDeviation) { + return -3 + moment4 / (standardDeviation * standardDeviation * standardDeviation * standardDeviation); + } + /** + * Returns the kurtosis (aka excess) of a data sequence, which is + * -3 + moment(data,4,mean) / standardDeviation4. + */ + public static float kurtosis(float[] data, float mean, float standardDeviation) { + return kurtosis(moment(data,4,mean), standardDeviation); + } + + public static int max(int a, int b) { + return (a > b) ? a : b; + } + + public static float max(float a, float b) { + return (a > b) ? a : b; + } + + + public static double max(double a, double b) { + return (a > b) ? a : b; + } + + + /** + * Returns the largest member of a data sequence. + */ + public static double max(double[] data) { + int size = data.length; + Check.size0(size); + double max = data[size-1]; + for (int i = size-1; --i >= 0;) { + if (data[i] > max) max = data[i]; + } + return max; + } + /** + * Returns the largest member of a data sequence. + */ + public static float max(float[] data) { + int size = data.length; + Check.size0(size); + float max = data[0]; + for (int i = 0; iSum( data[i] ) / data.length . + */ + public static float arithmetic(float[] data) { + return Sum.sum(data) / data.length; + } + + /** + * Returns the geometric mean of a data sequence. + * Note that for a geometric mean to be meaningful, the minimum of the data sequence must not be less or equal to zero. + *
    + * The geometric mean is given by pow( Product( data[i] ), 1/size) + * which is equivalent to Math.exp( Sum( Log(data[i]) ) / size). + *

    + * The latter version is used here is the former easily results in overflows. + */ + public static float geometric(int size, float sumOfLogarithms) { + return (float)Math.exp(sumOfLogarithms/size); + // this version would easily results in overflows + //return Math.pow(product, 1/size); + } + /** + * Returns the geometric mean of a data sequence. + * Note that for a geometric mean to be meaningful, the minimum of the data sequence must not be less or equal to zero. + *
    + * The geometric mean is given by pow( Product( data[i] ), 1/data.size()). + * This method tries to avoid overflows at the expense of an equivalent but somewhat slow definition: + * geometricMean = Math.exp( Sum( Log(data[i]) ) / size). + */ + public static float geometric(float[] data) { + return geometric(data.length, (float)Sum.logs(data,0,data.length-1)); + } + /** + * Returns the harmonic mean of a data sequence. + * + * @param size the number of elements in the data sequence. + * @param sumOfInversions Sum( 1.0 / data[i]). + */ + public static float harmonic(int size, float sumOfInversions) { + return size / sumOfInversions; + } + + /** + * Returns the harmonic mean of a data sequence as Sum( 1.0 / data[i]). + * + * @param data array + */ + public static float harmonic(float[] data) { + return (float)data.length / (float)Sum.inversions(data, 0, data.length-1); + } + /** + * Returns the trimmed arithmetic mean of a sorted data sequence. + * @param sortedData the data sequence; must be sorted ascending. + * @param mean the mean of the (full) sorted data sequence. + * @param left the number of leading elements to trim. + * @param right the number of trailing elements to trim. + * */ + public static float trimmed(float[] sortedData, float mean, int left, int right) { + int size = sortedData.length; + Check.size0(size); + if (left+right >= size) throw new IllegalArgumentException("Not enough data. left: "+left+", right: "+right+", data length: "+ size); + int origLn=size; + for(int i=0; imust be sorted ascending. + * @param mean the mean of the (full) sorted data sequence. + * @param left the number of leading elements to trim. + * @param right the number of trailing elements to trim. + */ + public static float winsorized(float[] sortedData, float mean, int left, int right) { + int size = sortedData.length; + Check.size0(size); + if (left+right >= size) throw new IllegalArgumentException("Not enough data."); + + float leftElement = sortedData[left]; + float winsorMean = mean; + for(int i=0; iarithmetic mean of a data sequence; + * That is Sum( data[i] ) / data.length . + * Similar to {@link Mean#arithmetic}. + */ + public static float mean(float[] data) { + return Mean.arithmetic(data); + } + /** + * Returns the mean deviation of a dataset. + * That is Sum( Math.abs(data[i]-mean)) ) / data.length. + */ + public static float meanDeviation(float[] data, float mean) { + + int size = data.length; + double sum=0; + for (int i=size; --i >= 0;) sum += Math.abs(data[i]-mean); + return (float)sum/size; + } + + /** + * Returns the median of a data sequence. + * @param data the data sequence; + * @param isSorted true if the data sequence is sorted (in ascending order), else false. + */ + public static float median(float[] data, boolean isSorted) { + if(isSorted) return quantile(data, 0.5f); + else{ + float[] sortedData = Mat.copyThenSort(data); + return quantile(sortedData, 0.5f); + } + } + + public static int min(int a, int b) { + return (a < b) ? a : b; + } + + public static float min(float a, float b) { + return (a < b) ? a : b; + } + public static double min(double a, double b) { + return (a < b) ? a : b; + } + /** + * Returns the smallest member of a data sequence. + */ + public static double min(double[] data) { + int size = data.length; + Check.size0(size); + double min = data[0]; + for (int i = 1; i distinctValues = new ArrayList(); + ArrayList frequencies = new ArrayList(); + frequencies(data,distinctValues,frequencies); + int maxRepeats = frequencies.get(0); int size = frequencies.size(); + for(int i=1; imaxRepeats) { + maxRepeats = frequencies.get(i); + } + } + ArrayList tempMod = new ArrayList(); + for(int i=0; ik-th order with constant c of a data sequence, + * which is Sum( (data[i]-c)k ) / data.length. + * + * @param sumOfPowers sumOfPowers[m] == Sum( data[i]m) ) for m = 0,1,..,k as returned by method + * {@link #incrementalUpdateSumsOfPowers(DoubleArrayList,int,int,int,int,double[])}. + * In particular there must hold sumOfPowers.length == k+1. + * @param size the number of elements of the data sequence. + */ + // public static float moment(int k, float c, int size, float[] sumOfPowers) { + // double sum=0; + // int sign = 1; + // for (int i=0; i<=k; i++) { + // double y; + // if (i==0) y = 1; + // else if (i==1) y = c; + // else if (i==2) y = c*c; + // else if (i==3) y = c*c*c; + // else y = Math.pow(c, i); + // //sum += sign * + // sum += sign * cern.jet.math.Arithmetic.binomial(k,i) * y * sumOfPowers[k-i]; + // sign = -sign; + // } + // /* + // for (int i=0; i<=k; i++) { + // sum += sign * cern.jet.math.Arithmetic.binomial(k,i) * Math.pow(c, i) * sumOfPowers[k-i]; + // sign = -sign; + // } + // */ + // return sum/size; + // } + /** + * Returns the moment of k-th order with constant c of a data sequence, + * which is Sum( (data[i]-c)k ) / data.size(). + */ + public static float moment(float[] data, int k, float c) { + return (float)Sum.powerDeviations(data,k,c) / data.length; + } + /** + * Returns the array containing all elements in the dataset that are less than + * or equal to the lowerLimit + * and more than or equal to the upperLimit + * @param data the data array + * @param lowerLimit + * @param upperLimit + * @param isSorted true if the data array has been sorted in ascending order, else set to false. + */ + public static float[] outliers(float[] data, float lowerLimit, float upperLimit, boolean isSorted){ + int size = data.length; + float[] sortedData = new float[size]; + if(isSorted){ + sortedData = data; + } + else{ + sortedData = Mat.copyThenSort(data); + } + float max = sortedData[size-1]; float min = sortedData[0]; + float[] tempArray = new float[size]; + int i=0; + if(lowerLimit>=min){ + while(sortedData[i]<=lowerLimit){ + tempArray[i] = sortedData[i]; + i++; + } + } + int newSize = i; + i = size-1; + if(upperLimit<=max){ + while(sortedData[i]>=upperLimit){ + tempArray[i] = sortedData[i]; + i--; + newSize++; + } + } + float[] outliers = Arrays.copyOf(tempArray,newSize); + //Arrays.sort(outliers); + return outliers; + } + + /** Class for computing the pooled mean and variance of data sequences */ + public static class Pooled{ + protected Pooled(){} + + /** + * Returns the pooled mean of two data sequences. + * That is (size1 * mean1 + size2 * mean2) / (size1 + size2). + *

    + * @param size1 the number of elements in data sequence 1. + * @param mean1 the mean of data sequence 1. + * @param size2 the number of elements in data sequence 2. + * @param mean2 the mean of data sequence 2. + */ + public static float mean(float mean1, int size1, float mean2, int size2) { + return (size1 * mean1 + size2 * mean2) / (size1 + size2); + } + /** + * Returns the pooled mean of a k data sequences. + * That is (size1 * mean1 + size2 * mean1 + ... + sizek * meank) / (size1 + size2 + ... + sizek). + *

    + * + */ + public static float mean(float[] means, int[] sizes) { + int size = sizes.length; + Check.equalLengths(size,means); + float sum=0, sumSizes=0; + for(int i=0; i + * unbiasedPooledVar = Sum( (size_i -1)*variance_i ) / Sum( (size_i-1) ), + * + * while the biased pooled variance is computed using + *

    +		 * biasedPooledVar = Sum( (size_i)*variance_i ) / Sum(size_i),
    +		 * 
    +		 * For more than 2 datasets, use {@link Pooled#var(float[],int[],boolean)}.
    +		 *
    +		 * @param size1 the number of elements in data sequence 1.
    +		 * @param variance1 the variance of data sequence 1.
    +		 * @param size2 the number of elements in data sequence 2.
    +		 * @param variance2 the variance of data sequence 2.
    +		 * @param unbiased set to true to return the unbiased pooled variance,
    +		 * false to return the biased version.
    +		 */
    +		public static float var(float variance1, int size1, float variance2, int size2, boolean unbiased) {
    +			if(!unbiased) return (size1 * variance1 + size2 * variance2) / (size1 + size2);
    +			else return((size1-1)*variance1+(size2-1)*variance2)/(size1+size2-2);
    +		}
    +		/**
    +		 * Returns the pooled variance of k data sequences. The unbiased estimate of the
    +		 * pooled variance is computed as
    +		 * 
    +		 * unbiasedPooledVar = Sum( (sizes[i] -1)*variances[i] ) / Sum( (sizes[i]-1) ),
    +		 * 
    + * while the biased pooled variance is computed using + *
    +		 * biasedPooledVar = Sum( (sizes[i])*variances[i] ) / Sum(sizes[i]),
    +		 */
    +		public static float var(float[] variances, int[] sizes, boolean unbiased) {
    +			int size = sizes.length;
    +			Check.equalLengths(size, variances);
    +			float sizeSum = sizes[0];
    +			float varianceSum=0;
    +			float pooledVar = 0;
    +			if(unbiased){
    +				for(int i=0; iProd( data[i] ).
    +	 * In other words: data[0]*data[1]*...*data[data.length-1].
    +	 * This method uses the equivalent definition:
    +	 * prod = pow( exp( Sum( Log(x[i]) ) / length*length).
    +	 */
    +	public static float product(int size, float sumOfLogarithms) {
    +		return (float)Math.pow(Math.exp(sumOfLogarithms/size), size);
    +	}
    +	/**
    +	 * Returns the product of a data sequence, which is Prod( data[i] ).
    +	 * In other words: data[0]*data[1]*...*data[data.length-1].
    +	 * Note that you may easily get numeric overflows. Use {@link product(int,float)}
    +	 * instead to avoid that.
    +	 */
    +	public static float product(float[] data) {
    +		int size = data.length;
    +		float product = 1;
    +		for (int i=size; --i >= 0;) product *= data[i];
    +		return product;
    +	}
    +
    +	/** 
    +	 * Returns the quartiles of the input data array (not necessarily sorted).
    +	 * 
    +	 * 

    Details:
    + * The first quartile, or lower quartile (Q[0]), is the value that cuts off + * the first 25% of the data when it is sorted in ascending order. + * The second quartile, or median (Q[1]), is the value that cuts off the first 50%. + * The third quartile, or upper quartile (Q[2], is the value that cuts off the first 75%. + *

    + * + * @param data The data array. + * @param isSorted true if the data array has been sorted in ascending order, else set to false. + * @return The 3 quartile values Q[0], Q[1], and Q[2]. + */ + public static float[] quartiles(float[] data, boolean isSorted){ + float[] quartiles = new float[3]; + if(isSorted){ + quartiles = Descriptive.quantiles(data, new float[]{.25f,.5f,.75f}); + } + else{ + quartiles = Descriptive.quantiles(Mat.copyThenSort(data), new float[]{.25f,.5f,.75f}); + } + return quartiles; + } + + /** + * Returns the phi-quantile; that is, an element elem + * for which holds that phi percent of data elements are less than + * elem. + * The quantile need not necessarily be contained in the data sequence, + * it can be a linear interpolation. + * @param sortedData the data sequence; must be sorted ascending. + * @param phi the percentage; must satisfy 0 <= phi <= 1. + */ + public static float quantile(float[] sortedData, float phi) { + + int size = sortedData.length; + + float index = phi * (size - 1) ; + int lhs = (int)index ; + float delta = index - lhs ; + float result; + + if (size == 0) return 0.0f ; + + if (lhs == size - 1) { + result = sortedData[lhs] ; + } + else { + result = (1 - delta) * sortedData[lhs] + delta * sortedData[lhs + 1] ; + } + return result ; + } + /** + * Returns how many percent of the elements contained in the receiver are <= element. + * Does linear interpolation if the element is not contained but lies in between + * two contained elements. + * + * @param sortedList the list to be searched (must be sorted ascending). + * @param element the element to search for. + * @return the percentage phi of elements <= element + * (0.0 <= phi <= 1.0). + */ + public static float quantileInverse(float[] sortedList, float element) { + return rankInterpolated(sortedList,element) / sortedList.length; + } + /** + * Returns the quantiles of the specified percentages. + * The quantiles need not necessarily be contained in the data sequence, it can be a linear interpolation. + * @param sortedData the data sequence; must be sorted ascending. + * @param percentages the percentages for which quantiles are to be computed. + * Each percentage must be in the interval [0.0f,1.0f]. + * @return the quantiles. + */ + public static float[] quantiles(float[] sortedData, float[] percentages) { + int s = percentages.length; + ArrayList quantiles = new ArrayList(s); + for (int i=0; i < s; i++) { + quantiles.add(quantile(sortedData, percentages[i])); + } + return Cast.arrayListToFloat(quantiles); + } + /** + * Returns the linearly interpolated number of elements in an array that + * are ≤ a given element. + * The rank is the number of elements ≤ element. + * Ranks are of the form {0, 1, 2,..., sortedList.size()}. + *

    If no element is ≤ element, then the rank is zero.

    + * + *

    If the element lies in between two contained elements, then + * linear interpolation is used and a non integer value is returned.

    + * + * @param sortedList the list to be searched (must be sorted ascending). + * @param element the element to search for. + * @return the rank of the element. + */ + public static float rankInterpolated(float[] sortedList, float element) { + int index = Arrays.binarySearch(sortedList,element); + if (index >= 0) { // element found + // skip to the right over multiple occurances of element. + int to = index+1; + int s = sortedList.length; + while (toMath.sqrt(Sum( data[i]*data[i] ) / data.length). + * The RMS of data sequence is the square-root of the mean of the squares of the elements in the data sequence. + * It is a measure of the average "size" of the elements of a data sequence. + * + * @param sumOfSquares sumOfSquares(data) == Sum( data[i]*data[i] ) of the data sequence. + * @param size the number of elements in the data sequence. + */ + public static float rms(int size, double sumOfSquares) { + return (float)Math.sqrt(sumOfSquares/size); + } + + /** + * Contains sample-related statistical methods. + */ + private static class Sample{ + protected Sample(){} + /** + * Returns the sample kurtosis (aka excess) of a data sequence. + * That is, + *
    +		 * γ_2 = moment4*n^2*(n+1)/ ((n-1)*(n-2)*(n-3)*var^2) - 3*(n-1)^2/ ( (n-2)*(n-3) ) 
    +		 *     = Sum( (y_i-ymean)^4 )*n*(n+1)/ ((n-1)*(n-2)*(n-3)*var^2) - 3*(n-1)^2/ ( (n-2)*(n-3) ), 
    +		 * 
    + * where n is the length of the input data array. + *

    + * Ref: R.R. Sokal, F.J. Rohlf, Biometry: the principles and practice of statistics + * in biological research (W.H. Freeman and Company, New York, 1998, 3rd edition) + * p. 114-115. + * + * @param size the number of elements of the data sequence. + * @param moment4 the fourth central moment, which is moment(data,4,mean). + * @param sampleVariance the sample variance. + */ + public static float sampleKurtosis(int size, float moment4, float sampleVariance) { + float n=size; // set to float to avoid NaNs. + float s2=sampleVariance; // (y-ymean)^2/(n-1) + float m4 = moment4*n; // (y-ymean)^4 + return m4*n*(n+1) / ( (n-1)*(n-2)*(n-3)*s2*s2 ) + - 3.0f*(n-1)*(n-1)/((n-2)*(n-3)); + } + /** + * Returns the sample kurtosis (aka excess) of a data sequence. + */ + public static float sampleKurtosis(float[] data, float mean, float sampleVariance) { + return sampleKurtosis(data.length,moment(data,4,mean), sampleVariance); + } + /** + * Return the standard error of the sample kurtosis. That is, + *

    +		 * Sqrt( 24n*(n-1)*(n-1)/((n-3)*(n-2)*(n+3)*(n+5)) ), 
    +		 * 
    + * where n is the length of the input array. + *

    + * Ref: R.R. Sokal, F.J. Rohlf, Biometry: the principles and practice of statistics + * in biological research (W.H. Freeman and Company, New York, 1998, 3rd edition) + * p. 138. + * @param size the number of elements of the data sequence. + */ + public static float sampleKurtosisStandardError(int size) { + float n=size; // set to float to avoid NaNs. + return (float)Math.sqrt( 24.0*n*(n-1)*(n-1)/((n-3)*(n-2)*(n+3)*(n+5)) ); + } + /** + * Returns the sample skew of a data sequence. That is + *

    +		 * γ_1 = moment3*n^2 / ((n-1)*(n-2)*stdev^3)
    +		 *     = Sum( (y_i-ymean)^3 )/stdev^3  *  n /  ((n-1)*(n-2)), 
    +		 * 
    + * where n is the length of the input data array. + *

    + * Ref: R.R. Sokal, F.J. Rohlf, Biometry: the principles and practice of statistics + * in biological research (W.H. Freeman and Company, New York, 1998, 3rd edition) + * p. 114-115. + * @param size the number of elements of the data sequence. + * @param moment3 the third central moment, which is moment(data,3,mean). + * @param sampleVariance the sample variance. + */ + public static float sampleSkew(int size, float moment3, float sampleVariance) { + float n=size; // set to float to avoid NaNs + float s=(float)Math.sqrt(sampleVariance); // sqrt( (y-ymean)^2/(n-1) ) + float m3 = moment3*n; // (y-ymean)^3 + return n*m3 / ((n-1)*(n-2)*s*s*s); + } + /** + * Returns the sample skew of a data sequence. + */ + public static float sampleSkew(float[] data, float mean, float sampleVariance) { + return sampleSkew(data.length, moment(data,3,mean), sampleVariance); + } + /** + * Return the standard error of the sample skew. That is, + *

    +		 * Sqrt( 6n*(n-1)/((n-2)*(n+1)*(n+3)) ), 
    +		 * 
    + * where n is the length of the input array. + *

    + * Ref: R.R. Sokal, F.J. Rohlf, Biometry: the principles and practice of statistics + * in biological research (W.H. Freeman and Company, New York, 1998, 3rd edition) + * p. 138. + * + * @param size the number of elements of the data sequence. + */ + public static float sampleSkewStandardError(int size) { + float n=size; + return (float)Math.sqrt( 6.0*n*(n-1)/((n-2)*(n+1)*(n+3)) ); + } + } + + /** + * Returns the skew of a data sequence when the 3rd moment has already been computed. + * @param moment3 the third central moment, which is moment(data,3,mean). + * @param standardDeviation the standardDeviation. + */ + public static float skew(float moment3, float standardDeviation) { + return moment3 / (standardDeviation * standardDeviation * standardDeviation); + } + /** + * Returns the skew of a data sequence, which is moment(data,3,mean) / standardDeviation3. + */ + public static float skew(float[] data, float mean, float standardDeviation) { + return skew(moment(data,3,mean), standardDeviation); + } + + /** + * Returns the standard deviation of a dataset. + * + * There are two definitions of the standard deviation: + *

    +	 * sigma_1 = 1/(N-1) * Sum( (x[i] - mean(x))^2 )
    +	 * sigma_2 = 1/(N) * Sum( (x[i] - mean(x))^2 )
    +	 * 
    + * sigma_1 is the square root of an unbiased estimator of the variance of the population + * the x is drawn, as long as x consists of independent, identically distributed samples. + * sigma_2 corresponds to the second moment of the set of values about their mean. + *

    + * std(data,unbiased==true) returns sigma_1 above, while std(data,unbiased==false) returns sigma_2. + * @param data the dataset + * @param unbiased set to true to return the unbiased standard deviation, + * false to return the biased version. + */ + public static float std(float[] data, boolean unbiased) { + return (float)Math.sqrt(var(data,unbiased)); + } + + + /** + * Returns an array with each element of the array corresponding to + * the standard deviations of each column of the input + * matrix. Each column of the matrix corresponds to a dataset, and each row an observation. + * + * There are two definitions of the standard deviation: + *

    +	 * sigma_1 = 1/(N-1) * Sum( (x[i] - mean(x))^2 )
    +	 * sigma_2 = 1/(N) * Sum( (x[i] - mean(x))^2 )
    +	 * 
    + * sigma_1 is the square root of an unbiased estimator of the variance of the population + * the x is drawn, as long as x consists of independent, identically distributed samples. + * sigma_2 corresponds to the second moment of the set of values about their mean. + *

    + * std(data,unbiased==true) returns sigma_1 above, while std(data,unbiased==false) returns sigma_2. + * + * @param data the dataset + * @param unbiased set to true to return the unbiased standard deviation, + * false to return the biased version. + */ + public static float[] std(float[][] data, boolean unbiased) { + int numColumns = data[0].length; + float[] std = new float[numColumns]; + float[] dataEach = new float[data.length]; + float variance = 0; + for(int i=0; inormally distributed. + * + * Ref: R.R. Sokal, F.J. Rohlf, Biometry: the principles and practice of statistics + * in biological research (W.H. Freeman and Company, New York, 1998, 3rd edition) + * p. 53. + *

    See also this entry on wikipedia.org + * + * @param size the number of elements of the data sequence. + * @param sampleVariance the sample variance. + */ + public static float stdUnbiased(int size, float sampleVariance) { + double s, Cn; + int n=size; + // The standard deviation calculated as the sqrt of the variance underestimates + // the unbiased standard deviation. + s=Math.sqrt(sampleVariance); + // It needs to be multiplied by this correction factor. + if (n>30) { + Cn = 1 + 1.0/(4*(n-1)); // Cn = 1+1/(4*(n-1)); + } else { + Cn = Math.sqrt((n-1)*0.5)*Gamma.gamma((n-1)*0.5)/Gamma.gamma(n*0.5); + } + return (float) (Cn*s); + } + + /** Methods for computing various different sums of datasets such as sum of inversions, + * logs, products, power deviations, squares, etc. */ + + public static class Sum{ + protected Sum(){}; + /** + * Returns the sum of inversions of a data sequence, + * which is Sum( 1.0 / data[i]). + * @param data the data sequence. + * @param from the index of the first data element (inclusive). + * @param to the index of the last data element (inclusive). + */ + public static double inversions(float[] data, int from, int to) { + return powerDeviations(data,-1,0.0f,from,to); + } + /** + * Returns the sum of logarithms of a data sequence, which is Sum( Log(data[i]). + * @param data the data sequence. + * @param from the index of the first data element (inclusive). + * @param to the index of the last data element (inclusive). + */ + public static double logs(float[] data, int from, int to) { + double logsum = 0; + for (int i=from-1; ++i <= to;) logsum += Math.log(data[i]); + return (float)logsum; + } + /** + * Returns the sum of the product of two data arrays, Sum( x[i] * y[i]). + * @param data1 the first data sequence. + * @param data2 the second data sequence + * @return the sum of the product of the two data sequences. + */ + public static double products(float[] data1, float[] data2) { + int size = data1.length; + Check.equalLengths(size,data2); + + double sumOfProduct = data1[0]*data2[0]; + for (int i=1; iSum( (data[i]-c)k ); + * optimized for common parameters like c == 0.0 and/or k == -2 .. 4. + */ + public static double powerDeviations(float[] data, int k, float c) { + return powerDeviations(data,k,c,0,data.length-1); + } + /** + * Returns Sum( (data[i]-c)k ) for all i = from .. to; + * optimized for common parameters like c == 0.0 and/or k == -2 .. 5. + * Note that no checks are made for divisions by zero (important for + * k = -2 and k = -1), so think twice before using this + * if the data has elements = 0. + */ + + public static double powerDeviations(final float[] data, final int k, final float c, final int from, final int to) { + + double sum = 0.0; + double v; + int i; + switch (k) { // optimized for speed + case -2: + if (c==0.0) for (i=from-1; ++i<=to; ) { v = data[i]; sum += 1/(v*v); } + else for (i=from-1; ++i<=to; ) { v = data[i]-c; sum += 1/(v*v); } + break; + case -1: + if (c==0.0) for (i=from-1; ++i<=to; ) sum += 1/(data[i]); + else for (i=from-1; ++i<=to; ) sum += 1/(data[i]-c); + break; + case 0: + sum += to-from+1; + break; + case 1: + if (c==0.0) for (i=from-1; ++i<=to; ) sum += data[i]; + else for (i=from-1; ++i<=to; ) sum += data[i]-c; + break; + case 2: + if (c==0.0) for (i=from-1; ++i<=to; ) { v = data[i]; sum += v*v; } + else for (i=from-1; ++i<=to; ) { v = data[i]-c; sum += v*v; } + break; + case 3: + if (c==0.0) for (i=from-1; ++i<=to; ) { v = data[i]; sum += v*v*v; } + else for (i=from-1; ++i<=to; ) { v = data[i]-c; sum += v*v*v; } + break; + case 4: + if (c==0.0) for (i=from-1; ++i<=to; ) { v = data[i]; sum += v*v*v*v; } + else for (i=from-1; ++i<=to; ) { v = data[i]-c; sum += v*v*v*v; } + break; + case 5: + if (c==0.0) for (i=from-1; ++i<=to; ) { v = data[i]; sum += v*v*v*v*v; } + else for (i=from-1; ++i<=to; ) { v = data[i]-c; sum += v*v*v*v*v; } + break; + default: + for (i=from-1; ++i<=to; ) sum += Math.pow(data[i]-c, k); + break; + } + return sum; + } + /** + * Returns the sum of powers of a data sequence, which is Sum ( data[i]k ). + */ + public static double powers(float[] data, int k) { + return powerDeviations(data,k,0); + } + /** + * Returns the sum of squared mean deviation of of a data sequence. + * That is variance * (size-1) == Sum( (data[i] - mean)^2 ). + * + * @param size the number of elements of the data sequence. + * @param variance the variance of the data sequence. + */ + public static float squaredDeviations(int size, float variance) { + return variance * (size-1); + } + /** + * Returns the sum of squares of a data sequence. + * That is Sum ( data[i]*data[i] ). + */ + public static double squares(float[] data) { + return powerDeviations(data,2,0.0f); + } + /** + * Returns the simple sum of a data sequence. + * That is Sum( data[i] ). + * @see Mat#sum(float[]) + * @see Mat#sum(float[], float[]) + * @see Mat#sum(float[],float) + */ + public static float sum(float[] data) { + return (float)Sum.powerDeviations(data,1,0.0f); + } + } // end Sum class + + /** + * Return the tukey five number summary of a dataset consisting of the minimum, maximum, + * and three quartile values. + * @param data the data array + * @return the array of five numbers. + */ + public static float[] tukeyFiveNum(float[] data){ + int size = data.length; + float[] sortedArray = Mat.copyThenSort(data); + float[] Q = quartiles(sortedArray, true); + float[] fiveNum = new float[5]; + fiveNum[0] = sortedArray[0]; + fiveNum[4]=sortedArray[size-1]; + fiveNum[1] = Q[0]; fiveNum[2] = Q[1]; fiveNum[3] = Q[2]; + return fiveNum; + } + + /** + * Returns the variance of a dataset, V. + * For matrices, var(X,unbiased=true) returns an array containing the variance of each column of X. + * The result V is an unbiased estimator of the variance of the population from which + * X is drawn, as long as X consists of independent, identically distributed samples. + *

    + * var(x,true) normalizes V by N - 1 if N > 1, where N is the sample size. + * This is an unbiased estimator of the variance of the population from which X is drawn, + * as long as X consists of independent, identically distributed samples. For N = 1, + * V is normalized by 1. + *

    + * V = var(x,false) normalizes by N and produces the second moment of the sample about its mean. + * + *

    Reference: + *
    + * Algorithms for calculating variance, Wikipedia.org + *
    + * Incremental calculation of weighted mean and variance, Tony Finch + * @param data the data sequence. + * @param unbiased set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N). + * @return the variance in the data. + */ + public static float var(float[] data, boolean unbiased) { + int size = data.length; + float varianceSum = varianceNotNormalized(data); + if(unbiased && size>1) return varianceSum/(size-1); + return varianceSum/size; + } + + /** + * Returns an array containing the variance of each column of the input matrix X. + * The result V is an unbiased estimator of the variance of the population from which + * X is drawn, as long as X consists of independent, identically distributed samples. + *

    + * var(X,unbiased=true) normalizes V by N - 1 if N > 1, where N is the sample size. + * This is an unbiased estimator of the variance of the population from which X is drawn, + * as long as X consists of independent, identically distributed samples. For N = 1, + * V is normalized by 1. + *

    + * V = var(X,unbiased=false) normalizes by N and produces the second moment of the sample about its mean. + * + *

    Reference: + *
    + * Algorithms for calculating variance, Wikipedia.org + *
    + * Incremental calculation of weighted mean and variance, Tony Finch + * @param data the data sequence. + * @param unbiased set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N). + * @return the variance in the data. + */ + public static float[] var(float[][] data, boolean unbiased) { + int numColumns = data[0].length; + float[] variances = new float[numColumns]; + float[] dataEach = new float[data.length]; + for(int i=0; inot been normalized + * by the size. + *

    + * formula: var(data) = (Sum.squares(data) - mean(data)^2) / size + */ + protected static float varianceNotNormalized(float[] data){ + float size = data.length; + float mean = data[0]; + float varianceSum = 0; + for(int i = 1; i < size; ++i) { + float stepSum = data[i]-mean; // deviation of data from previous mean + mean += stepSum/(i+1); // mean_at_step_k = mean_at_step_k-1 + (data[k] - mean_at_step_k-1) / k + varianceSum+=stepSum*(data[i]-mean); + } + return varianceSum; + } + + + /** + * Contains methods related to weighted datasets. + */ + public static class Weighted{ + protected Weighted(){} + /** + * Returns the weighted mean of a data sequence. Used when the values in a set of + * data do not share equal importance. + * That is Sum (data[i] * weights[i]) / Sum ( weights[i] ). + */ + public static float mean(float[] data, float[] weights) { + int size = data.length; + Check.equalLengths(size,weights); + float sum = 0.0f; + float weightsSum = 0.0f; + for (int i=size; --i >= 0; ) { + sum += data[i] * weights[i]; + weightsSum += weights[i]; + } + return sum/weightsSum; + } + /** + * Returns the weighted RMS (Root-Mean-Square) of a data sequence. + * That is Sum( data[i] * data[i] * weights[i]) / Sum( data[i] * weights[i] ), + * or in other words sumOfProducts / sumOfSquaredProducts. + * + * @param sumOfProducts == Sum( data[i] * weights[i] ). + * @param sumOfSquaredProducts == Sum( data[i] * data[i] * weights[i] ). + */ + public static float rms(float sumOfProducts, float sumOfSquaredProducts) { + return sumOfProducts / sumOfSquaredProducts; + } + + + /** + * Returns the weighted variance of a data sequence of length N + * There are (unfortunately) many different definitions of the unbiased weighted variance. + * Here, we use the following formula + *

    +		 * weighted.var(x,w,unbiased=true) = biasCorrection * Sum ( w[i] * (x[i] - mu_w)^2  ) / Sum(w[i]).
    +		 * 
    + * where mu_w corresponds to the weighted mean and the biasCorrection + * term + *
    +		 * biasCorrection = ( Sum(w[i]) )^2  / ( ( Sum(w[i]) )^2 - Sum( w[i]^2 )  ).
    +		 * 
    + * corrects for the bias in the variance. + * weighted.var(x,w,unbiased=false) computes the biased weighted variance and is given by the formula above, + * but without the correction factor. + * + *

    The formula above agrees with that presented in + * + * the NIST Information Technology Laboratory page. + * The algorithm used, is a one-pass formula credited to + * "D. H. D. West (1979). Communications of the ACM, 22, 9, 532-535: + * Updating Mean and Variance Estimates: An Improved Method", and spelled out under the + *
    + * weighted incremental algorithm section of the link. + * + * @param unbiased set to true to return the unbiased variance (division by (N-1)), false to return the biased value (division by N). + * @return the weighted variance. + */ + public static float var(float[] data, float[] weights, boolean unbiased) { + int size = data.length; + Check.equalLengths(size,weights); + if(size==1) return 0; + float weightSum = weights[0]; // Sum of weights from 0 to i + float varianceSum = 0; + float mean = data[0]; + float weightSumSquared = weights[0]*weights[0]; + + /** at step i: + mean= meanOld +weights[i]/weightSum * (data[i] - meanOld) + S[i]+= weights[i]*(data[i] - meanOld)*(data[i] - mean) + */ + for(int i=1; i(x-mean)/standardDeviation + */ + public static float zScore(float x, float mean, float standardDeviation){ + return (x-mean)/standardDeviation; + } + + /** + * Returns the array of z-scores for a given data array. + * with each elment given by + * z[i] = ( x[i] - mean ) / standardDeviation. + * @return the standardized array, z + */ + public static float[] zScore(float[] x, float mean, float standardDeviation){ + float[] z = new float[x.length]; + for(int i=0; ij, of the output is given by + * Z[i][j] = ( X[i][j]- mean(X[,j]) / standardDeviation(X[,j]) + * where mean(X[,j]) is the mean value of column j of X. + */ + public static float[][] zScore(float[][] X, float[] means, float[] standardDeviations){ + int numRows = X.length; int numColumns = X[0].length; + float[][] z = new float[numRows][numColumns]; + Check.equalLengths(numColumns,means); + Check.equalLengths(numColumns,standardDeviations); + for(int i=0; i + * For an m-by-n input matrix with m observations and n variables, the output D is + * the symmetric m-by-m matrix with zeros along the diagonals and element ij + * specifying the distance between rows i and j. + * + */ +public final class Distance { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Distance(){ + + } + + /** + * Computes the cityblock (or Manhattan) distance matrix between pairs of objects + * in the m-by-n data matrix X. That is, + *

    +	 * Dist[i][j] = (X[i][1] - X[j][1]) + (X[i][2] - X[j][2]) + ... + (X[i][n] - X[j][n]). 
    +	 * 
    + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the cityblock + * (or manhattan) distance between the rows of the input X. + */ + public static float[][] cityblock(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + double val = 0.0; + for(int r = 0; r + * Dist[i][j] =Max( |X[i][1] - X[j][1]| , |X[i][2] - X[j][2]| , ... , |(X[i][n] - X[j][n]|). + *

    + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the Chebychev + * distance between the rows of the input X. + */ + public static float[][] chebychev(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + double val = 0.0; + for(int r = 0; r + * Dist[1][2] = 1 - sum_{j=1^numColumns} ( ( y1_j - mean(y1) ) * ( y2_j - mean(y2) ) / ( n * std(y1)*std(y2) ) ), + *

    + * where n = number of columns. + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the correlation + * distance between the rows of the input X. + */ + public static float[][] correlation(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + float[] mean = new float[numRows]; float[] std = new float[numRows]; + for(int i=0; i + * Dist[1][2] = 1- sum_{j=1^numColumns} ( y1_j * y2_j ) / ( mag(y1)*mag(y2) ), + * + * where mag(y1) = sum_{i=1 to numColumns} (y1[j]*y1[j]) and likewise + * for mag(y2). + * etc. + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the cosine + * distance between the rows of the input X. + */ + public static float[][] cosine(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + float[] mag = new float[numRows]; + for(int i=0; i + * Dist[i][j]^2 = (X[i][1] - X[j][1]) ^2+ (X[i][2] - X[j][2])^2 + ... + (X[i][n] - X[j][n])^2. + * + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the Euclidean + * distance between the rows of the input X. + */ + public static float[][] euclidean(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + double val = 0.0; + for(int r = 0; r + * standardized value = (original value - mean)/standard deviation + * + * where the mean and standard deviation correspond to the column mean and std. + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the standardized + * Euclidean distance between the rows of the input X. + */ + public static float[][] seuclidean(float[][] X){ + float[] means = Descriptive.Mean.columnMean(X); + float[] stds = Descriptive.std(X,true);//unbiased + float[][] distMatrix = euclidean(Descriptive.zScore(X,means,stds)); + return distMatrix; + } + /** + * Computes the Mahalanobis distance matrix of the m-by-n input matrix X. That is, + *

    +	 * Dist[i][j]^2 = (X[i][1] - X[j][1])^2/ invcov[1][1] + ... + (X[i][n] - X[j][n])^2/ invcov[n][n]. 
    +	 * 
    + * + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the s + * mahalanobis distance between the rows of the input X. + */ + public static float[][] mahalanobis(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + double[][] invCov = new LU(Correlation.cov(X,true)).solve(Mat.identity(numColumns)); + float[][] distMatrix = new float[numRows][numRows]; + for(int r = 0; r + * Dist[i][j]^p= (X[i][1] - X[j][1])^p/ + (X[i][2] - X[j][2])^p + ... + (X[i][n] - X[j][n])^p. + * + * Notice that for the special case of p = 1, the Minkowski metric + * gives the city block metric, for the special case of p = 2, + * the Minkowski metric gives the Euclidean distance, + * and for the special case of p = &inf;, the Minkowski metric gives the Chebychev distance. + * Also notice that the larger the value of p, the higher the probability of causing overflow + * errors (which are, in turn, highly correlated to headaches and overall feelings of malaise). + * @param exp the Minkowski exponent (positive). + */ + public static float[][] minkowski(float[][] X, int exp){ + if(exp<1) throw new IllegalArgumentException("Exponent has to be a scalar positive value"); + // check if it fits any of these + if(exp==1) return cityblock(X); + if(exp==2) return euclidean(X); + if(exp>100) return chebychev(X); + // otherwise, compute it. + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + for(int r = 0; rr11, r12, ... , r1n + *
    + * and + *
    r21, r22, ... , r2n,
    then + *
    
    +	 * Dist[1][2] = 1 -  sum_{j=1^numColumns} ( ( r1_j - mean(r1) ) * ( r2_j - mean(r2) ) / ( n * std(r1)*std(r2) ) ), 
    +	 * 
    + * and similarly for the remaining rows. + *

    + * Rows of X correspond to observations, and columns correspond to variables. + * Returns the m-by-m matrix D with D[r1][r2] corresponding to the Spearman + * distance between the rows of the input X. + */ + public static float[][] spearman(float[][] X){ + int numRows = X.length; int numColumns = X[0].length; + float[][] distMatrix = new float[numRows][numRows]; + // get the rank for all rows + float[][] rank = new float[numRows][numColumns]; + float mean = (numColumns+1)/2; + double[] std = new double[numRows]; + for(int i=0; i 0 + // additionalArg = varargin{1}; % get exponent from input args + // else + // error('stats:pdist:InvalidExponent',... + // 'The exponent for the Minkowski metric must be positive.'); + // end + // case 'cos' % Cosine + // Xnorm = sqrt(sum(X.^2, 2)); + // if min(Xnorm) <= eps(full(max(Xnorm))) + // error('stats:pdist:InappropriateDistance',... + // ['Some points have small relative magnitudes, making them ', ... + // 'effectively zero.\nEither remove those points, or choose a ', ... + // 'distance other than cosine.'], []); + // end + // X = X ./ Xnorm(:,ones(1,p)); + // additionalArg = []; + // case 'cor' % Correlation + // X = X - repmat(mean(X,2),1,p); + // Xnorm = sqrt(sum(X.^2, 2)); + // if min(Xnorm) <= eps(full(max(Xnorm))) + // error('stats:pdist:InappropriateDistance',... + // ['Some points have small relative standard deviations, making ', ... + // 'them effectively constant.\nEither remove those points, or ', ... + // 'choose a distance other than correlation.'], []); + // end + // X = X ./ Xnorm(:,ones(1,p)); + // additionalArg = []; + // case 'spe' + // X = tiedrank(X')'; % treat rows as a series + // X = X - (p+1)/2; % subtract off the (constant) mean + // Xnorm = sqrt(sum(X.^2, 2)); + // if min(Xnorm) <= eps(full(max(Xnorm))) + // error('stats:pdist:InappropriateDistance',... + // ['Some points have too many ties, making them effectively ', ... + // 'constant.\nEither remove those points, or choose a ', ... + // 'distance other than rank correlation.'], []); + // end + // X = X ./ Xnorm(:,ones(1,p)); + // additionalArg = []; + // otherwise + // additionalArg = []; + // end + + + +} \ No newline at end of file diff --git a/drawing/papaya/src/papaya/Eigenvalue.java b/drawing/papaya/src/papaya/Eigenvalue.java new file mode 100644 index 0000000..ac83507 --- /dev/null +++ b/drawing/papaya/src/papaya/Eigenvalue.java @@ -0,0 +1,991 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +/** Eigenvalues and eigenvectors of a real matrix. +

    + If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is + diagonal and the eigenvector matrix V is orthogonal. + I.e. A = V.times(D.times(V.transpose())) and + V.times(V.transpose()) equals the identity matrix. +

    + If A is not symmetric, then the eigenvalue matrix D is block diagonal + with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, + lambda + i*mu, in 2-by-2 blocks, [lambda, mu; -mu, lambda]. The + columns of V represent the eigenvectors in the sense that A*V = V*D, + i.e. A.times(V) equals V.times(D). The matrix V may be badly + conditioned, or even singular, so the validity of the equation + A = V*D*inverse(V) depends upon V.cond(). +

    +Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +{@link Cast#doubleToFloat(double[][])} if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). + */ + + +public class Eigenvalue { + +/* ------------------------ + Class variables + * ------------------------ */ + + /** Row and column dimension (square matrix). + @serial matrix dimension. + */ + private int n; + + /** Symmetry flag. + @serial internal symmetry flag. + */ + private boolean issymmetric; + + /** Arrays for internal storage of eigenvalues. + @serial internal storage of eigenvalues. + */ + private double[] d, e; + + /** Array for internal storage of eigenvectors. + @serial internal storage of eigenvectors. + */ + private double[][] V; + + /** Array for internal storage of nonsymmetric Hessenberg form. + @serial internal storage of nonsymmetric Hessenberg form. + */ + private double[][] H; + + /** Working storage for nonsymmetric algorithm. + @serial working storage for nonsymmetric algorithm. + */ + private double[] ort; + +/* ------------------------ + Private Methods + * ------------------------ */ + + // Symmetric Householder reduction to tridiagonal form. + + private void tred2 () { + + // This is derived from the Algol procedures tred2 by + // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for + // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. + + for (int j = 0; j < n; j++) { + d[j] = V[n-1][j]; + } + + // Householder reduction to tridiagonal form. + + for (int i = n-1; i > 0; i--) { + + // Scale to avoid under/overflow. + + double scale = 0.0; + double h = 0.0; + for (int k = 0; k < i; k++) { + scale = scale + Math.abs(d[k]); + } + if (scale == 0.0) { + e[i] = d[i-1]; + for (int j = 0; j < i; j++) { + d[j] = V[i-1][j]; + V[i][j] = 0.0; + V[j][i] = 0.0; + } + } else { + + // Generate Householder vector. + + for (int k = 0; k < i; k++) { + d[k] /= scale; + h += d[k] * d[k]; + } + double f = d[i-1]; + double g = Math.sqrt(h); + if (f > 0) { + g = -g; + } + e[i] = scale * g; + h = h - f * g; + d[i-1] = f - g; + for (int j = 0; j < i; j++) { + e[j] = 0.0; + } + + // Apply similarity transformation to remaining columns. + + for (int j = 0; j < i; j++) { + f = d[j]; + V[j][i] = f; + g = e[j] + V[j][j] * f; + for (int k = j+1; k <= i-1; k++) { + g += V[k][j] * d[k]; + e[k] += V[k][j] * f; + } + e[j] = g; + } + f = 0.0; + for (int j = 0; j < i; j++) { + e[j] /= h; + f += e[j] * d[j]; + } + double hh = f / (h + h); + for (int j = 0; j < i; j++) { + e[j] -= hh * d[j]; + } + for (int j = 0; j < i; j++) { + f = d[j]; + g = e[j]; + for (int k = j; k <= i-1; k++) { + V[k][j] -= (f * e[k] + g * d[k]); + } + d[j] = V[i-1][j]; + V[i][j] = 0.0; + } + } + d[i] = h; + } + + // Accumulate transformations. + + for (int i = 0; i < n-1; i++) { + V[n-1][i] = V[i][i]; + V[i][i] = 1.0; + double h = d[i+1]; + if (h != 0.0) { + for (int k = 0; k <= i; k++) { + d[k] = V[k][i+1] / h; + } + for (int j = 0; j <= i; j++) { + double g = 0.0; + for (int k = 0; k <= i; k++) { + g += V[k][i+1] * V[k][j]; + } + for (int k = 0; k <= i; k++) { + V[k][j] -= g * d[k]; + } + } + } + for (int k = 0; k <= i; k++) { + V[k][i+1] = 0.0; + } + } + for (int j = 0; j < n; j++) { + d[j] = V[n-1][j]; + V[n-1][j] = 0.0; + } + V[n-1][n-1] = 1.0; + e[0] = 0.0; + } + + // Symmetric tridiagonal QL algorithm. + + private void tql2 () { + + // This is derived from the Algol procedures tql2, by + // Bowdler, Martin, Reinsch, and Wilkinson, Handbook for + // Auto. Comp., Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. + + for (int i = 1; i < n; i++) { + e[i-1] = e[i]; + } + e[n-1] = 0.0; + + double f = 0.0; + double tst1 = 0.0; + double eps = Math.pow(2.0,-52.0); + for (int l = 0; l < n; l++) { + + // Find small subdiagonal element + + tst1 = Math.max(tst1,Math.abs(d[l]) + Math.abs(e[l])); + int m = l; + while (m < n) { + if (Math.abs(e[m]) <= eps*tst1) { + break; + } + m++; + } + + // If m == l, d[l] is an eigenvalue, + // otherwise, iterate. + + if (m > l) { + int iter = 0; + do { + iter = iter + 1; // (Could check iteration count here.) + + // Compute implicit shift + + double g = d[l]; + double p = (d[l+1] - g) / (2.0 * e[l]); + double r = SVD.hypot(p,1.0); + if (p < 0) { + r = -r; + } + d[l] = e[l] / (p + r); + d[l+1] = e[l] * (p + r); + double dl1 = d[l+1]; + double h = g - d[l]; + for (int i = l+2; i < n; i++) { + d[i] -= h; + } + f = f + h; + + // Implicit QL transformation. + + p = d[m]; + double c = 1.0; + double c2 = c; + double c3 = c; + double el1 = e[l+1]; + double s = 0.0; + double s2 = 0.0; + for (int i = m-1; i >= l; i--) { + c3 = c2; + c2 = c; + s2 = s; + g = c * e[i]; + h = c * p; + r = SVD.hypot(p,e[i]); + e[i+1] = s * r; + s = e[i] / r; + c = p / r; + p = c * d[i] - s * g; + d[i+1] = h + s * (c * g + s * d[i]); + + // Accumulate transformation. + + for (int k = 0; k < n; k++) { + h = V[k][i+1]; + V[k][i+1] = s * V[k][i] + c * h; + V[k][i] = c * V[k][i] - s * h; + } + } + p = -s * s2 * c3 * el1 * e[l] / dl1; + e[l] = s * p; + d[l] = c * p; + + // Check for convergence. + + } while (Math.abs(e[l]) > eps*tst1); + } + d[l] = d[l] + f; + e[l] = 0.0; + } + + // Sort eigenvalues and corresponding vectors. + + for (int i = 0; i < n-1; i++) { + int k = i; + double p = d[i]; + for (int j = i+1; j < n; j++) { + if (d[j] < p) { + k = j; + p = d[j]; + } + } + if (k != i) { + d[k] = d[i]; + d[i] = p; + for (int j = 0; j < n; j++) { + p = V[j][i]; + V[j][i] = V[j][k]; + V[j][k] = p; + } + } + } + } + + // Nonsymmetric reduction to Hessenberg form. + + private void orthes () { + + // This is derived from the Algol procedures orthes and ortran, + // by Martin and Wilkinson, Handbook for Auto. Comp., + // Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutines in EISPACK. + + int low = 0; + int high = n-1; + + for (int m = low+1; m <= high-1; m++) { + + // Scale column. + + double scale = 0.0; + for (int i = m; i <= high; i++) { + scale = scale + Math.abs(H[i][m-1]); + } + if (scale != 0.0) { + + // Compute Householder transformation. + + double h = 0.0; + for (int i = high; i >= m; i--) { + ort[i] = H[i][m-1]/scale; + h += ort[i] * ort[i]; + } + double g = Math.sqrt(h); + if (ort[m] > 0) { + g = -g; + } + h = h - ort[m] * g; + ort[m] = ort[m] - g; + + // Apply Householder similarity transformation + // H = (I-u*u'/h)*H*(I-u*u')/h) + + for (int j = m; j < n; j++) { + double f = 0.0; + for (int i = high; i >= m; i--) { + f += ort[i]*H[i][j]; + } + f = f/h; + for (int i = m; i <= high; i++) { + H[i][j] -= f*ort[i]; + } + } + + for (int i = 0; i <= high; i++) { + double f = 0.0; + for (int j = high; j >= m; j--) { + f += ort[j]*H[i][j]; + } + f = f/h; + for (int j = m; j <= high; j++) { + H[i][j] -= f*ort[j]; + } + } + ort[m] = scale*ort[m]; + H[m][m-1] = scale*g; + } + } + + // Accumulate transformations (Algol's ortran). + + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + V[i][j] = (i == j ? 1.0 : 0.0); + } + } + + for (int m = high-1; m >= low+1; m--) { + if (H[m][m-1] != 0.0) { + for (int i = m+1; i <= high; i++) { + ort[i] = H[i][m-1]; + } + for (int j = m; j <= high; j++) { + double g = 0.0; + for (int i = m; i <= high; i++) { + g += ort[i] * V[i][j]; + } + // Double division avoids possible underflow + g = (g / ort[m]) / H[m][m-1]; + for (int i = m; i <= high; i++) { + V[i][j] += g * ort[i]; + } + } + } + } + } + + + // Complex scalar division. + + private transient double cdivr, cdivi; + private void cdiv(double xr, double xi, double yr, double yi) { + double r,d; + if (Math.abs(yr) > Math.abs(yi)) { + r = yi/yr; + d = yr + r*yi; + cdivr = (xr + r*xi)/d; + cdivi = (xi - r*xr)/d; + } else { + r = yr/yi; + d = yi + r*yr; + cdivr = (r*xr + xi)/d; + cdivi = (r*xi - xr)/d; + } + } + + + // Nonsymmetric reduction from Hessenberg to real Schur form. + + private void hqr2 () { + + // This is derived from the Algol procedure hqr2, + // by Martin and Wilkinson, Handbook for Auto. Comp., + // Vol.ii-Linear Algebra, and the corresponding + // Fortran subroutine in EISPACK. + + // Initialize + + int nn = this.n; + int n = nn-1; + int low = 0; + int high = nn-1; + double eps = Math.pow(2.0,-52.0); + double exshift = 0.0; + double p=0,q=0,r=0,s=0,z=0,t,w,x,y; + + // Store roots isolated by balanc and compute matrix norm + + double norm = 0.0; + for (int i = 0; i < nn; i++) { + if (i < low | i > high) { + d[i] = H[i][i]; + e[i] = 0.0; + } + for (int j = Math.max(i-1,0); j < nn; j++) { + norm = norm + Math.abs(H[i][j]); + } + } + + // Outer loop over eigenvalue index + + int iter = 0; + while (n >= low) { + + // Look for single small sub-diagonal element + + int l = n; + while (l > low) { + s = Math.abs(H[l-1][l-1]) + Math.abs(H[l][l]); + if (s == 0.0) { + s = norm; + } + if (Math.abs(H[l][l-1]) < eps * s) { + break; + } + l--; + } + + // Check for convergence + // One root found + + if (l == n) { + H[n][n] = H[n][n] + exshift; + d[n] = H[n][n]; + e[n] = 0.0; + n--; + iter = 0; + + // Two roots found + + } else if (l == n-1) { + w = H[n][n-1] * H[n-1][n]; + p = (H[n-1][n-1] - H[n][n]) / 2.0; + q = p * p + w; + z = Math.sqrt(Math.abs(q)); + H[n][n] = H[n][n] + exshift; + H[n-1][n-1] = H[n-1][n-1] + exshift; + x = H[n][n]; + + // Real pair + + if (q >= 0) { + if (p >= 0) { + z = p + z; + } else { + z = p - z; + } + d[n-1] = x + z; + d[n] = d[n-1]; + if (z != 0.0) { + d[n] = x - w / z; + } + e[n-1] = 0.0; + e[n] = 0.0; + x = H[n][n-1]; + s = Math.abs(x) + Math.abs(z); + p = x / s; + q = z / s; + r = Math.sqrt(p * p+q * q); + p = p / r; + q = q / r; + + // Row modification + + for (int j = n-1; j < nn; j++) { + z = H[n-1][j]; + H[n-1][j] = q * z + p * H[n][j]; + H[n][j] = q * H[n][j] - p * z; + } + + // Column modification + + for (int i = 0; i <= n; i++) { + z = H[i][n-1]; + H[i][n-1] = q * z + p * H[i][n]; + H[i][n] = q * H[i][n] - p * z; + } + + // Accumulate transformations + + for (int i = low; i <= high; i++) { + z = V[i][n-1]; + V[i][n-1] = q * z + p * V[i][n]; + V[i][n] = q * V[i][n] - p * z; + } + + // Complex pair + + } else { + d[n-1] = x + p; + d[n] = x + p; + e[n-1] = z; + e[n] = -z; + } + n = n - 2; + iter = 0; + + // No convergence yet + + } else { + + // Form shift + + x = H[n][n]; + y = 0.0; + w = 0.0; + if (l < n) { + y = H[n-1][n-1]; + w = H[n][n-1] * H[n-1][n]; + } + + // Wilkinson's original ad hoc shift + + if (iter == 10) { + exshift += x; + for (int i = low; i <= n; i++) { + H[i][i] -= x; + } + s = Math.abs(H[n][n-1]) + Math.abs(H[n-1][n-2]); + x = y = 0.75 * s; + w = -0.4375 * s * s; + } + + // MATLAB's new ad hoc shift + + if (iter == 30) { + s = (y - x) / 2.0; + s = s * s + w; + if (s > 0) { + s = Math.sqrt(s); + if (y < x) { + s = -s; + } + s = x - w / ((y - x) / 2.0 + s); + for (int i = low; i <= n; i++) { + H[i][i] -= s; + } + exshift += s; + x = y = w = 0.964; + } + } + + iter = iter + 1; // (Could check iteration count here.) + + // Look for two consecutive small sub-diagonal elements + + int m = n-2; + while (m >= l) { + z = H[m][m]; + r = x - z; + s = y - z; + p = (r * s - w) / H[m+1][m] + H[m][m+1]; + q = H[m+1][m+1] - z - r - s; + r = H[m+2][m+1]; + s = Math.abs(p) + Math.abs(q) + Math.abs(r); + p = p / s; + q = q / s; + r = r / s; + if (m == l) { + break; + } + if (Math.abs(H[m][m-1]) * (Math.abs(q) + Math.abs(r)) < + eps * (Math.abs(p) * (Math.abs(H[m-1][m-1]) + Math.abs(z) + + Math.abs(H[m+1][m+1])))) { + break; + } + m--; + } + + for (int i = m+2; i <= n; i++) { + H[i][i-2] = 0.0; + if (i > m+2) { + H[i][i-3] = 0.0; + } + } + + // Double QR step involving rows l:n and columns m:n + + for (int k = m; k <= n-1; k++) { + boolean notlast = (k != n-1); + if (k != m) { + p = H[k][k-1]; + q = H[k+1][k-1]; + r = (notlast ? H[k+2][k-1] : 0.0); + x = Math.abs(p) + Math.abs(q) + Math.abs(r); + if (x != 0.0) { + p = p / x; + q = q / x; + r = r / x; + } + } + if (x == 0.0) { + break; + } + s = Math.sqrt(p * p + q * q + r * r); + if (p < 0) { + s = -s; + } + if (s != 0) { + if (k != m) { + H[k][k-1] = -s * x; + } else if (l != m) { + H[k][k-1] = -H[k][k-1]; + } + p = p + s; + x = p / s; + y = q / s; + z = r / s; + q = q / p; + r = r / p; + + // Row modification + + for (int j = k; j < nn; j++) { + p = H[k][j] + q * H[k+1][j]; + if (notlast) { + p = p + r * H[k+2][j]; + H[k+2][j] = H[k+2][j] - p * z; + } + H[k][j] = H[k][j] - p * x; + H[k+1][j] = H[k+1][j] - p * y; + } + + // Column modification + + for (int i = 0; i <= Math.min(n,k+3); i++) { + p = x * H[i][k] + y * H[i][k+1]; + if (notlast) { + p = p + z * H[i][k+2]; + H[i][k+2] = H[i][k+2] - p * r; + } + H[i][k] = H[i][k] - p; + H[i][k+1] = H[i][k+1] - p * q; + } + + // Accumulate transformations + + for (int i = low; i <= high; i++) { + p = x * V[i][k] + y * V[i][k+1]; + if (notlast) { + p = p + z * V[i][k+2]; + V[i][k+2] = V[i][k+2] - p * r; + } + V[i][k] = V[i][k] - p; + V[i][k+1] = V[i][k+1] - p * q; + } + } // (s != 0) + } // k loop + } // check convergence + } // while (n >= low) + + // Backsubstitute to find vectors of upper triangular form + + if (norm == 0.0) { + return; + } + + for (n = nn-1; n >= 0; n--) { + p = d[n]; + q = e[n]; + + // Real vector + + if (q == 0) { + int l = n; + H[n][n] = 1.0; + for (int i = n-1; i >= 0; i--) { + w = H[i][i] - p; + r = 0.0; + for (int j = l; j <= n; j++) { + r = r + H[i][j] * H[j][n]; + } + if (e[i] < 0.0) { + z = w; + s = r; + } else { + l = i; + if (e[i] == 0.0) { + if (w != 0.0) { + H[i][n] = -r / w; + } else { + H[i][n] = -r / (eps * norm); + } + + // Solve real equations + + } else { + x = H[i][i+1]; + y = H[i+1][i]; + q = (d[i] - p) * (d[i] - p) + e[i] * e[i]; + t = (x * s - z * r) / q; + H[i][n] = t; + if (Math.abs(x) > Math.abs(z)) { + H[i+1][n] = (-r - w * t) / x; + } else { + H[i+1][n] = (-s - y * t) / z; + } + } + + // Overflow control + + t = Math.abs(H[i][n]); + if ((eps * t) * t > 1) { + for (int j = i; j <= n; j++) { + H[j][n] = H[j][n] / t; + } + } + } + } + + // Complex vector + + } else if (q < 0) { + int l = n-1; + + // Last vector component imaginary so matrix is triangular + + if (Math.abs(H[n][n-1]) > Math.abs(H[n-1][n])) { + H[n-1][n-1] = q / H[n][n-1]; + H[n-1][n] = -(H[n][n] - p) / H[n][n-1]; + } else { + cdiv(0.0,-H[n-1][n],H[n-1][n-1]-p,q); + H[n-1][n-1] = cdivr; + H[n-1][n] = cdivi; + } + H[n][n-1] = 0.0; + H[n][n] = 1.0; + for (int i = n-2; i >= 0; i--) { + double ra,sa,vr,vi; + ra = 0.0; + sa = 0.0; + for (int j = l; j <= n; j++) { + ra = ra + H[i][j] * H[j][n-1]; + sa = sa + H[i][j] * H[j][n]; + } + w = H[i][i] - p; + + if (e[i] < 0.0) { + z = w; + r = ra; + s = sa; + } else { + l = i; + if (e[i] == 0) { + cdiv(-ra,-sa,w,q); + H[i][n-1] = cdivr; + H[i][n] = cdivi; + } else { + + // Solve complex equations + + x = H[i][i+1]; + y = H[i+1][i]; + vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q; + vi = (d[i] - p) * 2.0 * q; + if (vr == 0.0 & vi == 0.0) { + vr = eps * norm * (Math.abs(w) + Math.abs(q) + + Math.abs(x) + Math.abs(y) + Math.abs(z)); + } + cdiv(x*r-z*ra+q*sa,x*s-z*sa-q*ra,vr,vi); + H[i][n-1] = cdivr; + H[i][n] = cdivi; + if (Math.abs(x) > (Math.abs(z) + Math.abs(q))) { + H[i+1][n-1] = (-ra - w * H[i][n-1] + q * H[i][n]) / x; + H[i+1][n] = (-sa - w * H[i][n] - q * H[i][n-1]) / x; + } else { + cdiv(-r-y*H[i][n-1],-s-y*H[i][n],z,q); + H[i+1][n-1] = cdivr; + H[i+1][n] = cdivi; + } + } + + // Overflow control + + t = Math.max(Math.abs(H[i][n-1]),Math.abs(H[i][n])); + if ((eps * t) * t > 1) { + for (int j = i; j <= n; j++) { + H[j][n-1] = H[j][n-1] / t; + H[j][n] = H[j][n] / t; + } + } + } + } + } + } + + // Vectors of isolated roots + + for (int i = 0; i < nn; i++) { + if (i < low | i > high) { + for (int j = i; j < nn; j++) { + V[i][j] = H[i][j]; + } + } + } + + // Back transformation to get eigenvectors of original matrix + + for (int j = nn-1; j >= low; j--) { + for (int i = low; i <= high; i++) { + z = 0.0; + for (int k = low; k <= Math.min(j,high); k++) { + z = z + V[i][k] * H[k][j]; + } + V[i][j] = z; + } + } + } + + +/* ------------------------ + Constructor + * ------------------------ */ + + /** Check for symmetry, then construct the eigenvalue decomposition. + * Upon initialization, the matrices D and V, as well as the vectors containing the + * real and imaginary eigenvalues are computed and stored. + * @see getV() + * @see getD() + * @see getRealEigenvalues() + * @see getImagEigenvalues() + */ + + public Eigenvalue (float[][] Arg) { + double[][] A = Cast.floatToDouble(Arg); + n = Arg[0].length; + V = new double[n][n]; + d = new double[n]; + e = new double[n]; + + issymmetric = true; + for (int j = 0; (j < n) & issymmetric; j++) { + for (int i = 0; (i < n) & issymmetric; i++) { + issymmetric = (A[i][j] == A[j][i]); + } + } + + if (issymmetric) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + V[i][j] = A[i][j]; + } + } + + // Tridiagonalize. + tred2(); + + // Diagonalize. + tql2(); + + } else { + H = new double[n][n]; + ort = new double[n]; + + for (int j = 0; j < n; j++) { + for (int i = 0; i < n; i++) { + H[i][j] = A[i][j]; + } + } + + // Reduce to Hessenberg form. + orthes(); + + // Reduce Hessenberg to real Schur form. + hqr2(); + } + } + +/* ------------------------ + Public Methods + * ------------------------ */ + + /** Return the eigenvector matrix with each column corresponding to + * an eigenvector of the input matrix. + @return V + */ + + public double[][] getV () { + return V; + } + + /** Return the real parts of the eigenvalues + @return real(diag(D)) + */ + public double[] getRealEigenvalues () { + return d; + } + + /** Return the imaginary parts of the eigenvalues + @return imag(diag(D)) + */ + + public double[] getImagEigenvalues () { + return e; + } + + /** Return the block diagonal eigenvalue matrix + @return D + */ + + public double[][] getD () { + double[][] D = new double[n][n]; + for (int i = 0; i < n; i++) { + D[i][i] = d[i]; + if (e[i] > 0) { + D[i][i+1] = e[i]; + } else if (e[i] < 0) { + D[i][i-1] = e[i]; + } + } + return D; + } +} + + + + + diff --git a/drawing/papaya/src/papaya/Find.java b/drawing/papaya/src/papaya/Find.java new file mode 100644 index 0000000..d3eee6d --- /dev/null +++ b/drawing/papaya/src/papaya/Find.java @@ -0,0 +1,1945 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ + +package papaya; + +import java.util.*; +import java.io.*; +import processing.core.*; + +/** + * Static class for finding indices in an array corresponding to a given value/object. + *

    + * (Portions of this code were (conveniently!) copied and pasted from commons.apache.org.) :) + *

    + * + */ +public final class Find implements PapayaConstants { + +// /** +// * Index to return if not found. +// */ +// public static final int INDEX_NOT_FOUND = -1; +// +// /** +// * Index array to return if not found. +// */ +// public static final int[] INDICES_NOT_FOUND = new int[]{-1}; + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Find(){ + } + + // IndexOf search + // ---------------------------------------------------------------------- + + // Object IndexOf + //----------------------------------------------------------------------- + /** + *

    Finds the index of the given object in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param objectToFind the object to find, may be {@code null} + * @return the index of the object within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(Object[] array, Object objectToFind) { + return indexOf(array, objectToFind, 0); + } + + /** + *

    Finds the index of the given object in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param objectToFind the object to find, may be {@code null} + * @param startIndex the index to start searching at + * @return the index of the object within the array starting at the index, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(Object[] array, Object objectToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + if (objectToFind == null) { + for (int i = startIndex; i < array.length; i++) { + if (array[i] == null) { + return i; + } + } + } else if (array.getClass().getComponentType().isInstance(objectToFind)) { + for (int i = startIndex; i < array.length; i++) { + if (objectToFind.equals(array[i])) { + return i; + } + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given object within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param objectToFind the object to find, may be {@code null} + * @return the last index of the object within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(Object[] array, Object objectToFind) { + return lastIndexOf(array, objectToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given object in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than + * the array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param objectToFind the object to find, may be {@code null} + * @param startIndex the start index to travers backwards from + * @return the last index of the object within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(Object[] array, Object objectToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + if (objectToFind == null) { + for (int i = startIndex; i >= 0; i--) { + if (array[i] == null) { + return i; + } + } + } else if (array.getClass().getComponentType().isInstance(objectToFind)) { + for (int i = startIndex; i >= 0; i--) { + if (objectToFind.equals(array[i])) { + return i; + } + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the object is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param objectToFind the object to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(Object[] array, Object objectToFind) { + return indexOf(array, objectToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified object in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object to find, may be {@code null} + * @param objectToFind the object to find + * @return the indices containing the object within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(Object[] array, Object objectToFind) { + return indicesWith(array, objectToFind, 0); + } + + /** + *

    Finds the indices containing the specified object in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object to find, may be {@code null} + * @param objectToFind the object to find + * @param startIndex the index to start searching at + * @return the indices containing the object within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(Object[] array, Object objectToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + + if (objectToFind == null) { + for (int i = startIndex; i < array.length; i++) { + if (array[i] == null) { + indices.add(i); + } + } + } else if (array.getClass().getComponentType().isInstance(objectToFind)) { + for (int i = startIndex; i < array.length; i++) { + if (objectToFind.equals(array[i])) { + indices.add(i); + } + } + } + + if(indices.size()>0){ + return Cast.vectorToInt(indices); + } + else{ + return INDICES_NOT_FOUND; + } + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param objectToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(Object[] array, Object objectToFind) { + int count=0; + if (objectToFind == null) { + for (int i = 0; i < array.length; i++) { + if (array[i] == null) { + count++; + } + } + } else if (array.getClass().getComponentType().isInstance(objectToFind)) { + for (int i = 0; i < array.length; i++) { + if (objectToFind.equals(array[i])) { + count++; + } + } + } + return count; + } + + + // long IndexOf + //----------------------------------------------------------------------- + /** + *

    Finds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(long[] array, long valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(long[] array, long valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(long[] array, long valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(long[] array, long valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(long[] array, long valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(long[] array, long valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(long[] array, long valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(long[] array, long valueToFind) { + int count=0; + for (int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(int[] array, int valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(int[] array, int valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(int[] array, int valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(int[] array, int valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(int[] array, int valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(int[] array, int valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(int[] array, int valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + /** + *

    Finds the indices for the array elements within the min and max value (inclusive).

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + */ + public static int[] indicesWithin(int[] array, float minVal, float maxVal) { + if (array == null) { + return INDICES_NOT_FOUND; + } + Vector indices = new Vector(); + for (int i = 0; i < array.length; i++) { + if (array[i] >= minVal && array[i]<= maxVal) { + indices.add(i); + } + } + return checkIndices(indices); + } + + public static int[] indicesLessThanOrEqualTo(int[] array, int valueOfMax){ + ArrayList indices = new ArrayList(); + for(int i=0; i=valueOfMin) indices.add(i); + } + return Cast.arrayListToInt(indices); + } + + public static int[] indicesGreaterThan(int[] array, int valueOfMin){ + ArrayList indices = new ArrayList(); + for(int i=0; ivalueOfMin) indices.add(i); + } + return Cast.arrayListToInt(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(int[] array, int valueToFind) { + int count=0; + for (int i=0; iFinds the number of elements less than or equal to the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements ? that value + */ + public static int numLessThanOrEqualTo(int[] array, int valueOfMax) { + int count=0; + for (int i=0; iFinds the number of elements strictly less than the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements strictly less than that value + */ + public static int numLessThan(int[] array, int valueOfMax) { + int count=0; + for (int i=0; iFinds the number of elements greater than or equal to the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements ? that value + */ + public static int numGreaterThanOrEqualTo(int[] array, int valueOfMin) { + int count=0; + for (int i=0; i= valueOfMin) { + count++; + } + } + return count; + } + + /** + *

    Finds the number of elements strictly greater than the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements strictly greater than that value + */ + public static int numGreaterThan(int[] array, int valueOfMin) { + int count=0; + for (int i=0; i valueOfMin) { + count++; + } + } + return count; + } + + /** Find the unique elements in a int array (uses HashSets) */ + public static int[] uniqueElems(int[] array){ + Set uniqueVals = new HashSet(); + for(int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(short[] array, short valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(short[] array, short valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(short[] array, short valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(short[] array, short valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(short[] array, short valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(short[] array, short valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(short[] array, short valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(short[] array, short valueToFind) { + int count=0; + for (int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + * @since 2.1 + */ + public static int indexOf(char[] array, char valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + * @since 2.1 + */ + public static int indexOf(char[] array, char valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + * @since 2.1 + */ + public static int lastIndexOf(char[] array, char valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + * @since 2.1 + */ + public static int lastIndexOf(char[] array, char valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + * @since 2.1 + */ + public static boolean contains(char[] array, char valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(char[] array, char valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(char[] array, char valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(char[] array,char valueToFind) { + int count=0; + for (int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(byte[] array, byte valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(byte[] array, byte valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(byte[] array, byte valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(byte[] array, byte valueToFind, int startIndex) { + if (array == null) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(byte[] array, byte valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(byte[] array, byte valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(byte[] array, byte valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(byte[] array, byte valueToFind) { + int count=0; + for (int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(double[] array, double valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value within a given tolerance in the array. + * This method will return the index of the first value which falls between the region + * defined by valueToFind - tolerance and valueToFind + tolerance.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param tolerance tolerance of the search + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(double[] array, double valueToFind, double tolerance) { + return indexOf(array, valueToFind, 0, tolerance); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(double[] array, double valueToFind, int startIndex) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the index of the given value in the array starting at the given index. + * This method will return the index of the first value which falls between the region + * defined by valueToFind - tolerance and valueToFind + tolerance.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @param tolerance tolerance of the search + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(double[] array, double valueToFind, int startIndex, double tolerance) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + double min = valueToFind - tolerance; + double max = valueToFind + tolerance; + for (int i = startIndex; i < array.length; i++) { + if (array[i] >= min && array[i] <= max) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(double[] array, double valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value within a given tolerance in the array. + * This method will return the index of the last value which falls between the region + * defined by valueToFind - tolerance and valueToFind + tolerance.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param tolerance tolerance of the search + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(double[] array, double valueToFind, double tolerance) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE, tolerance); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(double[] array, double valueToFind, int startIndex) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value in the array starting at the given index. + * This method will return the index of the last value which falls between the region + * defined by valueToFind - tolerance and valueToFind + tolerance.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @param tolerance search for value within plus/minus this amount + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(double[] array, double valueToFind, int startIndex, double tolerance) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + double min = valueToFind - tolerance; + double max = valueToFind + tolerance; + for (int i = startIndex; i >= 0; i--) { + if (array[i] >= min && array[i] <= max) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(double[] array, double valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Checks if a value falling within the given tolerance is in the + * given array. If the array contains a value within the inclusive range + * defined by (value - tolerance) to (value + tolerance).

    + * + *

    The method returns {@code false} if a {@code null} array + * is passed in.

    + * + * @param array the array to search + * @param valueToFind the value to find + * @param tolerance the array contains the tolerance of the search + * @return true if value falling within tolerance is in array + */ + public static boolean contains(double[] array, double valueToFind, double tolerance) { + return indexOf(array, valueToFind, 0, tolerance) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(double[] array, double valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(double[] array, double valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(double[] array, double valueToFind) { + int count=0; + for (int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(float[] array, float valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(float[] array, float valueToFind, int startIndex) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(float[] array, float valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than the + * array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(float[] array, float valueToFind, int startIndex) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Checks if the value is in the given array.

    + * + *

    The method returns {@code false} if a {@code null} array is passed in.

    + * + * @param array the array to search through + * @param valueToFind the value to find + * @return {@code true} if the array contains the object + */ + public static boolean contains(float[] array, float valueToFind) { + return indexOf(array, valueToFind) != INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(float[] array, float valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(float[] array, float valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the indices for the array elements within the min and max value (inclusive).

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + */ + public static int[] indicesWithin(float[] array, float minVal, float maxVal) { + if (array == null) { + return INDICES_NOT_FOUND; + } + Vector indices = new Vector(); + for (int i = 0; i < array.length; i++) { + if (array[i] >= minVal && array[i]<= maxVal) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(float[] array, float valueToFind) { + int count=0; + for (int i=0; i=valueOfMin) indices.add(i); + } + return Cast.arrayListToInt(indices); + } + + public static int[] indicesGreaterThan(float[] array, float valueOfMin){ + ArrayList indices = new ArrayList(); + for(int i=0; ivalueOfMin) indices.add(i); + } + return Cast.arrayListToInt(indices); + } + + /** + *

    Finds the number of elements less than or equal to the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements ? that value + */ + public static int numLessThanOrEqualTo(float[] array, float valueOfMax) { + int count=0; + for (int i=0; iFinds the number of elements strictly less than the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements strictly less than that value + */ + public static int numLessThan(float[] array, float valueOfMax) { + int count=0; + for (int i=0; iFinds the number of elements greater than or equal to the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements ? that value + */ + public static int numGreaterThanOrEqualTo(float[] array, float valueOfMin) { + int count=0; + for (int i=0; i= valueOfMin) { + count++; + } + } + return count; + } + + /** + *

    Finds the number of elements strictly greater than the specified value.

    + * + * @param array the array to search through for the value/object + * @param valueOfMax the maximum value + * @return the number of elements strictly greater than that value + */ + public static int numGreaterThan(float[] array, float valueOfMin) { + int count=0; + for (int i=0; i valueOfMin) { + count++; + } + } + return count; + } + + /** Find the unique elements in a float array (uses HashSets) */ + public static float[] uniqueElems(float[] array){ + Set uniqueVals = new HashSet(); + for(int i=0; iFinds the index of the given value in the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int indexOf(boolean[] array, boolean valueToFind) { + return indexOf(array, valueToFind, 0); + } + + /** + *

    Finds the index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex is treated as zero. A startIndex larger than the array + * length will return {@link #INDEX_NOT_FOUND} ({@code -1}).

    + * + * @param array the array to search through for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} + * array input + */ + public static int indexOf(boolean[] array, boolean valueToFind, int startIndex) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + for (int i = startIndex; i < array.length; i++) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the last index of the given value within the array.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) if + * {@code null} array input.

    + * + * @param array the array to travers backwords looking for the object, may be {@code null} + * @param valueToFind the object to find + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(boolean[] array, boolean valueToFind) { + return lastIndexOf(array, valueToFind, Integer.MAX_VALUE); + } + + /** + *

    Finds the last index of the given value in the array starting at the given index.

    + * + *

    This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.

    + * + *

    A negative startIndex will return {@link #INDEX_NOT_FOUND} ({@code -1}). A startIndex larger than + * the array length will search from the end of the array.

    + * + * @param array the array to traverse for looking for the object, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the start index to travers backwards from + * @return the last index of the value within the array, + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int lastIndexOf(boolean[] array, boolean valueToFind, int startIndex) { + if (array.length == 0) { + return INDEX_NOT_FOUND; + } + if (startIndex < 0) { + return INDEX_NOT_FOUND; + } else if (startIndex >= array.length) { + startIndex = array.length - 1; + } + for (int i = startIndex; i >= 0; i--) { + if (valueToFind == array[i]) { + return i; + } + } + return INDEX_NOT_FOUND; + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(boolean[] array, boolean valueToFind) { + return indicesWith(array, valueToFind, 0); + } + + /** + *

    Finds the indices containing the specified value in the array.

    + * + *

    This method returns {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) for a {@code null} input array.

    + * + * @param array the array to search through for the value to find, may be {@code null} + * @param valueToFind the value to find + * @param startIndex the index to start searching at + * @return the indices containing the value within the array, + * {@link #INDICES_NOT_FOUND} ({@code int[] = -1}) if not found or {@code null} array input + */ + public static int[] indicesWith(boolean[] array, boolean valueToFind, int startIndex) { + if (array == null) { + return INDICES_NOT_FOUND; + } + if (startIndex < 0) { + startIndex = 0; + } + Vector indices = new Vector(); + for (int i = startIndex; i < array.length; i++) { + if (array[i] == valueToFind) { + indices.add(i); + } + } + return checkIndices(indices); + } + + /** + *

    Finds the number of times a given value/object is present in an array.

    + * + * @param array the array to search through for the value/object + * @param valueToFind the object to find. + * @return the number of times that value/object appears in the array + * {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input + */ + public static int numRepeats(boolean[] array, boolean valueToFind) { + int count=0; + for (int i=0; i0){ + return Cast.vectorToInt(indices); + } + else{ + return INDICES_NOT_FOUND; + } + + } +} + diff --git a/drawing/papaya/src/papaya/Frequency.java b/drawing/papaya/src/papaya/Frequency.java new file mode 100644 index 0000000..c2aa9df --- /dev/null +++ b/drawing/papaya/src/papaya/Frequency.java @@ -0,0 +1,195 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.util.*; +import java.io.*; +import processing.core.*; +import processing.core.PApplet; +import processing.core.PImage; + +/** + * Class for getting the frequency distribution, cumulative frequency distribution, and other + * distribution-related parameters of a given array of floats or ints. + * To initialize, use something like this: + *

    + * Frequency freq= new Frequency(dataArray, minimumVal,maximumVal,widthOfEachBin); + * + * Once initialized, it stores 3 things: + *

      + *
    • The array containing the number of elements in each of the histogram bins ({@link getFrequency()}). + *
    • The number of bins. + *
    • The length of the full data array. + *
    + * + *

    A number of different methods are available for computing other distribution-related parameters + * (e.g. the relative frequency distribution, the cumulative frequency distribution, etc).

    + * + *

    See the FrequencyExample in the examples folder for an example.

    + * + * @author Adila Faruk + */ + +// TO DO: OBJECTS!!!! +public class Frequency{ + + private int numBins = 0; + private int ln = 0; + // stored as a float so that we don't mess things up when dividing! + private float[] frequency; + + /** + * Initialize the class by setting the minimum value, maximum value, and the bin width. + * Upon initialization, the number of bins are determined and the + * frequency distribution array is computed for the given input data and histogram bin width. + * This frequency distribution can be accessed using the {@link getFrequency()} function. + * Note that this is the only place where you can set the frequency distribution. + * + *

    How is the number of bins computed? + *
    Like this: + *
    bins = floor[ (max - min) / binWidth ] +1 ,
    + * as opposed to ceil[ (max - min) / binWidth ]. + * Why? The latter algorithm is problematic when [ (max - min) / binWidth ] + * is a whole number. + * E.g. let min = 0.0, max = 100.0, and binWidth = 10.0. We get 10 bins with + *

      + *
    • 1st bin = bin[0] --> contains elements 0.0 - 9.999... + *
    • 2nd bin = bin[1] --> contains elements 10.0 - 19.999... + *
    • ... + *
    • ... + *
    • 10th bin = bin[9] --> contains elements 90.0-99.999... + *
    + * Poor 100. He's got nowhere to go but into an Array Index out of bound Exception! + *

    + *

    What element goes into what bin? + *
    Let value = data[i]; + *
    value will go into bin number floor( (_inputDat[i]-_minVal)/_binWidth ); + *

    + * + * @param _inputDat the input data + * @param _minVal the minimum value in the array + * @param _maxVal the maximum value in the array + * @param _binWidth the width of each of the bins + */ + public Frequency(float[] _inputDat, float _minVal, float _maxVal, float _binWidth){ + numBins = (int)Math.floor((_maxVal - _minVal)/_binWidth) +1; + frequency = new float[numBins]; + for (int i=0; i<_inputDat.length; i++) { + frequency[(int) Math.floor( (_inputDat[i]-_minVal)/_binWidth ) ]++; + } + ln = _inputDat.length; + } + + /** + * Initialize the class by setting the minimum value, maximum value, and the bin width. + * Upon initialization, the number of bins are determined and the + * frequency distribution array is computed for the given input data and histogram bin width. + * This frequency distribution can be accessed using the {@link getFrequency()} function. + * Note that this is the only place where you can set the frequency distribution. + * + *

    See {@link Frequency(float[] _inputDat, float _minVal, float _maxVal, float _binWidth)} for + * more details. + *

    + */ + public Frequency(int[] _inputDat, int _minVal, int _maxVal, int _binWidth){ + numBins = ( (_maxVal - _minVal)/_binWidth) +1; + frequency = new float[numBins]; + for (int i=0; i<_inputDat.length; i++) { + frequency[ (_inputDat[i]-_minVal)/_binWidth ]++; + } + ln = _inputDat.length; + } + + /** + * Computes the fraction of the total data that's in each bin. + * This is similar to dividing the number in each bin by the total + * number of elements in the data array. + */ + public float[] compRelFrequency() { + return Mat.multiply( frequency, (float)1/ln ); + } + + /** + * Computes the percents of the total data that's in each bin. + * This isimilar to dividing the number in each bin by the total + * number of elements in the data array x 100% + */ + public float[] compRelFrequencyPct() { + return Mat.multiply( frequency, (float)100/ln ); + } + + /** + * Computes the cumulative frequency of the data. + */ + public float[] compCumFrequency() { + float[] cumFreq = new float[frequency.length]; + cumFreq[0] = frequency[0]; + for(int i=1; i + * Implementation: + * The code is mostly adapted from the CERN + * Jet Java libraries, which in turn was adapted from the Cephes Mathematical Library. As far a + * as I can tell, Stephen L. Moshier wrote the original C++ code for CEPHES (1989, moshier@na-net.ornl.gov) + * and Wolfgang Hoschek (at CERN, hats off to you mate!) then adapted it for the + * Java platform, making some significant changes along the way. + *
    + * + */ +//public class Gamma extends cern.jet.math.Constants { +public class Gamma implements PapayaConstants { + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Gamma() {} + /** + * Returns the beta function of the arguments. + *
    +	 * 
    +	 * beta( a, b )  = Γ(a) * Γ(b) ) Γ(a+b)
    +	 *
    +	 * 
    + */ + static public float beta(double a, double b) throws ArithmeticException { + double y; + + y = a + b; + y = gamma(y); + if( y == 0.0 ) return 1.0f; + + if( a > b ) { + y = gamma(a)/y; + y *= gamma(b); + } + else { + y = gamma(b)/y; + y *= gamma(a); + } + + return((float)y); + } + /** + * Returns the Gamma function of the argument, Γ(x) + */ + static public double gamma(double x) throws ArithmeticException { + + double P[] = { + 1.60119522476751861407E-4, + 1.19135147006586384913E-3, + 1.04213797561761569935E-2, + 4.76367800457137231464E-2, + 2.07448227648435975150E-1, + 4.94214826801497100753E-1, + 9.99999999999999996796E-1 + }; + double Q[] = { + -2.31581873324120129819E-5, + 5.39605580493303397842E-4, + -4.45641913851797240494E-3, + 1.18139785222060435552E-2, + 3.58236398605498653373E-2, + -2.34591795718243348568E-1, + 7.14304917030273074085E-2, + 1.00000000000000000320E0 + }; + //double MAXGAM = 171.624376956302725; + //double LOGPI = 1.14472988584940017414; + + double p, z; + int i; + + double q = Math.abs(x); + + if( q > 33.0 ) { + if( x < 0.0 ) { + p = Math.floor(q); + if( p == q ) throw new ArithmeticException("gamma: overflow"); + i = (int)p; + z = q - p; + if( z > 0.5 ) { + p += 1.0; + z = q - p; + } + z = q * Math.sin( Math.PI * z ); + if( z == 0.0 ) throw new ArithmeticException("gamma: overflow"); + z = Math.abs(z); + z = Math.PI/(z * stirlingFormula(q) ); + + return -z; + } else { + return stirlingFormula(x); + } + } + + z = 1.0; + while( x >= 3.0 ) { + x -= 1.0; + z *= x; + } + + while( x < 0.0 ) { + if( x == 0.0 ) { + throw new ArithmeticException("gamma: singular"); + } else + if( x > -1.E-9 ) { + return( z/((1.0 + 0.5772156649015329 * x) * x) ); + } + z /= x; + x += 1.0; + } + + while( x < 2.0 ) { + if( x == 0.0 ) { + throw new ArithmeticException("gamma: singular"); + } else + if( x < 1.e-9 ) { + return( z/((1.0 + 0.5772156649015329 * x) * x) ); + } + z /= x; + x += 1.0; + } + + if( (x == 2.0) || (x == 3.0) ) return z; + + x -= 2.0; + p = Polynomial.polyval( x, P ); + q = Polynomial.polyval( x, Q ); + return z * p / q; + + } + /** + * Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta. + * + * @param aa the alpha parameter of the beta distribution. + * @param bb the beta parameter of the beta distribution. + * @param xx the integration end point. + */ + public static double incompleteBeta( double aa, double bb, double xx ) throws ArithmeticException { + double a, b, t, x, xc, w, y; + boolean flag; + + if( aa <= 0.0 || bb <= 0.0 ) throw new + ArithmeticException("incompleteBeta: Domain error!"); + + if( (xx <= 0.0) || ( xx >= 1.0) ) { + if( xx == 0.0 ) return 0.0; + if( xx == 1.0 ) return 1.0; + throw new ArithmeticException("incompleteBeta: Domain error!"); + } + + flag = false; + if( (bb * xx) <= 1.0 && xx <= 0.95) { + t = powerSeries(aa, bb, xx); + return t; + } + + w = 1.0 - xx; + + /* Reverse a and b if x is greater than the mean. */ + if( xx > (aa/(aa+bb)) ) { + flag = true; + a = bb; + b = aa; + xc = xx; + x = w; + } else { + a = aa; + b = bb; + xc = w; + x = xx; + } + + if( flag && (b * x) <= 1.0 && x <= 0.95) { + t = powerSeries(a, b, x); + if( t <= MACHEP ) t = 1.0 - MACHEP; + else t = 1.0 - t; + return t; + } + + /* Choose expansion for better convergence. */ + y = x * (a+b-2.0) - (a-1.0); + if( y < 0.0 ) + w = incompleteBetaFraction1( a, b, x ); + else + w = incompleteBetaFraction2( a, b, x ) / xc; + + /* Multiply w by the factor + x^a (1-x)^b Γ(a+b) / ( a *Γ(a) *Γ(b) ) . */ + + y = a * Math.log(x); + t = b * Math.log(xc); + if( (a+b) < MAXGAM && Math.abs(y) < MAXLOG && Math.abs(t) < MAXLOG ) { + t = Math.pow(xc,b); + t *= Math.pow(x,a); + t /= a; + t *= w; + t *= gamma(a+b) / (gamma(a) * gamma(b)); + if( flag ) { + if( t <= MACHEP ) t = 1.0 - MACHEP; + else t = 1.0 - t; + } + return t; + } + /* Resort to logarithms. */ + y += t + logGamma(a+b) - logGamma(a) - logGamma(b); + y += Math.log(w/a); + if( y < MINLOG ) + t = 0.0; + else + t = Math.exp(y); + + if( flag ) { + if( t <= MACHEP ) t = 1.0 - MACHEP; + else t = 1.0 - t; + } + return t; + } + + /** + * Returns the inverse of the incomplete Beta integral. + * That is, given y, the function finds x such that + *
    +	 *  incompleteBeta( a, b, x ) = y.
    +	 *
    + * The routine performs interval halving until incompleteBeta(a,b,x) - y = 0, + * to within roughly 10^-13 of the true solution. If this precision is not reached, the + * method returns the current approximation of x, and prints a warning statement + * specifying the current error. Typically, this is on the order of 10^-12. + * + * @param aa the alpha parameter of the beta distribution. + * @param bb the beta parameter of the beta distribution. + * @param yy0 the value for which to solve for the corresponding x in the + * incomplete Beta integral. + * @return the value x such that incompleteBeta( a, b, x ) = y. + */ + public static double incompleteBetaInverse(double aa,double bb,double yy0 ) + { + double a=0, b=0, y0=0, d, y=0, x=0, x0, x1, lgm=0, yp, di=0, dithresh=0, yl, yh, xt; + int i=0, rflg=0, dir=0, nflg; + + //ap_error::make_assertion(y>=0&&y<=1); + if( yy0 <= 0 ) + return 0.0; + if( yy0 >= 1.0 ) + return 1.0; + x0 = 0.0; + yl = 0.0; // ylow + x1 = 1.0; + yh = 1.0; // yhigh + + int count = 0; + double precision = 1e-8; + + /* Make an initial approximation for the inverse function */ + + if( aa <= 1.0 || bb <= 1.0 ) + { + dithresh = 1.0e-6; + rflg = 0; + a = aa; + b = bb; + y0 = yy0; + x = a/(a+b); // approximate x using the mean value + y = incompleteBeta( a, b, x ); + } + else{ + a=aa; + b=bb; + y0 = yy0; + + yp = -Probability.norminv(yy0); + if( yy0 > 0.5 ) + { + yp = -yp; // since the normal distribution is symmetric + } + // log gamma + lgm = (yp * yp - 3.0)/6.0; + x = 2.0/( 1.0/(2.0*a-1.0) + 1.0/(2.0*b-1.0) ); + + d = yp * Math.sqrt( x + lgm ) / x + - ( 1.0/(2.0*b-1.0) - 1.0/(2.0*a-1.0) ) + * (lgm + 5.0/6.0 - 2.0/(3.0*x)); + d = 2.0 * d; + if( d < MINLOG ) + { + x = 0.0; + return x; + } + x = a/( a + b * Math.exp(d) ); + y = incompleteBeta( a, b, x ); + } + + /* This only works because the incompleteBeta function is an increasing function */ + while (Math.abs(y-y0) > precision && count<1000) + { + // if y>y0, we're too far right so move x1 to x + if (y > y0) + { + x1 = x; + } + else // y<=y0 we're too far left so move x0 to the right. + { + x0 = x; + } + x = (x1 + x0) / 2; + y = incompleteBeta( a, b, x ); + count++; // so we don't end up in a never-ending loop. + } + if(count>=1000){ + System.out.println("Warning: incompleteBetaInverse: Could not solve to specified precision."+ + "Returning closest match ( error = " + Math.abs(y-y0)+" )"); + } + return x; + } + + /** + * Continued fraction expansion #1 for incomplete beta integral; formerly named incbcf. + */ + static double incompleteBetaFraction1( double a, double b, double x ) throws ArithmeticException { + double xk, pk, pkm1, pkm2, qk, qkm1, qkm2; + double k1, k2, k3, k4, k5, k6, k7, k8; + double r, t, ans, thresh; + int n; + + k1 = a; + k2 = a + b; + k3 = a; + k4 = a + 1.0; + k5 = 1.0; + k6 = b - 1.0; + k7 = k4; + k8 = a + 2.0; + + pkm2 = 0.0; + qkm2 = 1.0; + pkm1 = 1.0; + qkm1 = 1.0; + ans = 1.0; + r = 1.0; + n = 0; + thresh = 3.0 * MACHEP; + do { + xk = -( x * k1 * k2 )/( k3 * k4 ); + pk = pkm1 + pkm2 * xk; + qk = qkm1 + qkm2 * xk; + pkm2 = pkm1; + pkm1 = pk; + qkm2 = qkm1; + qkm1 = qk; + + xk = ( x * k5 * k6 )/( k7 * k8 ); + pk = pkm1 + pkm2 * xk; + qk = qkm1 + qkm2 * xk; + pkm2 = pkm1; + pkm1 = pk; + qkm2 = qkm1; + qkm1 = qk; + + if( qk != 0 ) r = pk/qk; + if( r != 0 ) { + t = Math.abs( (ans - r)/r ); + ans = r; + } else + t = 1.0; + + if( t < thresh ) return ans; + + k1 += 1.0; + k2 += 1.0; + k3 += 2.0; + k4 += 2.0; + k5 += 1.0; + k6 -= 1.0; + k7 += 2.0; + k8 += 2.0; + + if( (Math.abs(qk) + Math.abs(pk)) > big ) { + pkm2 *= biginv; + pkm1 *= biginv; + qkm2 *= biginv; + qkm1 *= biginv; + } + if( (Math.abs(qk) < biginv) || (Math.abs(pk) < biginv) ) { + pkm2 *= big; + pkm1 *= big; + qkm2 *= big; + qkm1 *= big; + } + } while( ++n < 300 ); + + return ans; + } + /** + * Continued fraction expansion #2 for incomplete beta integral; formerly named incbd. + */ + static double incompleteBetaFraction2( double a, double b, double x ) throws ArithmeticException { + double xk, pk, pkm1, pkm2, qk, qkm1, qkm2; + double k1, k2, k3, k4, k5, k6, k7, k8; + double r, t, ans, z, thresh; + int n; + + k1 = a; + k2 = b - 1.0; + k3 = a; + k4 = a + 1.0; + k5 = 1.0; + k6 = a + b; + k7 = a + 1.0;; + k8 = a + 2.0; + + pkm2 = 0.0; + qkm2 = 1.0; + pkm1 = 1.0; + qkm1 = 1.0; + z = x / (1.0-x); + ans = 1.0; + r = 1.0; + n = 0; + thresh = 3.0 * MACHEP; + do { + xk = -( z * k1 * k2 )/( k3 * k4 ); + pk = pkm1 + pkm2 * xk; + qk = qkm1 + qkm2 * xk; + pkm2 = pkm1; + pkm1 = pk; + qkm2 = qkm1; + qkm1 = qk; + + xk = ( z * k5 * k6 )/( k7 * k8 ); + pk = pkm1 + pkm2 * xk; + qk = qkm1 + qkm2 * xk; + pkm2 = pkm1; + pkm1 = pk; + qkm2 = qkm1; + qkm1 = qk; + + if( qk != 0 ) r = pk/qk; + if( r != 0 ) { + t = Math.abs( (ans - r)/r ); + ans = r; + } else + t = 1.0; + + if( t < thresh ) return ans; + + k1 += 1.0; + k2 -= 1.0; + k3 += 2.0; + k4 += 2.0; + k5 += 1.0; + k6 += 1.0; + k7 += 2.0; + k8 += 2.0; + + if( (Math.abs(qk) + Math.abs(pk)) > big ) { + pkm2 *= biginv; + pkm1 *= biginv; + qkm2 *= biginv; + qkm1 *= biginv; + } + if( (Math.abs(qk) < biginv) || (Math.abs(pk) < biginv) ) { + pkm2 *= big; + pkm1 *= big; + qkm2 *= big; + qkm1 *= big; + } + } while( ++n < 300 ); + + return ans; + } + /** + * Returns the Incomplete Gamma function; formerly named igamma. + * @param a the parameter of the gamma distribution. + * @param x the integration end point. + */ + static public double incompleteGamma(double a, double x) + throws ArithmeticException { + + + double ans, ax, c, r; + + if( x <= 0 || a <= 0 ) return 0.0; + + if( x > 1.0 && x > a ) return 1.0 - incompleteGammaComplement(a,x); + + /* Compute x**a * exp(-x) / gamma(a) */ + ax = a * Math.log(x) - x - logGamma(a); + if( ax < -MAXLOG ) return( 0.0 ); + + ax = Math.exp(ax); + + /* power series */ + r = a; + c = 1.0; + ans = 1.0; + + do { + r += 1.0; + c *= x/r; + ans += c; + } + while( c/ans > MACHEP ); + + return( ans * ax/a ); + + } + /** + * Returns the Complemented Incomplete Gamma function; formerly named igamc. + * @param a the parameter of the gamma distribution. + * @param x the integration start point. + */ + static public double incompleteGammaComplement( double a, double x ) throws ArithmeticException { + double ans, ax, c, yc, r, t, y, z; + double pk, pkm1, pkm2, qk, qkm1, qkm2; + + if( x <= 0 || a <= 0 ) return 1.0; + + if( x < 1.0 || x < a ) return 1.0 - incompleteGamma(a,x); + + ax = a * Math.log(x) - x - logGamma(a); + if( ax < -MAXLOG ) return 0.0; + + ax = Math.exp(ax); + + /* continued fraction */ + y = 1.0 - a; + z = x + y + 1.0; + c = 0.0; + pkm2 = 1.0; + qkm2 = x; + pkm1 = x + 1.0; + qkm1 = z * x; + ans = pkm1/qkm1; + + do { + c += 1.0; + y += 1.0; + z += 2.0; + yc = y * c; + pk = pkm1 * z - pkm2 * yc; + qk = qkm1 * z - qkm2 * yc; + if( qk != 0 ) { + r = pk/qk; + t = Math.abs( (ans - r)/r ); + ans = r; + } else + t = 1.0; + + pkm2 = pkm1; + pkm1 = pk; + qkm2 = qkm1; + qkm1 = qk; + if( Math.abs(pk) > big ) { + pkm2 *= biginv; + pkm1 *= biginv; + qkm2 *= biginv; + qkm1 *= biginv; + } + } while( t > MACHEP ); + + return ans * ax; + } + /** + * Returns the natural logarithm of the gamma function; formerly named lgamma. + */ + public static double logGamma(double x) throws ArithmeticException { + double p, q, w, z; + + double A[] = { + 8.11614167470508450300E-4, + -5.95061904284301438324E-4, + 7.93650340457716943945E-4, + -2.77777777730099687205E-3, + 8.33333333333331927722E-2 + }; + double B[] = { + -1.37825152569120859100E3, + -3.88016315134637840924E4, + -3.31612992738871184744E5, + -1.16237097492762307383E6, + -1.72173700820839662146E6, + -8.53555664245765465627E5 + }; + double C[] = { + 1.00000000000000000000E0, + -3.51815701436523470549E2, + -1.70642106651881159223E4, + -2.20528590553854454839E5, + -1.13933444367982507207E6, + -2.53252307177582951285E6, + -2.01889141433532773231E6 + }; + + if( x < -34.0 ) { + q = -x; + w = logGamma(q); + p = Math.floor(q); + if( p == q ) throw new ArithmeticException("logGamma: Overflow"); + z = q - p; + if( z > 0.5 ) { + p += 1.0; + z = p - q; + } + z = q * Math.sin( Math.PI * z ); + if( z == 0.0 ) throw new + ArithmeticException("logGamma: Overflow"); + z = LOGPI - Math.log( z ) - w; + return z; + } + + if( x < 13.0 ) { + z = 1.0; + while( x >= 3.0 ) { + x -= 1.0; + z *= x; + } + while( x < 2.0 ) { + if( x == 0.0 ) throw new + ArithmeticException("logGamma: Overflow"); + z /= x; + x += 1.0; + } + if( z < 0.0 ) z = -z; + if( x == 2.0 ) return Math.log(z); + x -= 2.0; + p = x * Polynomial.polyval( x, B) / Polynomial.polyval( x, C); + return( Math.log(z) + p ); + } + + if( x > 2.556348e305 ) throw new + ArithmeticException("logGamma: Overflow"); + + q = ( x - 0.5 ) * Math.log(x) - x + 0.91893853320467274178; + //if( x > 1.0e8 ) return( q ); + if( x > 1.0e8 ) return( q ); + + p = 1.0/(x*x); + if( x >= 1000.0 ) + q += (( 7.9365079365079365079365e-4 * p + - 2.7777777777777777777778e-3) *p + + 0.0833333333333333333333) / x; + else + q += Polynomial.polyval( p, A ) / x; + return q; + } + /** + * Power series for incomplete beta integral; formerly named pseries. + * Use when b*x is small and x not too close to 1. + */ + static double powerSeries( double a, double b, double x ) throws ArithmeticException { + double s, t, u, v, n, t1, z, ai; + + ai = 1.0 / a; + u = (1.0 - b) * x; + v = u / (a + 1.0); + t1 = v; + t = u; + n = 2.0; + s = 0.0; + z = MACHEP * ai; + while( Math.abs(v) > z ) { + u = (n - b) * x / n; + t *= u; + v = t / (a + n); + s += v; + n += 1.0; + } + s += t1; + s += ai; + + u = a * Math.log(x); + if( (a+b) < MAXGAM && Math.abs(u) < MAXLOG ) { + t = Gamma.gamma(a+b)/(Gamma.gamma(a)*Gamma.gamma(b)); + s = s * t * Math.pow(x,a); + } else { + t = Gamma.logGamma(a+b) - Gamma.logGamma(a) - Gamma.logGamma(b) + u + Math.log(s); + if( t < MINLOG ) s = 0.0; + else s = Math.exp(t); + } + return s; + } + /** + * Returns the Gamma function computed by Stirling's formula; formerly named stirf. + * The polynomial STIR is valid for 33 <= x <= 172. + */ + static double stirlingFormula(double x) throws ArithmeticException { + double STIR[] = { + 7.87311395793093628397E-4, + -2.29549961613378126380E-4, + -2.68132617805781232825E-3, + 3.47222221605458667310E-3, + 8.33333333333482257126E-2, + }; + double MAXSTIR = 143.01608; + + double w = 1.0/x; + double y = Math.exp(x); + + w = 1.0 + w * Polynomial.polyval( w, STIR); + + if( x > MAXSTIR ) { + /* Avoid overflow in Math.pow() */ + double v = Math.pow( x, 0.5 * x - 0.25 ); + y = v * (v / y); + } else { + y = Math.pow( x, x - 0.5 ) / y; + } + y = SQTPI * y * w; + return y; + } +} diff --git a/drawing/papaya/src/papaya/LU.java b/drawing/papaya/src/papaya/LU.java new file mode 100644 index 0000000..0ac1b42 --- /dev/null +++ b/drawing/papaya/src/papaya/LU.java @@ -0,0 +1,410 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +/** LU Decomposition. +

    +For an m x n matrix A with m > n, the LU decomposition is an m x n +unit lower triangular matrix L, an n x n upper triangular matrix U, +and a permutation vector piv of length m so that A(piv,:) = L*U; +If m < n, then L is m x m and U is m x n. +

    +The LU decomposition with pivoting always exists, even if the matrix is +singular, so the constructor will never fail. The primary use of the +LU decomposition is in the solution of square systems of simultaneous +linear equations. This will fail if isNonsingular() returns false. +

    +Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +{@link Cast#doubleToFloat(double[][])} if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). + */ + +public class LU { + + /* ------------------------ +Class variables + * ------------------------ */ + + /** Array for internal storage of decomposition. +@serial internal array storage. + */ + private double[][] LU; + + /** Row and column dimensions, and pivot sign. +@serial column dimension. +@serial row dimension. +@serial pivot sign. + */ + private int numRows, numColumns, pivsign; + + /** Internal storage of pivot vector. +@serial pivot vector. + */ + private int[] piv; + + /* ------------------------ +Constructor + * ------------------------ */ + + /** Constructor. Takes in a matrix and computes the LU matrix. Additional + * parameters can be obtained by calling one of the available methods. + * @see getL() + * @see getU() + * @see getPivot() + * @see getFloatPivot() + * @see det() + */ + public LU (float[][] A) { + + // Use a "left-looking", dot-product, Crout/Doolittle algorithm. + LU = Cast.floatToDouble(A); + numRows = A.length; + numColumns = A[0].length; + piv = new int[numRows]; + for (int i = 0; i < numRows; i++) { + piv[i] = i; + } + pivsign = 1; + double[] LUrowi; + double[] LUcolj = new double[numRows]; + + // Outer loop. + + for (int j = 0; j < numColumns;j++) { + + // Make a copy of the j-th column to localize references. + + for (int i = 0; i < numRows; i++) { + LUcolj[i] = LU[i][j]; + } + + // Apply previous transformations. + + for (int i = 0; i < numRows; i++) { + LUrowi = LU[i]; + + // Most of the time is spent in the following dot product. + + int kmax = Math.min(i,j); + float s = 0.0f; + for (int k = 0; k < kmax; k++) { + s += LUrowi[k]*LUcolj[k]; + } + + LUrowi[j] = LUcolj[i] -= s; + } + + // Find pivot and exchange if necessary. + + int p = j; + for (int i = j+1; i < numRows; i++) { + if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) { + p = i; + } + } + if (p != j) { + for (int k = 0; k < numColumns; k++) { + double t = LU[p][k]; LU[p][k] = LU[j][k]; LU[j][k] = t; + } + int k = piv[p]; piv[p] = piv[j]; piv[j] = k; + pivsign = -pivsign; + } + + // Compute multipliers. + + if (j < numRows & LU[j][j] != 0.0) { + for (int i = j+1; i < numRows; i++) { + LU[i][j] /= LU[j][j]; + } + } + } + } + + /* ------------------------ +Temporary, experimental code. +------------------------ *\ + +\** LU Decomposition, computed by Gaussian elimination. +

    +This constructor computes L and U with the "daxpy"-based elimination +algorithm used in LINPACK and MATLAB. In Java, we suspect the dot-product, +Crout algorithm will be faster. We have temporarily included this +constructor until timing experiments confirm this suspicion. +

    +@param A Rectangular matrix +@param linpackflag Use Gaussian elimination. Actual value ignored. +@return Structure to access L, U and piv. + *\ + +public LUDecomposition (Matrix A, int linpackflag) { + // Initialize. + LU = A.getArrayCopy(); + m = A.getRowDimension(); + n = A.getColumnDimension(); + piv = new int[m]; + for (int i = 0; i < numRows; i++) { + piv[i] = i; + } + pivsign = 1; + // Main loop. + for (int k = 0; k < numColumns k++) { + // Find pivot. + int p = k; + for (int i = k+1; i < numRows; i++) { + if (Math.abs(LU[i][k]) > Math.abs(LU[p][k])) { + p = i; + } + } + // Exchange if necessary. + if (p != k) { + for (int j = 0; j < numColumns;j++) { + double t = LU[p][j]; LU[p][j] = LU[k][j]; LU[k][j] = t; + } + int t = piv[p]; piv[p] = piv[k]; piv[k] = t; + pivsign = -pivsign; + } + // Compute multipliers and eliminate k-th column. + if (LU[k][k] != 0.0) { + for (int i = k+1; i < numRows; i++) { + LU[i][k] /= LU[k][k]; + for (int j = k+1; j < numColumns;j++) { + LU[i][j] -= LU[i][k]*LU[k][j]; + } + } + } + } +} + +\* ------------------------ +End of temporary code. + * ------------------------ */ + + /* ------------------------ +Public Methods + * ------------------------ */ + + /** Is the matrix nonsingular? +@return true if U, and hence A, is nonsingular. + */ + + public boolean isNonsingular () { + for (int j = 0; j < numColumns;j++) { + if (LU[j][j] == 0) + return false; + } + return true; + } + + /** Return lower triangular factor, L.*/ + public double[][] getL () { + double[][] L = new double[numRows][numColumns]; + for (int i = 0; i < numRows; i++) { + for (int j = 0; j < numColumns;j++) { + if (i > j) { + L[i][j] = LU[i][j]; + } else if (i == j) { + L[i][j] = 1.0f; + } else { + L[i][j] = 0.0f; + } + } + } + return L; + } + + /** Return upper triangular factor, U */ + public double[][] getU () { + double[][] U = new double[numColumns][numColumns]; + for (int i = 0; i < numColumns; i++) { + for (int j = 0; j < numColumns;j++) { + if (i <= j) { + U[i][j] = LU[i][j]; + } else { + U[i][j] = 0.0f; + } + } + } + return U; + } + + /** Return pivot permutation vector +@return piv + */ + + public int[] getPivot () { + int[] p = new int[numRows]; + for (int i = 0; i < numRows; i++) { + p[i] = piv[i]; + } + return p; + } + + /** Return pivot permutation vector as a one-dimensional float array + * @return piv + */ + + public float[] getFloatPivot () { + float[] vals = new float[numRows]; + for (int i = 0; i < numRows; i++) { + vals[i] = (float) piv[i]; + } + return vals; + } + + /** Determinant + *@return det(A) + *@exception IllegalArgumentException Matrix must be square + */ + public double det () { + if (numRows != numColumns) { + throw new IllegalArgumentException("Matrix must be square."); + } + double d = (double) pivsign; + for (int j = 0; j < numColumns;j++) { + d *= LU[j][j]; + } + return d; + } + + /** Solve A*x = b for x + * @param b An array with as many elements as the number of rows in A. + * @return x so that L*U*x = b(piv,:) + * @exception IllegalArgumentException Matrix row dimensions must agree. + * @exception RuntimeException Matrix is singular. + */ + public double[] solve (float[] b, boolean returnZeroesForSingularCase) { + if (b.length != numRows) { + throw new IllegalArgumentException("Matrix row dimensions must agree."); + } + if (!this.isNonsingular()) { + if(returnZeroesForSingularCase) return new double[numColumns]; + else throw new RuntimeException("Matrix is singular."); + } + + // Copy right hand side with pivoting + double[] X = Cast.floatToDouble(Mat.populate(b,piv)); + //System.out.println(X.length+","+b.length+","+LU[0].length); + // Solve L*Y = B(piv,:) + for (int k = 0; k < numColumns; k++) { + for (int i = k+1; i < numColumns; i++) { + X[i] -= X[k]*LU[i][k]; + } + } + // Solve U*X = Y; + for (int k = numColumns-1; k >= 0; k--) { + X[k] /= LU[k][k]; + for (int i = 0; i < k; i++) { + X[i] -= X[k]*LU[i][k]; + } + } + //Mat.print(X,3); System.out.print("\n"); + return X; + } + + /** Solve A*X = B + * @param B A Matrix with as many rows as A and any number of columns. + * @return X so that L*U*X = B(piv,:) + * @exception IllegalArgumentException Matrix row dimensions must agree. + * @exception RuntimeException Matrix is singular. + */ + public double[][] solve (float[][] B) { + if (B.length != numRows) { + throw new IllegalArgumentException("Matrix row dimensions must agree."); + } + if (!this.isNonsingular()) { + throw new RuntimeException("Matrix is singular."); + } + + // Copy right hand side with pivoting + int nx = B[0].length; + double[][] X = subMatrix(B,piv,0,nx-1); + // Solve L*Y = B(piv,:) + for (int k = 0; k < numColumns; k++) { + for (int i = k+1; i < numColumns; i++) { + for (int j = 0; j < nx; j++) { + X[i][j] -= X[k][j]*LU[i][k]; + } + } + } + // Solve U*X = Y; + for (int k = numColumns-1; k >= 0; k--) { + for (int j = 0; j < nx; j++) { + X[k][j] /= LU[k][k]; + } + for (int i = 0; i < k; i++) { + for (int j = 0; j < nx; j++) { + X[i][j] -= X[k][j]*LU[i][k]; + } + } + } + return X; + } + + /** + * Function to get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). + * @param inputMat input matrix + * @param rowIndices the row indices + * @param columnStart column to start at (inclusive) + * @param columnEnd column to end at (inclusive) + * @return the submatrix containing a copy of the input matrix's specified rows from + * columnStart to columnEnd; copy of A(rowIndices(:), columnStart:columnEnd). + * @throws IllegalArgumentException if the inputs are not within the inputMatrix size bounds. + */ + private static double[][] subMatrix(float[][] inputMat, int[] rowIndices, int columnStart, int columnEnd) { + int numRows = rowIndices.length; + int numColumns = columnEnd-columnStart+1; + double[][] outputMat = new double[numRows][numColumns]; + for (int i = 0; i z[i] = x[i] * y[i]. + */ + private static double[] multiply(float[] data1, int[] pivot){ + int size = data1.length; + double[] multiplied = new double[size]; + for(int i=0; iz = slope*x + intercept by minimizing the sum of least squares + * between z and the y. + * @param x the x data + * @param y the y data + * @return a 2-by-1 array with the first element coeff[0]corresponding to + * the slope, and the second element coeff[1] equal to the y-intercept. + */ + public static float[] bestFit(float[] x, float[] y){ + int size = x.length; + Check.equalLengths(size,y); + if(size<3) throw new IllegalArgumentException("Each data array needs to hold at least 3 values."); + + // the best-fit linear line coefficients. + double sumX = 0; double sumY = 0; double sumXY = 0; double sumXX = 0; + for(int i=0; iz = slope*x + intercept, where the intercept is specified + * by the user. E.g. intercept = 1 will result in z = slope*x+1. + * The slope is computed by minimizing the sum of least squares + * between z and the y. + * @param x the x data + * @param y the y data + * @param intercept the intercept of the best-fit line with the y-axis. + * + * @return the slope of the best-fit linear line. + */ + public static float bestFit(float[] x, float[] y, float intercept){ + int size = x.length; + Check.equalLengths(size,y); + if(size<3) throw new IllegalArgumentException("Each data array needs to hold at least 3 values."); + // the best-fit linear line coefficients. + double sumX = 0; double sumY = 0; double sumXY = 0; double sumXX = 0; + for(int i=0; iDelta_i = z_i - y_i, + * where + * z_i = (slope*x_i + intercept) is the best fit linear line. + * @param slope the slope of the best-fit linear line + * @param intercept the y-intercept of the best fit linear line + */ + public static float[] residuals(float[] x, float[] y, float slope, float intercept){ + int size = x.length; Check.equalLengths(size,y); + float[] delta = new float[size]; + for(int i=0; iDelta_i = z_i - y_i, + * where + * z_i = (slope*x_i + intercept) is the best fit linear line. + * You'd basically use this to compute the spread of a best fit line (max - min) + */ + public static float[] residuals(float[] x, float[] y){ + int size = x.length; Check.equalLengths(size,y); + float[] params = bestFit(x,y); + float[] delta = new float[size]; + for(int i=0; i + * residualStdErr = Sqrt ( Sum( (delta[i] - mean(delta))^2 ) / df ) + * + * where df is the degrees of freedom ( (n-1) if the y-intercept was pre-specified in the + * best-fit line, (n-2) if neither slope nor intercept were specified.) + * @param residuals + * @param df + * @return standard error of the residual + */ + public static float residual(float[] residuals, int df){ + int size = residuals.length; + return (float)Math.sqrt( Descriptive.var(residuals,false) * size/df ); + } + /** + * Returns the standard error of the computed slope given x and the + * standard error in the residuals. That is, + *

    +		 * slopeStdErr = residualStdErr / Sum ( (x[i] - mean(x))^2 ).
    +		 * 
    + * @param x the independent variable + * @param residualStdErr the standard error of the residual + * @return the error in the slope. + */ + public static float slope(float[] x, float residualStdErr ){ + float v = Descriptive.varianceNotNormalized(x); + double slopeError = residualStdErr/Math.sqrt(v); + return (float)slopeError; + } + /** + * Returns the standard error of the computed slope given x and the + * standard error in the residuals. That is, + *
    +		 * interceptStdErr = slopeStdErr / Sqrt( Sum(x[i]*x[i])/size ).
    +		 * 
    + * where the slopeStdErr is computed using the methods specified + * in {@link StdErr#slope}. + * @param x the independent variable + * @param residualStdErr the standard error of the residual + * @return error in the slope. + */ + public static float intercept(float[] x, float residualStdErr ){ + int size = x.length; + float slopeError = slope(x,residualStdErr); + double sumXX = 0; + for(int i=0; inot to be used for small datasets(i.e. size<20). + */ + public static class Significance{ + /** + * Returns the p-value, or significance, of the computed slope under the null-hypothesis + * of slope = 0 (two-tailed test). The p-value is computed using the student-T distribution + * with df degrees of freedom and test statistic + *
     t = slope/slopeStdErr,
    + * @param slope the slope of the best fit linear line + * @param slopeStdErr the standard error of the slope + * @param df the degrees of freedom (typically (n-2), but could also be (n-1) if the + * intercept was previously specified. + */ + public static float slope(float slope, float slopeStdErr, int df){ + double t = slope/slopeStdErr; + System.out.println("t slope: "+t); + return (float)twoTailedStudentT(t,df); + } + /** + * Returns the p-value, or significance, of the computed intercept under the null-hypothesis + * of intercept = 0 (two-tailed test). The p-value is computed using the student-T distribution + * with df degrees of freedom and test statistic + *
    t=intercept/interceptStdErr
    + * @param intercept the intercept of the best fit linear line + * @param interceptStdErr the standard error of the intercept + * @param df the degrees of freedom (n-2) + */ + public static float intercept(float intercept, float interceptStdErr, int df){ + double t = intercept/interceptStdErr; + System.out.println("t intercept: "+t); + return (float)twoTailedStudentT(t,df); + } + } + + /** + * Contains methods related to the Box-Cox transformation of a data set; useful in + * determining the best transformation that will yield the best method for converting + * a monotonic, non-linear relationship between x and y into + * a linear one. + *

    Reference: + *
    Box, George E. P.; Cox, D. R. (1964). "An analysis of transformations". + * Journal of the Royal Statistical Society, Series B 26 (2): 211?252. + *
    + * NIST/SEMATECH e-Handbook of Statistical Methods, EDA Section 1.3.3.6: Box-Cox Linearity Plots + * (The reader's digest version of the original.) + * + */ + public static class BoxCox{ + protected BoxCox(){} + + /** + * Performs the box-cox transformation on y for a sequence of λ + * and returns the array of linear correlation coefficients + * between the x and the box-cox transformed y. + * at each value of λ . + * The value of λ corresponding to the maximum correlation + * (or minimum for negative correlation) is the optimal choice for + * λ such that the relationship between x and T(y) is linear. + *

    Reference: + *
    + * NIST/SEMATECH e-Handbook of Statistical Methods, EDA Section 1.3.3.6: Box-Cox Linearity Plots + * + * @param x the independent data array + * @param y the dependent data array + * @param lambda an array of lambda values + * @return the array containing the linear correlation coefficients, r. + */ + public static float[] correlation(float[] x, float[] y, float []lambda){ + /* Check that the data is all positive */ + if(Descriptive.min(x)<=0) throw new IllegalArgumentException("y (the dependent variable) has to be strictly > 0."); + int size = x.length; + Check.equalLengths(size,y); + float[] transformed = new float[size]; + int numSteps = lambda.length; + float[] corrcoef = new float[numSteps]; + for(int i=0; i + * y[i](λ) = (y[i]^λ-1) / λ if λ ≠ 0 + * + * y[i](λ) = log(y[i])if λ = 0 + * + * Requirements: all elements of y are >0. + * @param data the data to be transformed + * @param lambda the lambda value + * @return the transformed data, or y(λ) above. + * */ + public static float[] transform(float[] data, float lambda){ + /* Check that the data is all positive */ + if(Descriptive.min(data)<=0) throw new IllegalArgumentException("data has to be strictly > 0."); + int size = data.length; + float[] transformed = new float[size]; + if(lambda==0){ + for(int i=0; i0) return ( 2*(1.0- (Probability.tcdf(t,df)) ) ); + else return (2 * (Probability.tcdf(t,df))); + } +} + + + + + + + + diff --git a/drawing/papaya/src/papaya/MDS.java b/drawing/papaya/src/papaya/MDS.java new file mode 100644 index 0000000..add55c3 --- /dev/null +++ b/drawing/papaya/src/papaya/MDS.java @@ -0,0 +1,149 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ + +package papaya; + +import java.util.*; +import java.io.*; +import java.text.NumberFormat; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; + +import processing.core.*; + +/** + * Contains methods for performing but classical and non-classical multidimensional scaling. + *

    + * For an m-by-n input matrix with m observations and n variables, the output D is + * the symmetric m-by-m matrix with zeros along the diagonals and element ij + * specifying the distance between rows i and j. + * + */ +public final class MDS { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected MDS(){ + + } + static double MACHEP = PapayaConstants.MACHEP; + + /** + * Performs classical (metric) multidimensional scaling, on an input matrix of Distances (computed + * using e.g. {@link Distance} ) and outputs the best-fitting p-dimensional configuration of points + * (p<N). The output matrix Y has p columns with rows + * giving the coordinates of the points chosen to represent the dissimilarities. + * When D corresponds to the Euclidian distance matrix, the p + * dimensional coordinates correspond exactly to the first p principal components. + *

    + * Remarks + *

      + *
    • If p > kwhere k is the number of + * positive eigenvalues of Y*Y', then only the + * first k columns of Y are computed. + *
    • + *
    • Set showEigenvalues to true to print the + * values of the "scalar product matrix" Y*Y' to the screen. + * (This is a good idea if you want to know how well the first p dimensions + * captures most of the variation in D.
    • + *
    > + * @param D the input distance matrix (see {@link Distance}) + * @param p the dimension (number of columns) of the output matrix. + * @param showEigenvalues whether to print the eigenvalues to the screen or otherwise. + * @return Y, N-by-p (or N-by-k) matrix consisting of N points in each of the p (or k) dimensions. + */ + public static float[][] classical(float[][] D, int p, boolean showEigenvalues){ + Check.square(D); + int n = D.length; + float[][] P = createP(n); + float[][] B = new float[n][n]; + double sum = 0.0; + // Doubly center D + for(int i=0; ikeep.length) { + System.out.println("\nNumber of dimensions exceeds the number of positive Eigenvalues. "+ + "Returning the first "+ln+" dimensions instead.\n"); + } + float[][] Y = new float[n][ln]; + if(keep.length==0) + System.out.println("\nUnable to find a suitable Y. Maximum eigenvalue is "+Descriptive.max(e)); + else{ + //Y = V(:,i(keep)) * diag(sqrt(e(keep))); + double sqrtEig = 0.0; + for(int c=0; cval) {indices[j]=i; j++;} + } + return Arrays.copyOf(indices,j); + } + +} \ No newline at end of file diff --git a/drawing/papaya/src/papaya/Mat.java b/drawing/papaya/src/papaya/Mat.java new file mode 100644 index 0000000..a48de20 --- /dev/null +++ b/drawing/papaya/src/papaya/Mat.java @@ -0,0 +1,1511 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ + +package papaya; + +import java.util.*; +import java.io.*; +import java.text.NumberFormat; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; + +import processing.core.*; + +/** + * Static class for performing some basic matrix operations. + *

    + * Guidelines + *
    + * Methods that modify an array by a value always take the array as the first parameter, and + * the value as the second. + * For example, + *

      + *
      {@link divide(float[] array, float numberToDivideBy)} + *
      {@link multiply(float[] array, float numberToMultiplyBy)} + *
      {@link sum(float[] array, float numberToAdd)} + *
    + * I try to follow that guiding principle with all methods that take in an input + * array (e.g. {@link swap(float[] array, int index1, int index2)}, + * {@link populate(float[] array, int[] indices)}). + *

    + * Remarks + *
    + * Almost all the methods here take in float arrays or matrices, although I've also added in a few + * methods that operate on integers. In addition, to avoid accidental array manipulation, + * all methods return a new array or matrix instead of modifying the original one. E.g. + *
    C[i][j] = A[i][j]*B[i][j] return C + *
    as opposed to + *
    A[i][j] = A[i][j]*B[i][j], return A + *
    in {@link dotMultiply(float[][],float[][])}. + * (If you find it performing to the contrary though, please let me know!) + * + *

    + * Some non-trivial matrix-math related methods, including those for getting + * the condition number, inverse, rank, and norms of a 2D input matrix are also included. + * Making everything float-based instead of double-based naturally results in some precision loss but + * the internal computations are done using doubles to minimize this. + * + *

    + * + * @see Cast + * @see Find + * @see NaNs + * @see Rank + * @see Sorting + * + */ +public final class Mat { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Mat(){ + + } + /** + * Appends the part of the specified list between from (inclusive) and + * to (inclusive) to the receiver. + * + *@param listToAddTo ArrayList to add the elements to. Clears this list before + * adding the elements in. + * @param data the array to be added to the listToAddTo. + * @param from the index of the first element to be appended (inclusive). + * @param to the index of the last element to be appended (inclusive). + * @exception IndexOutOfBoundsException index is out of range + * ((from<0 || from>to || to>=sortedData.length)). + */ + private static void addAllOfFromTo(ArrayList listToAddTo, float[] sortedData,int from, int to){ + if (from<0 || from>to || to>sortedData.length) { + throw new IndexOutOfBoundsException("from: "+from+", to: "+to+", sortedData.length: "+sortedData.length); + } + // print a warning just in case. + if(listToAddTo.size()>0){ + System.out.println("Warning: Input ArrayList has size "+listToAddTo.size()+ + ". Appending the data to the end of the end"); + } + for(int i = from; i<=to; i++){ + listToAddTo.add(sortedData[i]); + } + } + + /** Return absolute values of an array */ + public static float[] abs(float[] array){ + float[] output = new float[array.length]; + for(int i=0; i=inputMat[0].length || indexStart >indexEnd || indexStart<0) + throw new IllegalArgumentException("Invalid indices"); + float[][] outputMat = new float[inputMat.length][indexEnd-indexStart+1]; + int k; + for (int i = 0; i b ? 1 : 0; + } + /** Returns -1 if a is less than b, or 1 if a is greater than b, or 0. + This is the comparator function for natural order. */ + + public static float compare(float a, float b) { + return a < b ? -1 : a > b ? 1 : 0; + } + + /** + * Concatenates two arrays a and b into a new array + * c such that c = {a,b}. + */ + public static float[] concat(float[] a, float[] b) { + float[] c= new float[a.length+b.length]; + System.arraycopy(a, 0, c, 0, a.length); + System.arraycopy(b, 0, c, a.length, b.length); + return c; + } + public static int[] concat(int[] a, int[] b) { + int[] c= new int[a.length+b.length]; + System.arraycopy(a, 0, c, 0, a.length); + System.arraycopy(b, 0, c, a.length, b.length); + return c; + } + + /** + * Returns an array with of length size with + * each element equal to the specified constValue. + * @see Arrays.fill + */ + public static float[] constant(float constValue, int size){ + float[] constant = new float[size]; + for(int i=0; isize with + * each element equal to the specified constValue. + * @see Arrays.fill + */ + public static int[] constant(int constValue, int size){ + int[] constant = new int[size]; + for(int i=0; ia copy of the input array in ascending order + * @return a sorted copy of the input array. + */ + public static float[] copyThenSort(float[] data){ + float[] sortedData = new float[data.length]; + System.arraycopy(data, 0, sortedData, 0, data.length); + Arrays.sort(sortedData); + return sortedData; + } + + /** vector cross product: c = a (cross) b */ + public static float[] cross(float[] a, float[] b){ + if(a.length!=3 || b.length!=3) throw new IllegalArgumentException("Inputs to Mat.cross have lengths !=3"); + float[] c = new float[3]; + c[0] = a[1]*b[2] - a[2]*b[1]; + c[1] = a[2]*b[0] - a[0]*b[2]; + c[2] = a[0]*b[1] - a[1]*b[0]; + return c; + } + + /** returns the determinant of the square input matrix. + * @throws IllegalArgumentException if the matrix is not square. */ + public static float det (float[][] data) { + return (float)(new LU(data).det()); + } + + /** + * Divides all elements of input array by value. + * That is, z[i] = x[i] / value. + * @throws IllegalArgumentException if value is zero. + */ + public static float[] divide(float[] data, float value){ + if(value==0) throw new IllegalArgumentException("Division by zero"); + float[] divided = new float[data.length]; + for(int i=0; idimension*/ + public static float[][] identity(int dimension){ + float[][] ii = new float[dimension][dimension]; + for(int i=0; ireplaceZeroWith value instead. + */ + public static float[] inverse(float[] data, float replaceZeroWith){ + float[] inverse = new float[data.length]; + for(int i=0; ilog_A(x) = log(x) / log(A) where + * log is the natural logarithm (base e), and A is the new log base. + * This function expects the values greater than 0.0; No internal checks are done. + * @param base the log base. E.g. to get log2, we would use logToBase(data,2). + */ + public static float[] logToBase(float[] data, float base){ + float[] log = new float[data.length]; + double logBase = Math.log(base); + for(int i=0; istart (inclusive) to end (inclusive): + * y[0] = start; y[1] = start+1; ... , y[n] = end;. + *
    + * For example, int[] ii = linspace(2,5); + * produces the array ii = {2,3,4,5}; with length 4. + *

    +	 * It is similar to this:
    +	 * 
    +	 * for(int i=0; i<=end-start+1; i++){
    +	 * 
        y[i] = i + start; + *
    } + *
    + *
    + * @param start the start index (inclusive) + * @param end the end index (inclusive); + */ + public static int[] linspace(int start, int end){ + int[] indices = new int[end-start+1]; + for(int i=0; i + * + * @return mapped data array + */ + public static float map(float data, float low1, float high1, float low2, float high2){ + return low2 + (data-low1) * (high2-low2) / (high1-low1); + } + + /** + * Similar to map([] value, valueArrayMinimum, valueArrayMaximum, from, to) + * @return mapped data array + */ + public static float[] map(float[] data, float from, float to){ + return map( data, Descriptive.min(data), Descriptive.max(data), from, to); + } + + /** + * Function for mapping an input array of floats for plotting + * Extends processing "map" function to accomodate + * arrays. E.g. map(value, low1, high1, low2, high2) + * is now + * map([] value, low1, high1, low2, high2) + * @return mapped data array + */ + public static float[] map(float[] data, float low1, float high1, float low2, float high2){ + float[] mappedData = new float[data.length]; + float ratio; + if( high1 == low1 ){ + System.out.println("Input array range is zero. Returning original array"); + return data; + } + else{ + ratio = (high2-low2)/(high1-low1); + for(int i=0; i z[i] = x[i] * y[i]. + */ + public static float[] multiply(float[] data1, float[] data2){ + int size = data1.length; + Check.equalLengths(size,data2); + float[] multiplied = new float[size]; + for(int i=0; i z[i] = k * x[i] . + */ + public static float[] multiply(float[] data, float number){ + float[] multiplied = new float[data.length]; + + for(int i=0; i + * y[0] = fullDataset[ indices[0] ]; + * y[1] = fullDataset[ indices[1] ]; + * ... + * ... + * y[n-1] = fullDataset[ indices[n-1] ]; + * + * @param indices the indices in the fullDataset you want to extract and store. + * @param fullDataset the full dataset. + */ + public static double[] populate( double[] fullDataset, int[] indices) { + double[] outputDat = new double[indices.length]; + for (int i=0; i + * y[0] = fullDataset[ indices[0] ]; + * y[1] = fullDataset[ indices[1] ]; + * ... + * ... + * y[n-1] = fullDataset[ indices[n-1] ]; + * + * @param indices the indices in the fullDataset you want to extract and store. + * @param fullDataset the full dataset. + */ + public static float[] populate( float[] fullDataset, int[] indices) { + float[] outputDat = new float[indices.length]; + for (int i=0; i + * y[0] = fullDataset[ indices[0] ]; + * y[1] = fullDataset[ indices[1] ]; + * ... + * ... + * y[n-1] = fullDataset[ indices[n-1] ]; + * + * @param indices the indices in the fullDataset you want to extract and store. + * @param fullDataset the full dataset. + */ + public static int[] populate( int[] fullDataset, int[] indices) { + int[] outputDat = new int[indices.length]; + for (int i=0; i + * y[0] = fullDataset[ indices[0] ]; + * y[1] = fullDataset[ indices[1] ]; + * ... + * ... + * y[n-1] = fullDataset[ indices[n-1] ]; + * + * @param indices the indices in the fullDataset you want to extract and store. + * @param fullDataset the full dataset. + */ + public static String[] populate(String[] fullDataset, int[] indices){ + String[] outputDat = new String[indices.length]; + for (int i=0; iprint, + * except that the entire array is printed on a single line on the screen and + * you can format the number of decimal digits directly instead of using Processing's + * nf or one of the other variants of it. + * @param data the matrix to be printed. + * @param d Number of digits after the decimal to display.. + */ + public static void print(double[] data, int d) { + if(d<0) throw new IllegalArgumentException("Can't display "+d+" decimal digits without recreating" + + "the number system."); + int numColumns = data.length; + // number format + DecimalFormat format = setupFormat(d); + for (int j=0; jprintln, except that + * each row of the matrix is printed on a single line on the screen and + * you can format the number of decimal digits directly instead of using Processing's + * nf or one of the other variants of it. + * @param data the matrix to be printed. + * @param d Number of digits after the decimal to display.. + */ + public static void print(double[][] data, int d) { + if(d<0) throw new IllegalArgumentException("Can't display "+d+" decimal digits without recreating" + + "the number system."); + int numRows = data.length; + // number format + DecimalFormat format = setupFormat(d); + for (int i=0; iprint, + * except that the entire array is printed on a single line on the screen and + * you can format the number of decimal digits directly instead of using Processing's + * nf or one of the other variants of it. + * @param data the matrix to be printed. + * @param d Number of digits after the decimal to display.. + */ + public static void print(float[] data, int d) { + if(d<0) throw new IllegalArgumentException("Can't display "+d+" decimal digits without recreating" + + "the number system."); + int numColumns = data.length; + // number format + DecimalFormat format = setupFormat(d); + for (int j=0; jprintln, except that + * each row of the matrix is printed on a single line on the screen and + * you can format the number of decimal digits directly instead of using Processing's + * nf or one of the other variants of it. + * @param data the matrix to be printed. + * @param d Number of digits after the decimal to display.. + */ + public static void print(float[][] data, int d) { + if(d<0) throw new IllegalArgumentException("Can't display "+d+" decimal digits without recreating" + + "the number system."); + int numRows = data.length; + // number format + DecimalFormat format = setupFormat(d); + for (int i=0; iprint, + * except that the entire array is printed on a single line on the screen and + * you can format the number of decimal digits directly instead of using Processing's + * nf or one of the other variants of it. + * @param data the matrix to be printed. + * @param d Number of digits after the decimal to display.. + */ + public static void print(int[] data, int d) { + if(d<0) throw new IllegalArgumentException("Can't display "+d+" decimal digits without recreating" + + "the number system."); + int numColumns = data.length; + // number format + DecimalFormat format = setupFormat(d); + for (int j=0; jprintln, except that + * each row of the matrix is printed on a single line on the screen and + * you can format the number of decimal digits directly instead of using Processing's + * nf or one of the other variants of it. + * @param data the matrix to be printed. + * @param d Number of digits after the decimal to display.. + */ + public static void print(int[][] data, int d) { + if(d<0) throw new IllegalArgumentException("Can't display "+d+" decimal digits without recreating" + + "the number system."); + int numRows = data.length; + // number format + DecimalFormat format = setupFormat(d); + for (int i=0; ioldValue with + * the newValue. Useful, for example, in replacing zeros with + * some other number (for {@link dotDivide(float[][], float[][])}), or for wall-street related book-keeping... + */ + public static float[][] replace(float[][] A, float oldValue, float newValue){ + int numRows = A.length; + int numColumns = A[0].length; + float[][] C = new float[numRows][numColumns]; + for(int i=0; ioldValue are replaced with + * the newValue. Useful, for example, in replacing zeros with + * some other number (for {@link divide(float[], float[])}), or for wall-street related book-keeping... + */ + public static float[] replace(float[] data, float oldValue, float newValue){ + int numRows = data.length; + float[]C = new float[numRows]; + for(int i=0; iOnly works if the input number has got more decimal places than the + * number to round to. + *

    + * Examples: + *
    roundToDecimalPlace(1.234567, 2) --> 1.23; + *
    roundToDecimalPlace(100, 2) --> 100; + *

    + * @param number number to round. + * @param decimal decimal place to round to. + * @return number rounded to the specified decimal place + */ + public static float roundToDecimalPlace(float number, int decimal) { + return (float) ( (Math.round((number*Math.pow(10, decimal))))/Math.pow(10, decimal) ); + } + protected static DecimalFormat setupFormat(int d){ + DecimalFormat format = new DecimalFormat(); + format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); + format.setMinimumIntegerDigits(1); + format.setMaximumFractionDigits(d); + format.setMinimumFractionDigits(d); + format.setGroupingUsed(false); + return format; + } + + /** + * Function for flooring a number to the closest interval. Useful for + * setting up the tick labels for plotting. + *

    + * Examples: + *
    floorToNearest(173.2,5) --> 170; + *
    floorToNearest(28,10) --> 20; + *

    + * @param currentVal number to floor. + * @param interval to floor to. E.g. in fives, twos, tens, etc. + * @return number. + */ + public static float floorToNearest(float currentVal, int interval){ + return (float)(Math.floor(currentVal/interval)*interval); + } + /** + * Function for ceiling a number to the closest interval. Useful for + * setting up the tick labels for plotting. + *

    + * Examples: + *
    ceilToNearest(173.2,5) --> 175; + *
    ceilToNearest(28,10) --> 30; + *

    + * @param currentVal number to ceil. + * @param interval to ceil to. E.g. in fives, twos, tens, etc. + * @return number. + */ + public static float ceilToNearest(float currentVal, int interval){ + return (float)(Math.ceil(currentVal/interval)*interval); + } + + /** + * Splits (partitions) an array into sublists such that each sublist contains the elements with a given range. + * splitters=(a,b,c,...,y,z) defines the ranges [-inf,a), [a,b), [b,c), ..., [y,z), [z,inf]. + *

    Examples:
    + *

      + * data = (1,2,3,4,5,8,8,8,10,11). + *
      splitters=(2,8) yields 3 bins: (1), (2,3,4,5) (8,8,8,10,11). + *
      splitters=() yields 1 bin: (1,2,3,4,5,8,8,8,10,11). + *
      splitters=(-5) yields 2 bins: (), (1,2,3,4,5,8,8,8,10,11). + *
      splitters=(100) yields 2 bins: (1,2,3,4,5,8,8,8,10,11), (). + *
    + * @param sortedList the list to be partitioned (must be sorted ascending). + * @param splitters the points at which the list shall be partitioned (must be sorted ascending). + * @return the sublists (an array with length == splitters.length + 1. + * Each sublist is returned sorted ascending. + */ + public static ArrayList[] split(float[] sortedList, float[] splitters) { + // assertion: data is sorted ascending. + // assertion: splitValues is sorted ascending. + int numBins = splitters.length + 1; + + ArrayList[] bins = new ArrayList[numBins]; + for (int i=numBins; --i >= 0;) bins[i] = new ArrayList(); + + int listSize = sortedList.length; + int nextStart = 0; + int i=0; + while (nextStart < listSize && i < numBins-1) { + float splitValue = splitters[i]; + int index = Arrays.binarySearch( sortedList,splitValue ); + if (index < 0) { // splitValue not found + int insertionPosition = -index - 1; + addAllOfFromTo(bins[i], sortedList, nextStart,insertionPosition-1); + nextStart = insertionPosition; + } + else { // splitValue found + // For multiple identical elements ("runs"), binarySearch does not define which of all valid indexes is returned. + // Thus, skip over to the first element of a run. + do { + index--; + } while (index >= 0 && sortedList[index] == splitValue); + + addAllOfFromTo(bins[i], sortedList, nextStart, index); + nextStart = index + 1; + } + i++; + } + // now fill the remainder + addAllOfFromTo(bins[numBins-1] , sortedList, nextStart,sortedList.length-1); + return bins; + } + + /** + * Get a (2D) submatrix of a (2D) matrix (a copy, not a pointer). + * @param inputMat input matrix + * @param rowStart row to start at (inclusive) + * @param rowEnd row to end at (inclusive) + * @param columnStart column to start at (inclusive) + * @param columnEnd column to end at (inclusive) + * @return submatrix containing (rowEnd-rowStart+1) rows and (columnEnd-columnStart+1) columns; + * copy of A(rowStart:rowEnd, columnStart:columnEnd). + * @throws IllegalArgumentException if the rowStart, rowEnd, columnStart, or columnEnd parameters + * are not within the inputMatrix size bounds. + */ + public static float[][] subMatrix(float[][] inputMat, int rowStart, int rowEnd, int columnStart, int columnEnd) { + int numRows = rowEnd-rowStart+1; + int numColumns = columnEnd-columnStart+1; + if(numRows>inputMat.length || rowStart<0 || rowEnd>inputMat.length-1) throw new IllegalArgumentException("Row indices are not within the matrix bounds"); + if(numColumns>inputMat[0].length || columnStart<0 || columnEnd>inputMat[0].length-1) throw new IllegalArgumentException("Column indices are not within the matrix bounds"); + float[][] outputMat = new float[numRows][numColumns]; + + for (int i = 0; iA(rowIndices(:), columnStart:columnEnd). + * @throws IllegalArgumentException if the inputs are not within the inputMatrix size bounds. + */ + public static float[][] subMatrix(float[][] inputMat, int[] rowIndices, int columnStart, int columnEnd) { + int numRows = rowIndices.length; + int numColumns = columnEnd-columnStart+1; + if(numRows>inputMat.length) throw new IllegalArgumentException("Row indices are not within the matrix bounds"); + if(numColumns>inputMat[0].length || columnStart<0 || columnEnd>inputMat[0].length-1) throw new IllegalArgumentException("Column indices are not within the matrix bounds"); + float[][] outputMat = new float[numRows][numColumns]; + for (int i = 0; iA(rowIndices(:), columnStart:columnEnd). + * @throws IllegalArgumentException if the inputs are not within the inputMatrix size bounds. + */ + public static float[][] subMatrix(float[][] inputMat, int rowStart, int rowEnd, int[] columnIndices) { + int numRows = rowEnd-rowStart+1; + int numColumns = columnIndices.length; + if(numRows>inputMat.length || rowStart<0 || rowEnd>inputMat.length-1) throw new IllegalArgumentException("Row indices are not within the matrix bounds"); + if(numColumns>inputMat[0].length) throw new IllegalArgumentException("Column indices are not within the matrix bounds"); + float[][] outputMat = new float[numRows][numColumns]; + for (int i = 0; iA(rowIndices(:), columnStart:columnEnd). + * @throws IllegalArgumentException if the inputs are not within the inputMatrix size bounds. + */ + public static float[][] subMatrix(float[][] inputMat, int[] rowIndices, int[] columnIndices) { + int numRows = rowIndices.length; + int numColumns = columnIndices.length; + if(numRows>inputMat.length) + throw new IllegalArgumentException("Row indices are not within the matrix bounds. Num Rows = "+numRows+", inputMat.length = "+inputMat.length); + if(numColumns>inputMat[0].length) + throw new IllegalArgumentException("Column indices are not within the matrix bounds. Num Columns = "+numColumns+", inputMat[0].length = "+inputMat[0].length); + float[][] outputMat = new float[numRows][numColumns]; + for (int i = 0; iinputMat.length) + throw new IllegalArgumentException("Row indices are not within the matrix bounds. Num Rows = "+numRows+", inputMat.length = "+inputMat.length); + if(numColumns>inputMat[0].length) + throw new IllegalArgumentException("Column indices are not within the matrix bounds. Num Columns = "+numColumns+", inputMat[0].length = "+inputMat[0].length); + int[][] outputMat = new int[numRows][numColumns]; + for (int i = 0; iSum( data[i] ). + */ + public static float sum(float[] data) { + float sum = data[0]; + for (int i = 1; i < data.length; i++) sum += data[i]; + return sum; + //return sumOfPowerDeviations(data,1,0.0f); + } + /** + * Returns the sum of two data sequences. + * That is Sum( data[i] ). + */ + public static float[] sum(float[] data1, float[] data2) { + int size = data1.length; + Check.equalLengths(size,data2); + float[] sum = new float[size]; + for (int i = 0; i < data1.length; i++) sum[i] = data1[i] + data2[i]; + return sum; + } + + /** + * Sum of an array with a number. That is + * Sum( data[i] + number). + * + * @return array with each element equal to data[i] + number + */ + public static float[] sum(float[] data, float number) { + float[] sum = new float[data.length]; + for (int i = 0; i < data.length; i++) sum[i] = data[i] + number; + return sum; + } + + /** + * Returns the sum of a data sequence. + * That is Sum( data[i] ). + */ + public static int sum(int[] data) { + int sum = data[0]; + for (int i = 1; i < data.length; i++) sum += data[i]; + return sum; + //return sumOfPowerDeviations(data,1,0.0f); + } + /** + * Returns the sum of two data sequences. + * That is Sum( data[i] ). + */ + public static int[] sum(int[] data1, int[] data2) { + int size = data1.length; + Check.equalLengths(size,data2); + int[] sum = new int[size]; + for (int i = 0; i < data1.length; i++) sum[i] = data1[i] + data2[i]; + return sum; + } + + /** + * Sum of an array with a number. That is + * Sum( data[i] + number). + * + * @return array with each element equal to data[i] + number + */ + public static int[] sum(int[] data,int number) { + int[] sum = new int[data.length]; + for (int i = 0; i < data.length; i++) sum[i] = data[i] + number; + return sum; + } + + /** + * Returns the matrix z = x+y where each element of z[i][j] = x[i][j] + y[i][j] + */ + public static float[][] sum(float[][] x, float[][] y) { + int numRows = x.length, numColumns = x[0].length; + //Check.equalLengths(numRows,y.length); + float[][] z = new float[numRows][]; + for (int i = 0; i < numRows; i++) { + z[i] = sum(x[i],y[i]); + } + return z; + } + /** + * Swap function that swaps the values in an array + * @param data is an array of floats + * @param oldIndex + * @param newIndex + * e.g. data[newIndex,oldIndex] = data[oldIndex,newIndex] + */ + public static void swap(float[] data, int oldIndex, int newIndex){ + float tmp = data[oldIndex]; + data[oldIndex] = data[newIndex]; + data[newIndex] = tmp; + } + /** + * Swap function that swaps the values in an array (overload function) + * @param data is an array of integers + * @param oldIndex + * @param newIndex + * e.g. data[newIndex,oldIndex] = data[oldIndex,newIndex] + */ + public static void swap(int[] data, int oldIndex, int newIndex){ + int tmp = data[oldIndex]; + data[oldIndex] = data[newIndex]; + data[newIndex] = tmp; + } + + /** Returns the symmetric part of the input matrix ((A+A')/2).*/ + public static float[][] symmetric(float[][] data ){ + Check.square(data); + int size = data.length; + float[][] symm = new float[size][size]; + for(int c=0; c min ≤ number ≤ max). + * @param min left-most limit (inclusive) + * @param max right-most limit (inclusive) + * @param number the value to check for. + * @return true if the number is within the bounds, else false + */ + public static boolean within(float number, float min, float max) { + if (number>=min && number<=max) return true; + else return false; + } + + /** + * returns an array containing all numbers within the min and max (inclusive). + * If nothing is within the min and max, an array of length 1 with the first element = -1 is returned + */ + public static float[] within(float[] numbers, float min, float max) { + ArrayList arrayWithin = new ArrayList(); + for(int i=0; i0) return Cast.arrayListToFloat(arrayWithin); + else return new float[]{-1}; + } + +} \ No newline at end of file diff --git a/drawing/papaya/src/papaya/NaNs.java b/drawing/papaya/src/papaya/NaNs.java new file mode 100644 index 0000000..246eca4 --- /dev/null +++ b/drawing/papaya/src/papaya/NaNs.java @@ -0,0 +1,288 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.util.ArrayList; + +import processing.core.*; + +/** + *

    Contains various methods for dealing with NaNs in your data.

    + * Currently only accommodates float and double arrays. Java's Integer.isNaN doesn't + * seem to exist or I'd include that as well. + * + * @author Adila Faruk + * + */ +public final class NaNs { + + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected NaNs(){} + + + /** + * Eliminate the NaNs from the input array. + * + * @param data the array containing NaNs + * @return the new array (with length < data.length) devoid + * of NaNs. + */ + public static double[] eliminate(double[] data){ + double[] data2 = new double[data.length]; + int j=0; + for(int i=0; idata[i] is NaN. + * + * @param data array to search for NaNs + * @return list of indexes i such that data[i] = NaN + */ + public static ArrayList getNaNPositions(double[] data) { + ArrayList out = new ArrayList(); + for (int i = 0; i < data.length; i++) { + if (Double.isNaN(data[i])) { + out.add(Integer.valueOf(i)); + } + } + return out; + } + + + /** + * Eliminate the NaNs from the input array. + * + * @param data the array containing NaNs + * @return the new array (with length < data.length) devoid + * of NaNs. + */ + public static float[] eliminate(float[] data){ + float[] data2 = new float[data.length]; + int j=0; + for(int i=0; idata[i] is NaN. + * + * @param data array to search for NaNs + * @return list of indexes i such that data[i] = NaN + */ + public static ArrayList getNaNPositions(float[] data) { + ArrayList out = new ArrayList(); + for (int i = 0; i < data.length; i++) { + if (Float.isNaN(data[i])) { + out.add(Integer.valueOf(i)); + } + } + return out; + } + +} + +///** +// * Eliminate the NaNs from the input array. +// * +// * @param data the array containing NaNs +// * @return the new array (with length < data.length) devoid +// * of NaNs. +// */ +//public static int[] eliminate(int[] data){ +// int[] data2 = new int[data.length]; +// int j=0; +// for(int i=0; idata[i] is NaN. +// * +// * @param data array to search for NaNs +// * @return list of indexes i such that data[i] = NaN +// */ +//public static ArrayList getNaNPositions(int[] data) { +// ArrayList out = new ArrayList(); +// for (int i = 0; i < data.length; i++) { +// if (Integer.isNaN(data[i])) { +// out.add(Integer.valueOf(i)); +// } +// } +// return out; +//} \ No newline at end of file diff --git a/drawing/papaya/src/papaya/Normality.java b/drawing/papaya/src/papaya/Normality.java new file mode 100644 index 0000000..2506543 --- /dev/null +++ b/drawing/papaya/src/papaya/Normality.java @@ -0,0 +1,282 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.util.*; +import java.io.*; +import processing.core.*; +/** + * Contains various utilities for checking if the dataset comes from a normal distribution. + */ + +public class Normality implements PapayaConstants { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Normality(){} + protected static void checkLength20(int size){ + if(size<20) throw new IllegalArgumentException("Dataset contains "+size+" elements which is" + + "less than the minimum of 20."); + } + + /** + * Return the Normal order statistic medians (N) necessary to produce a Q-Q plot + * for a normal distribution (or normal probability plot). + * That is, given a data array, this method computes the Normal order statistic medians + * and the ordered response values or z-scores of the input. + * A plot of the N vs z should form an approximate straight line if the + * data is normally distributed; + * departures from this straight line indicate departures from normality with the shape of the line + * providing clues as to the distribution of the data. + *

    + * The normal order statistic medians are computed as + *
    N[i] = Probability.norminv(U[i]) + * where U[i] are the uniform order statistic medians, given by + *

      + *
      U[i] = 1 - U(n) for i = 1 + *
      U[i] = (i - 0.3175)/(n + 0.365) for i = 2, 3, ..., n-1 + *
      U[i] = 0.5^(1/n) for i = n + *
    + *

    Reference: + * NIST/SEMATECH e-Handbook of Statistical Methods, EDA Section 1.3.3.21: Normal Probability Plots + * @param data the data array + * @return the Normal order statistic medians + * @see Descriptive#zScore(float[],float,float) + */ + public static float[] normalProbability(float[] data){ + int size = data.length; + float[] N = new float[size]; + double factor = (double)1/size; + double U = Math.pow(.5,factor); // U_n + N[0] = (float)Probability.norminv(1-U); + N[size-1] = (float)Probability.norminv(U); + //U(i) = (i - 0.3175)/(n + 0.365) for i = 2, 3, ..., n-1 + for(int i=1; iImplementation: + * + *
    Let mk denote the kth moment, + * mk = ∑_(i=1 to n)(x_i - mean(x))/n. Then, we can define the following: + *
    Sample estimate of the third standardized moment: b1 = m3/(m2)^(3/2)
    + *
    Sample estimate of the fourth standardized moment: b2 = m4/m2
    + *
    The test statistics Z(b1), Z(b2) are approximately normally distributed under + * the null hypothesis of population normality. Both Z(b1) and Z(b2) can be used to + * test one-sided and two-sided alternative hypothesis. + * + *

    + * D'Agostino and Pearson (1973) also introduced the following "omnibus" test statistic, + *
    K^2 = (Z(b1))^2 + (Z(b2))^2,
    + * which is able to detect deviations from normality due to either skewness or kurtosis + * This K^2 statistic has an approximately Chi-Squared distribution with 2 degrees of + * freedom when the population is normally distributed. + * Similar to Z(b1) and Z(b2), K^2 can be used to test one-sided and two-sided alternative hypothesis. + * + *

    Requirements + *
    data set has to have more than 20 elements. An error is thrown otherwise since the normal + * approximation is no longer valid (technically, the it is valid for Zb1, as long as n > 8, but + * since we're computing everything, the requirement has been set a little higher. + * + *

    Remarks: + *

      + *
    • + * The normal approximation for the zb1 is only valid for sample sizes > 8. For smaller sample sizes, + * it is suggested that you consult a look-up table. Likewise, the normal approximation for the + *
    • + * b1 and b2 differ from the Fisher g statistic parameters g1 + * and g2 used in SAS, and SPSS but they are related by a linear transformation (see + * cited paper for details). + *
    • + * For users familiar with the R software package, this class is analogous to the + * R's dagoTest class in the fBasics library albeit with some implementation. + *
    + *

    + * References: + *
    D'Agostino, R., Albert Belanger, A., D'Agostino Jr, R., 1990 + * A Suggestion for Using Powerful and Informative Tests of Normality + * + *
    D?Agostino, R., Pearson, E., 1973. Tests for departures from normality. + * Empirical results for the distribution of b1 and b2.Biometrika 60, 613?622. + */ + public static class Dago { + + protected Dago(){}; + + /** + * Computes and returns an array containing the test statistic zb1associated with sqrt(b1) and + * the significance, or "p-value" of the skew test statistic zb1, assuming a + * two-tailed null hypothesis as well as . The first element of the output array is the + * test statistic zb1 associated with sqrt(b1) = m3/m2^(3/2) where mk is + * the kth momement as specified in {@link Descriptive#moment} and the second element is + * the p-value for the two-tailed null hypothesis with + *

    +		 * pValueSkew = 2* ( 1-Probability.normcdf( zb1 ) ).
    +		 * 
    + * (D'Agostino et al. (1990)) . + */ + public static float[] skew(float[] data){ + float n = data.length; + checkLength20((int)n); + + float mean = Descriptive.mean(data); + float m2 = Descriptive.moment(data,2,mean); + double sd = Math.sqrt(m2); + double m3 = Descriptive.moment(data,3,mean); + double b1 = m3/(sd*sd*sd); + double y = b1* Math.sqrt( (n+1)*(n+3)/( 6*(n-2) ) ); // standardized b1 + // standardized moment + double beta2 = 3*(n*n+27*n-70)*(n+1)*(n+3)/ ( (n-2)*(n+5)*(n+7)*(n+9) ); + double Wsquared = -1 + Math.sqrt(2*(beta2-1)); + double W = Math.sqrt(Wsquared); + double delta = 1/Math.sqrt(Math.log(W)); + double alpha = Math.sqrt(2/(Wsquared-1)); + double yalpha = y/alpha; + double Zb1 = (delta*Math.log(yalpha + Math.sqrt(yalpha*yalpha+1))); + + return new float[]{(float)Zb1,(float)twoTailedNormal(Zb1)}; + } + + /** + * Computes and returns an array containing the test statistic zb2associated with + * b2 and the significance, or "p-value" of the kurtosis test statistic zb2, assuming a + * two-tailed null hypothesis as well as . The first element of the output array is the + * test statistic zb2 associated with b2 = m4/m2^2 where mk is + * the kth momement as specified in {@link Descriptive#moment}. and the second element is + * the p-value for the two-tailed null hypothesis with + *
    +		 * pValueKurtosis = 2* ( 1-Probability.normcdf( zb2 ) ).
    +		 * 
    + * (D'Agostino et al. (1990)) . + */ + public static float[] kurtosis(float[] data){ + float n = data.length; + checkLength20((int)n); + float mean = Descriptive.mean(data); + float m2 = Descriptive.moment(data,2,mean); + double m4 = Descriptive.moment(data,4,mean); + + double b2 = m4/(m2*m2); + double b2Mean = 3*(n-1)/(n+1); + double b2Var = 24*n*(n-2)*(n-3)/( (n+1)*(n+1)*(n+3)*(n+5) ); + double x = (b2-b2Mean)/Math.sqrt(b2Var); + double beta1 = 6*(n*n-5*n+2)/((n+7)*(n+9)) * Math.sqrt( (6*(n+3)*(n+5)) / (n*(n-2)*(n-3)) ); // third standardized moment of b2 + double A = 6+8/beta1* ( 2/beta1 + Math.sqrt(1+ 4/(beta1*beta1)) ); + double nineA = 9*A; + double temp = (1-2/A)/( 1+x*Math.sqrt(2/(A-4)) ); + double Zb2 = ( (1-2/(nineA) - Math.pow (temp,1.0/3.0) )/ Math.sqrt(2/(nineA))); + return new float[]{(float)Zb2,(float)twoTailedNormal(Zb2)}; + } + + /** + * Computes and returns an array containing the test statistic chi2, or the + * "omnibus" test statistic, and the significance, or "p-value" of this test statistic. + * The first element of the output array is the test statistic the ombibus test + * statistic chi2 and the second element is + * the p-value: + *
    +		 * pValueChiSquared = ( 1-Probability.chi2cdf( chi2 ) ).
    +		 * 
    + * (D'Agostino et al. (1990)) . + */ + public static float[] chi2(float[] data){ + float n = data.length; + checkLength20((int)n); + float Zb1 = skew(data)[0]; float Zb2 = kurtosis(data)[0]; + double Ksquared = Zb1*Zb1 + Zb2*Zb2; + float p = (float)( 1-Probability.chi2cdf(Ksquared,2.0) ); + return new float[]{(float)Ksquared,p}; + } + /** + * Returns an array containing the three significance, or p-values, for testing normality. + * The first element corresponds to the p-value associated with D'Agostino's Chi-Squared + * test statistic (or omnibus test, {@link Dago#chi2}), the second corresponds to D'Agostino's + * skew test ({@link Dago#skew}), and the + * third corresponds to D'Agostino's kurtosis test ({@link Dago#kurtosis}). + */ + public static float[] pValues(float[] data){ + float n = data.length; + if(n<20) throw new IllegalArgumentException("Dataset contains "+n+" elements which is" + + "less than the minimum of 20."); + float mean = Descriptive.mean(data); + float m2 = Descriptive.moment(data,2,mean); + double sd = Math.sqrt(m2); + double m3 = Descriptive.moment(data,3,mean); + double m4 = Descriptive.moment(data,4,mean); + double b1 = m3/(sd*sd*sd); + double y = b1* Math.sqrt( (n+1)*(n+3)/( 6*(n-2) ) ); // standardized b1 + // standardized moment + double beta2 = 3*(n*n+27*n-70)*(n+1)*(n+3)/ ( (n-2)*(n+5)*(n+7)*(n+9) ); + double Wsquared = -1 + Math.sqrt(2*(beta2-1)); + double W = Math.sqrt(Wsquared); + double delta = 1/Math.sqrt(Math.log(W)); + double alpha = Math.sqrt(2/(Wsquared-1)); + double yalpha = y/alpha; + double Zb1 = (delta*Math.log(yalpha + Math.sqrt(yalpha*yalpha+1))); + // kurtosis + double b2 = m4/(m2*m2); + double b2Mean = 3*(n-1)/(n+1); + double b2Var = 24*n*(n-2)*(n-3)/( (n+1)*(n+1)*(n+3)*(n+5) ); + double x = (b2-b2Mean)/Math.sqrt(b2Var); + double beta1 = 6*(n*n-5*n+2)/((n+7)*(n+9)) * Math.sqrt( (6*(n+3)*(n+5)) / (n*(n-2)*(n-3)) ); // third standardized moment of b2 + double A = 6+8/beta1* ( 2/beta1 + Math.sqrt(1+ 4/(beta1*beta1)) ); + double nineA = 9*A; + double temp = (1-2/A)/( 1+x*Math.sqrt(2/(A-4)) ); + double Zb2 = ( (1-2/(nineA) - Math.pow (temp,1.0/3.0) )/ Math.sqrt(2/(nineA))); + // omnibus K-squared + double Ksquared = Zb1*Zb1 + Zb2*Zb2; + + float pSkew = (float)twoTailedNormal(Zb1); + float pKurtosis = (float)twoTailedNormal(Zb2); + float pKSquared = (float)( 1-Probability.chi2cdf(Ksquared,2.0) ); + return new float[]{pKSquared,pSkew,pKurtosis}; + } + } + + +private static double twoTailedNormal(double z){ + if(z>0) return ( 2*(1.0- (Probability.normcdf(z)) ) ); + else return (2 * (Probability.normcdf(z))); +} + + +} diff --git a/drawing/papaya/src/papaya/OneWayAnova.java b/drawing/papaya/src/papaya/OneWayAnova.java new file mode 100644 index 0000000..f654ece --- /dev/null +++ b/drawing/papaya/src/papaya/OneWayAnova.java @@ -0,0 +1,196 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.util.*; +import java.io.*; +import processing.core.*; +/** + + * Computes the one-way ANOVA p-value to test the equality of two or more sample + * means by analyzing the sample variances using the test statistic + * F = variance between samples / variance within samples. + * Once initialized, the following values are computed and stored: + *
      + *
    • dfbg: degrees of freedom between the groups ({@link dfbg()}). + *
    • ssbg: sum of squared deviates between the groups ({@link ssbg()}). + *
    • dfwg: degrees of freedom within the groups, or "Error" dfs ({@link dfwg()}). + *
    • sswg: sum of squared deviates within the groups ({@link sswg()}). + *
    • F: the test statistic, computed as (ssbg/dfbg) / (sswg/dfwg) ({@link F()}). + *
    • pValue: the p-value, or significance level, corresponding to a two-tailed + * null hypothesis of no difference between the samples ({@link pValue()}). + *
    + * + *

    Preconditions:

      + *
    • The categoryData Collection must contain + * float[] arrays.
    • + *
    • There must be at least two float[] arrays in the + * categoryData collection and each of these arrays must + * contain at least two values.

    + * + *

    This implementation is based on a description provided in Chapter 13 of the VassarStats + * online textbook + * Mean values are not computed directly in the algorithm as this tends to cause round-off error. + * Rather, we use the more stable SumOfSquares - Sum^2: + *

    + * Sum_(i=1 to n) (x_i - mean(x) )^2 = Sum_(i=1 to n)(x_i)^2 - (Sum_(i=1 to n) x_i)^2/n.
    + * 
    + *

    + * + */ + + +public class OneWayAnova{ + int dfbg = 0; + int dfwg = 0; + double sswg = 0; + double ssbg = 0; + double sst = 0; // total sum of squares + double F = 0; + double p = -1; + /** + * Performs an Analysis of Variance (ANOVA) for a collection of float arrays. + * @param categoryData the data coresponding to the different groups + * @see Collection + */ + public OneWayAnova(Collection categoryData){ + if(categoryData.size()<2)throw new IllegalArgumentException("Input needs to contain at least two float arrays"); + + double totsum = 0; + double totsumsq = 0; + int totnum = 0; + + for (float[] data : categoryData) { + if(data.length<2) throw new IllegalArgumentException("Each float array has to contain at least two elements"); + double sum = 0; + double sumsq = 0; + int num = 0; + + for (int i = 0; i < data.length; i++) { + double val = data[i]; + + double valSquared = val*val; + // within category + num++; + sum += val; + sumsq +=valSquared; + + // for all categories + totnum++; + totsum += val; + totsumsq += valSquared; + } + dfwg += num - 1; // df2 = sum(n_i-1) + double ss = sumsq - sum * sum / num; + sswg += ss; // add the sum of squares to the final tally + } + sst = totsumsq - totsum * totsum/totnum; // total sum of squares + ssbg = sst - sswg; // error sum of squares + dfbg = categoryData.size() - 1; // df1 = k-1 + double msbg = ssbg/dfbg; + double mswg = sswg/dfwg; + F = msbg/mswg; + + p = 1.0 - Probability.fcdf(F,dfbg,dfwg); + } + + /** + * Computes eta^2: a measure of the strength of the curvilinear relationship + * between the independent and dependent variable. Useful in the context of + * one-way ANOVAs of independent samples. For example, the independent + * variable could be the amount of papaya consumed by 4 different groups + * (0, 1, 2, or 3 papayas/dar) and the dependent variable could be a measurement of their + * satisfaction with life. + */ + public float etasqrd(){ + return (float)(ssbg/sst); + } + /** + * Returns the degrees of freedom between groups. That is, + * if there are k groups, dfbg = k-1; + */ + public int dfbg(){ + return dfbg; + + } + + /** + * Returns the degrees of freedom within each group. That is, + * if there are k groups, and each have got n_i elements, + * dfwg = (n_1-1) + (n_2 -1) + ... + (n_k - 1); + */ + public int dfwg(){ + return dfwg; + + } + + /** + * Returns the test statistic F. That is, + *
     
    +     * F = (ssbg/dfbg) / (sswg/dfwg);
    +     * 
    + */ + public float F(){ + return (float)(F); + + } + + /** + * Returns the significance, or "p-value" of the test statistic {@link F()}. + * That is, + *
     
    +     * p = 1 - Probability.fcdf(F,dfbg,dfwg);
    +     * 
    + */ + public float pValue(){ + return (float)(p); + + } + + /** + * Returns the sum of squared deviates of the data within each group. That is, + * if there are k groups, and each have got n_i elements, + *
    +	 * sswg = Sum_(i=1 to n1) (xi1-mean(x1))^2 + Sum_(i=1 to n2) (xi2-mean(xk))^2 + ... + Sum_(i=1 to nk) (xik-mean(xk))^2;
    +	 * 
    + */ + public float sswg(){ + return (float)sswg; + + } + + /** + * Returns the sum of squared deviates between each group. That is, + * if there are k groups, each with mean value y_i, then + *
    +	 * ssbg = Sum_(i=1 to k) (y_i)-mean(y))
    +	 * 
    + */ + public float ssbg(){ + return (float)ssbg; + + } + + +} diff --git a/drawing/papaya/src/papaya/PapayaConstants.java b/drawing/papaya/src/papaya/PapayaConstants.java new file mode 100644 index 0000000..0ce44ad --- /dev/null +++ b/drawing/papaya/src/papaya/PapayaConstants.java @@ -0,0 +1,94 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.awt.event.KeyEvent; + +import processing.core.*; +import processing.core.PApplet; +import processing.core.PFont; +import processing.core.PConstants; + +/** + * PapayaConstants stores some of the constants used in plotting. + * I try to follow processing's conventions where possible + * as specified in processing.core.PConstants + * The Processing Javadoc has more details. + * + */ +public interface PapayaConstants{ + + public final static int BASELINE = 0; + + public final static int CORNER = 0; + + public final static int BOTTOM = 102; + + public final static int CENTER = 3; + + public final static int LEFT = 37; + + public final static int TOP = 101; + + public final static int RIGHT = 39; + + /** + * Default font used. + */ + public final static String FONTNAME = "Helvetica"; + + public final static float[] STROKEWEIGHT ={0.25f, .5f, .75f, 1}; + + public final static int[] GRAY ={100, 150, 200, 240, 250}; + + public final static int[] TEXTSIZE = {6,8,10,12}; + + + /** + * Index to return if a given value/object is not found in the {@link Cast} function. + */ + public static final int INDEX_NOT_FOUND = -1; + + /** + * Index array to return if a given value/object is not found in the {@link Cast} function. + */ + public static final int[] INDICES_NOT_FOUND = new int[]{-1}; + + /** + * machine constants + */ + public static final double MACHEP = 1.11022302462515654042E-16; + public static final double MAXLOG = 7.09782712893383996732E2; + public static final double MINLOG = -7.451332191019412076235E2; + public static final double MAXGAM = 171.624376956302725; + public static final double SQTPI = 2.50662827463100050242E0; + public static final double SQRTH = 7.07106781186547524401E-1; + public static final double LOGPI = 1.14472988584940017414; + + public static final double big = 4.503599627370496e15; + public static final double biginv = 2.22044604925031308085e-16; + +} + diff --git a/drawing/papaya/src/papaya/Polynomial.java b/drawing/papaya/src/papaya/Polynomial.java new file mode 100644 index 0000000..78f3bd6 --- /dev/null +++ b/drawing/papaya/src/papaya/Polynomial.java @@ -0,0 +1,129 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.util.*; +import java.io.*; +import processing.core.*; +import processing.core.PApplet; +import processing.core.PImage; + +/** + * Static Class for casting one variable type to another. + * + * @author Nur Adila Faruk Senan + */ +public final class Polynomial { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Polynomial() {} + + /** + * y = polyval(x,coeff) returns the value of a polynomial of degree n evaluated at x. + * The input argument coeff is an array of length n+1 whose elements are the coefficients + * in descending powers of the polynomial to be evaluated. + *

    + * y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. + *

    + *

    + * E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. + *

    + * @param x argument to the polynomial. + * @param coeff the coefficients of the polynomial. + */ + public static double polyval(double x, double coeff[] ) throws ArithmeticException { + int n = coeff.length; + double ans = coeff[0]; + for(int i=1; i + * y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. + *

    + *

    + * E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. + *

    + * @param x array argument to the polynomial. + * @param coeff the coefficients of the polynomial. + */ + public static double[] polyval(double[] x, double coeff[] ) throws ArithmeticException { + int size = x.length; + double[] y = new double[size]; + for(int i=0; i + * y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. + *

    + *

    + * E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. + *

    + * @param x argument to the polynomial. + * @param coeff the coefficients of the polynomial. + */ + public static float polyval(float x , float coeff[]) throws ArithmeticException { + int n = coeff.length; + float ans = coeff[0]; + for(int i=1; i + * y = coeff[0]*x^n + coeff[1]*x^(n-1) + .... + coeff[n-1]*x + coeff[n]. + *

    + *

    + * E.g. for a quadratic function, y = coeff[0]*x^2 + coeff[1]*x + coeff[2]. + *

    + * @param x array argument to the polynomial. + * @param coeff the coefficients of the polynomial. + */ + public static float[] polyval(float[] x, float coeff[] ) throws ArithmeticException { + int size = x.length; + float[] y = new float[size]; + for(int i=0; i + * Description: + *
    ...cdf signifies the cumulative distribution function and is similar to + * the q... functions in R and the ...cdf functions in + * MATLAB. The cdf represent the integral, from -infinity to 0 of the + * corresponding continuous probability density function (pdf), or, the sum from 0 to x + * of an associated finite pdf.
    + * + *
    ...inv signifies the inverse of the cumulative distribution function and is similar to + * the p... functions in R and the ...inv functions in + * MATLAB.
    + * + *

    Implementation: + *

      + *
    • Direct application examples: + *
      normcdf(1.96) = 0.975 --> 97.5% of the curve is within +/-1.96 of 0. + *
      norminv(0.975) = 1.96 --> finds the point x (=1.96) such that normcdf(x) = .975. + *
      norminv( normcdf(x) ) = x + *
    • Significance tests: + *
      Two-tailed significance test with alpha = 0.05 and H_0: μ=0 + * --> p = 1-alpha/2 = 0.975 + * --> Reject null hypothesis μ=0 if + * the test statistic is greater or less than than +/-1.96 (= +/- norminv(p) ). + * + *
      One-tailed significance test with alpha = 0.05 and H_0: μ < 0 + * --> p = 1-alpha = 0.95 + * --> Reject null hypothesis μ < 0 if + * the test statistic is greater than 1.645 (= norminv(p) ). + *
      One-tailed significance test with alpha = 0.05 and H_0: μ > 0 + * --> p = 1-alpha = 0.95 + * --> Reject null hypothesis μ > 0 if + * the test statistic is less than -1.645 (= -norminv(p) ). + *
    + *

    + * + * + * The code is partially adapted from the CERN Jet Java libraries, which in turn was adapted from the + * Cephes Mathematical Library. As far a as I can tell, Stephen L. Moshier wrote the original C++ code for + * CEPHES (1989, moshier@na-net.ornl.gov), Gedeck (at Novartis) and Wolfgang Hoschek (at CERN, hats off to you mate!) + * then adapted it for the Java platform, making some significant changes along the way. + *
    + * 2012 rolls along, and Adila (hello!) finds the library and makes even more changes, increasing the + * probability (ha.ha.) of things going massively wrong (pValue<.0001). + * + */ + +//public class Probability extends cern.jet.math.Constants { +public class Probability implements PapayaConstants { + /************************************************* + * COEFFICIENTS FOR METHOD normalInverse() * + *************************************************/ + /* approximation for 0 <= |y - 0.5| <= 3/8 */ + protected static final double P0[] = { + -5.99633501014107895267E1, + 9.80010754185999661536E1, + -5.66762857469070293439E1, + 1.39312609387279679503E1, + -1.23916583867381258016E0, + }; + protected static final double Q0[] = { + 1.00000000000000000000E0, + 1.95448858338141759834E0, + 4.67627912898881538453E0, + 8.63602421390890590575E1, + -2.25462687854119370527E2, + 2.00260212380060660359E2, + -8.20372256168333339912E1, + 1.59056225126211695515E1, + -1.18331621121330003142E0, + }; + + + /* Approximation for interval z = sqrt(-2 log y ) for z between 2 and 8 + * i.e., y between exp(-2) = .135 and exp(-32) = 1.27e-14. + */ + protected static final double P1[] = { + 4.05544892305962419923E0, + 3.15251094599893866154E1, + 5.71628192246421288162E1, + 4.40805073893200834700E1, + 1.46849561928858024014E1, + 2.18663306850790267539E0, + -1.40256079171354495875E-1, + -3.50424626827848203418E-2, + -8.57456785154685413611E-4, + }; + protected static final double Q1[] = { + 1.00000000000000000000E0, + 1.57799883256466749731E1, + 4.53907635128879210584E1, + 4.13172038254672030440E1, + 1.50425385692907503408E1, + 2.50464946208309415979E0, + -1.42182922854787788574E-1, + -3.80806407691578277194E-2, + -9.33259480895457427372E-4, + }; + + /* Approximation for interval z = sqrt(-2 log y ) between 8 and 64 + * i.e., y between exp(-32) = 1.27e-14 and exp(-2048) = 3.67e-890. + */ + protected static final double P2[] = { + 3.23774891776946035970E0, + 6.91522889068984211695E0, + 3.93881025292474443415E0, + 1.33303460815807542389E0, + 2.01485389549179081538E-1, + 1.23716634817820021358E-2, + 3.01581553508235416007E-4, + 2.65806974686737550832E-6, + 6.23974539184983293730E-9, + }; + protected static final double Q2[] = { + 1.00000000000000000000E0, + 6.02427039364742014255E0, + 3.67983563856160859403E0, + 1.37702099489081330271E0, + 2.16236993594496635890E-1, + 1.34204006088543189037E-2, + 3.28014464682127739104E-4, + 2.89247864745380683936E-6, + 6.79019408009981274425E-9, + }; + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Probability() {} + /** + * Returns the area from zero to x under the beta density + * function. + *
    +	 * 
    +	 * P(x) = Γ(a+b) / [ Γ(a) * Γ(b)  ] * Integral_(0 to x) [  t^(a-1) * (1-t)^(b-1) ] dt
    +	 *
    +	 * 
    + * This function is identical to the incomplete beta + * integral function + * + * Gamma.incompleteBeta(a, b, x). + * + * The complemented function is {@link betacdfComplemented}, specified by + * + * 1 - P(1-x) = Gamma.incompleteBeta( b, a, x ); + * + */ + static public double betacdf(double x, double a, double b) { + return Gamma.incompleteBeta( a, b, x ); + } + /** + * Returns the area under the right hand tail (from x to + * infinity) of the beta density function. + * + * This function is identical to the incomplete beta + * integral function Gamma.incompleteBeta(b, a, x). + */ + static public double betacdfComplemented(double x, double a, double b ) { + return Gamma.incompleteBeta( b, a, x ); + } + + /** + * Returns the inverse of the beta cumulative distribution function. + * That is, given p, the function finds x such that + *
    +	 *  Gamma.incompleteBeta( a, b, x ) = beta(x, a, b) = p;
    +	 *
    + * + * This function is identical to the incomplete beta inverse + * function Gamma.incompleteBetaInverse(aa, bb, yy0). + * + * @param a the alpha parameter of the beta distribution. + * @param b the beta parameter of the beta distribution. + * @param p the value for which to solve for the corresponding x in the + * incomplete Beta integral. + * @return the value x such that beta( a, b, x ) = p. + */ + static public double betainv( double p, double a, double b) { + return Gamma.incompleteBetaInverse( a, b, p); + } + /** + * Returns the sum of the terms 0 through k of the Binomial + * probability density. + *
    +	 * 
    +	 * Sum_(j=0 to k)  [ (n!)/(j!*(n-j)! ]  *  [ p^j * (1-p)^(n-j) ]
    +	 *
    +	 * 
    + * The terms are not summed directly; instead the incomplete + * beta integral is employed, according to the formula + *

    + * y = binomcdf( p, k, n) = Gamma.incompleteBeta( n-k, k+1, 1-p ). + *

    + * All arguments must be positive, + * @param k end term. + * @param n the number of trials. + * @param p the probability of success (must be in (0.0,1.0)). + */ + static public double binomcdf(double p, int k, int n) { + if( (p < 0.0) || (p > 1.0) ) throw new IllegalArgumentException(); + if( (k < 0) || (n < k) ) throw new IllegalArgumentException(); + + if( k == n ) return( 1.0 ); + if( k == 0 ) return Math.pow( 1.0-p, n-k ); + + return Gamma.incompleteBeta( n-k, k+1, 1.0 - p ); + } + /** + * Returns the sum of the terms k+1 through n of the Binomial + * probability density. + *

    +	 * 
    +	 * Sum_(j=k+1 to n)  [ (n!)/(j!*(n-j)! ]  *  [ p^j * (1-p)^(n-j) ]
    +	 *
    +	 * 
    + * The terms are not summed directly; instead the incomplete + * beta integral is employed, according to the formula + *

    + * y = binomcdfComplemented( p, k, n ) = Gamma.incompleteBeta( k+1, n-k, p ). + *

    + * All arguments must be positive, + * @param k (start-1) term. + * @param n the number of trials. + * @param p the probability of success (must be in (0.0,1.0)). + */ + static public double binomcdfComplemented( double p , int k, int n) { + if( (p < 0.0) || (p > 1.0) ) throw new IllegalArgumentException(); + if( (k < 0) || (n < k) ) throw new IllegalArgumentException(); + + if( k == n ) return( 0.0 ); + if( k == 0 ) return 1.0 - Math.pow( 1.0-p, n-k ); + + return Gamma.incompleteBeta( k+1, n-k, p ); + } + + /** + * Finds the event probability p such that the sum of the + * terms 0 through k of the Binomial probability density + * is equal to the given cumulative probability y. That is, + *

    +	 * binomcdf( p, k, n ) = y;
    +	 *
    + * This is accomplished using the inverse beta integral + * function and the relation + *

    + * 1 - p = Gamma.incompleteBetaInverse( n-k, k+1, y ). + *

    + * All arguments must be positive. + * @param k end term. + * @param n the number of trials. + * @param y the value to solve for such that binomcdf( p, k, n ) = y. + */ + static public double binominv( double y, int k, int n){ + double dk, dn, p; + + if( (y < 0.0) || (y > 1.0) ) throw new IllegalArgumentException("Test statistic not within possible range."); + if( (k < 0) || (n < k) ) throw new IllegalArgumentException(); + + dn = n - k; + if( k == 0 ) + { + if( y > 0.8 ) + p = -Math.expm1( Math.log1p(y-1.0) / dn ); + else + p = 1.0 - Math.pow( y, 1.0/dn ); + } + else + { + dk = k + 1; + p = Gamma.incompleteBeta( dn, dk, 0.5 ); + if( p > 0.5 ) + p = Gamma.incompleteBetaInverse( dk, dn, 1.0-y ); + else + p = 1.0 - Gamma.incompleteBetaInverse( dn, dk, y ); + } + return( p ); + } + + /** + * Returns the area under the left hand tail (from 0 to x) + * of the Chi square probability density function with + * v degrees of freedom. + *
    +	 * 
    +	 * P( x | v ) = 1/ [ 2^(v/2) * Γ(v/2)  ] * Integral_(from 0 to x) [ t^(v/2-1) * e^(-t/2) ] dt
    +	 *                                  
    +	 * 
    + * where x is the Chi-square variable. + *

    + * The incomplete gamma integral is used, according to the + * formula + *

    + * y = chi2cdf( x, v ) = Gamma.incompleteGamma( v/2.0, x/2.0 ). + *

    + * The arguments must both be positive. + * + * @param v degrees of freedom. + * @param x integration end point. + */ + static public double chi2cdf(double x, double v) throws ArithmeticException { + if( x < 0.0 || v < 1.0 ) return 0.0; + + //if(v==2) return 1-Math.exp(x/2.0); // special case. + + return Gamma.incompleteGamma( v/2.0, x/2.0 ); + } + /** + * Returns the area under the right hand tail (from x to + * infinity) of the Chi square probability density function + * with v degrees of freedom. + *

    +	 * 
    +	 * P( x | v ) = 1/ [ 2^(v/2) * Γ(v/2)  ] * Integral_(from x to infinity) [ t^(v/2-1) * e^(-t/2) ] dt
    +	 *
    +	 * 
    + * where x is the Chi-square variable. + * + * The incomplete gamma integral is used, according to the + * formula + * + * y = chi2cdfComplemented( x, v ) = incompleteGammaComplement( v/2.0, x/2.0 ). + * + * The arguments must both be positive. + * + * @param v degrees of freedom. + * @param x integration start point. + */ + static public double chi2cdfComplemented(double x, double v) throws ArithmeticException { + if( x < 0.0 || v < 1.0 ) return 0.0; + return Gamma.incompleteGammaComplement( v/2.0, x/2.0 ); + } + /** + * Returns the error function of the normal distribution. + * The integral is + *
    +	 * 
    +	 * erf(x) = 2/sqrt(PI) * Integral_(0 to x) [ e^(-t^2) ] dt
    +	 *                           
    +	 * 
    + * Implementation: + * For 0 <= |x| < 1, erf(x) = x * P4(x^2)/Q5(x^2) ; otherwise + * erf(x) = 1 - erfc(x). + *

    + * + * @param x the integral end point. + */ + static public double erf(double x) throws ArithmeticException { + double y, z; + final double T[] = { + 9.60497373987051638749E0, + 9.00260197203842689217E1, + 2.23200534594684319226E3, + 7.00332514112805075473E3, + 5.55923013010394962768E4 + }; + final double U[] = { + 1.00000000000000000000E0, + 3.35617141647503099647E1, + 5.21357949780152679795E2, + 4.59432382970980127987E3, + 2.26290000613890934246E4, + 4.92673942608635921086E4 + }; + + if( Math.abs(x) > 1.0 ) return( 1.0 - erfComplemented(x) ); + z = x * x; + y = x * Polynomial.polyval( z, T) / Polynomial.polyval( z, U); + return y; + } + /** + * Returns the complementary Error function of the normal distribution; formerly named erfc. + *

    +	 * 
    +	 *  erfc(x) = 2/sqrt(PI) * Integral_(x to inf) [ e^(-t^2) ] dt
    +	 *  		= 1 - 2/sqrt(PI) * Integral_(0 to x) [ e^(-t^2) ] dt
    +	 *  		= 1 - erf(x).
    +	 *			  
    +	 * 
    + * Implementation: + * For small x, erfc(x) = 1 - erf(x); otherwise rational + * approximations are computed. + *

    + * @param a corresponds to x above. An internal check is performed to see if + * a is < 0 or otherwise. If a < 0 --> x = -a. Else, x = a. + */ + static public double erfComplemented(double a) throws ArithmeticException { + double x,y,z,p,q; + + double P[] = { + 2.46196981473530512524E-10, + 5.64189564831068821977E-1, + 7.46321056442269912687E0, + 4.86371970985681366614E1, + 1.96520832956077098242E2, + 5.26445194995477358631E2, + 9.34528527171957607540E2, + 1.02755188689515710272E3, + 5.57535335369399327526E2 + }; + double Q[] = { + 1.00000000000000000000E0, + 1.32281951154744992508E1, + 8.67072140885989742329E1, + 3.54937778887819891062E2, + 9.75708501743205489753E2, + 1.82390916687909736289E3, + 2.24633760818710981792E3, + 1.65666309194161350182E3, + 5.57535340817727675546E2 + }; + + double R[] = { + 5.64189583547755073984E-1, + 1.27536670759978104416E0, + 5.01905042251180477414E0, + 6.16021097993053585195E0, + 7.40974269950448939160E0, + 2.97886665372100240670E0 + }; + double S[] = { + 1.00000000000000000000E0, + 2.26052863220117276590E0, + 9.39603524938001434673E0, + 1.20489539808096656605E1, + 1.70814450747565897222E1, + 9.60896809063285878198E0, + 3.36907645100081516050E0 + }; + + if( a < 0.0 ) x = -a; + else x = a; + + if( x < 1.0 ) return 1.0 - erf(a); + + z = -a * a; + + if( z < -MAXLOG ) { + if( a < 0 ) return( 2.0 ); + else return( 0.0 ); + } + + z = Math.exp(z); + + if( x < 8.0 ) { + p = Polynomial.polyval( x, P ); + q = Polynomial.polyval( x, Q ); + } else { + p = Polynomial.polyval( x, R); + q = Polynomial.polyval( x, S ); + } + + y = (z * p)/q; + + if( a < 0 ) y = 2.0 - y; + + if( y == 0.0 ) { + if( a < 0 ) return 2.0; + else return( 0.0 ); + } + + return y; + } + /** + * Returns the area from zero to x under the F density + * function (also known as Snedcor's density or the + * variance ratio density); formerly named fdtr. + * Corresponds to the left hand tail of the F-distribution. + * + * The incomplete beta integral is used, according to the formula + *

    +	 *
    +	 * P(x) = Gamma.incompleteBeta( df1/2, df2/2, (df1*x/(df2 + df1*x) ).
    +	 *
    +	 * 
    + * + * @param df1 ( greater than or equal to 1 ) + * @param df2 ( greater than or equal to 1 ) + * @param x the integration end point (greater than or equal to 0). + */ + public static double fcdf( double x, int df1, int df2 ){ + double a, b, w; + + if( (df1 < 1) || (df2 < 1) || x < 0.0 ) throw new IllegalArgumentException("F-distribution domain error."); + a = df1; + b = df2; + w = a * x; + w = w / (b + w); + return Gamma.incompleteBeta(0.5*a, 0.5*b, w); + } + + /** + * Returns the area from x to infinity under the F density + * function (also known as Snedcor's density or the + * variance ratio density); formerly named fdtrc. + * Corresponds to the right hand tail of the F-distribution ( and + * to the values presented in F-distribution tables). + * + * The incomplete beta integral is used, according to the + * relation + *
    +	 * 
    +	 * P(x) = Gamma.incompleteBeta( df2/2, df1/2, (df2/(df2 + df1*x) )
    +	 * 
    +	 * 
    + * + * @param df1 df1 ( greater than or equal to 1 ) + * @param df2 df2 ( greater than or equal to 1 ) + * @param x the left integration point. Corresponds to the F value in look-up tables. + * @return The area from x to inf. under the F density function. + */ + public static double fcdfComplemented(double x, int df1, int df2){ + + double a, b, w; + + if( (df1 < 1) || (df2 < 1) || (x < 0.0) ) throw new IllegalArgumentException("Complementary F-distribution domain error."); + + a = df1; + b = df2; + w = b / (b + a * x); // df1 / (df1 + df2*x) + return Gamma.incompleteBeta( 0.5*b, 0.5*a, w ); + } + + /** + * Finds the F density argument x such that the integral + * from 0 to x of the F density is equal to p; formerly named fdtri. + * That is, it solves for the value of x, given p such that + *
    +	 * fcdf(x,df1,df2) - p = 0.
    +	 * 
    + * + * This is accomplished using the inverse beta integral + * function and the relations + *
    +	 * z = incompleteBetaInverse( df2/2, df1/2, p ),
    +	 * x = 1 - df2 * (1-z) / (df1 z),
    +	 *
    + * if p > Gamma.incompleteBeta( 0.5*df1, 0.5*df2, 0.5 );, or p < 0.001 and, + *
    +	 * z = incompleteBetaInverse( df1/2, df2/2, p ),
    +	 * x = 1 - df2 * z / (df1 (1-z)),
    +	 * 
    + * otherwise. + * The significance level for a one-sided test (or α in look-up tables) is then 1-x + * + * @param df1 degrees of freedom of the first dataset + * @param df2 degrees of freedom of the second dataset + * @param p the fcdf value for which to solve for x + * @return the point x such that fcdf(x,df1,df2) = p. + * @throws IllegalArgumentException if df1 or df2 are less than 1, or p is not in (0,1]. + */ + public static double finv( double p, int df1, int df2){ + double a, b, w, x; + + if( (df1 < 1) || (df2 < 1) || (p <= 0.0) || (p > 1.0) ) + throw new IllegalArgumentException("Domain error in fInverse"); + a = df1; + b = df2; + /* Compute probability for x = 0.5. */ + w = Gamma.incompleteBeta( 0.5*b, 0.5*a, 0.5 ); + /* If that is greater than y, then the solution is in w < .5. + Otherwise, solve at 1-y to remove cancellation in (b - b*w). */ + if( w > p || p < 0.001) + { + /* FComplemented: w = b / (b + a * x); --> x = b(1/w- 1)/a = b*(1-w)/(a*w) */ + w = Gamma.incompleteBetaInverse( 0.5*b, 0.5*a, p ); + x = (b - b*w)/(a*w); + } + else + { + /* F: w = a*x/ (a*x+b) --> solve for x = b*w/(a*(1-w)) + */ + w = Gamma.incompleteBetaInverse( 0.5*a, 0.5*b, 1.0-p );// incbi( 0.5*a, 0.5*b, 1.0-p ); + x = b*w/(a*(1.0-w)); + } + return x; + } + + + /** + * Returns the integral from zero to x of the gamma probability + * density function. + *
    +	 * 
    +	 * y = a^b / Γ(b) * Integral_(0 to x) [ t^(b-1) e^(-a*t) ]dt
    +	 *
    +	 * 
    + * The incomplete gamma integral is used, according to the + * relation + * + * y = Gamma.incompleteGamma( b, a*x ). + * + * @param a the paramater a (alpha) of the gamma distribution. + * @param b the paramater b (beta, lambda) of the gamma distribution. + * @param x integration end point. + * @return y the integral from zero to x of the gamma pdf. + */ + static public double gammacdf( double x, double a, double b ) { + if( x < 0.0 ) return 0.0; + return Gamma.incompleteGamma(b, a*x); + } + /** + * Returns the integral from x to infinity of the gamma + * probability density function: + *
    +	 * 
    +	 * y = a^b / Γ(b) * Integral_(from x to infinity) [t^(b-1) * e^(-a*t) ] dt
    +	 *
    +	 * 
    + * The incomplete gamma integral is used, according to the + * relation + *

    + * y = Gamma.incompleteGammaComplement( b, a*x ). + * + * @param a the paramater a (alpha) of the gamma distribution. + * @param b the paramater b (beta, lambda) of the gamma distribution. + * @param x integration start point. + */ + static public double gammacdfComplemented( double x, double a, double b ) { + if( x < 0.0 ) return 0.0; + return Gamma.incompleteGammaComplement(b, a*x); + } + /** + * Returns the sum of the terms 0 through k of the Negative Binomial Distribution. + *

    +	 * 
    +	 * Sum_(from j=0 to k)  [ (n+j-1)! / ( j! * (n-1)! ) ] * [ p^n* (1-p)^j ]
    +	 *   
    +	 * 
    + * In a sequence of Bernoulli trials, this is the probability + * that k or fewer failures precede the n-th success. + *

    + * The terms are not computed individually; instead the incomplete + * beta integral is employed, according to the formula + *

    + * y = nbinomcdf( p, k, n ) = Gamma.incompleteBeta( n, k+1, p ). + * + * All arguments must be positive, + * @param k end term. + * @param n the number of trials. + * @param p the probability of success (must be in (0.0,1.0)). + */ + static public double nbinomcdf(double p, int k, int n) { + if( (p < 0.0) || (p > 1.0) ) throw new IllegalArgumentException(); + if(k < 0) return 0.0; + + return Gamma.incompleteBeta( n, k+1, p ); + } + /** + * Returns the sum of the terms k+1 to infinity of the Negative + * Binomial distribution. + *

    +	 * 
    +	 * Sum_(from j=k+1 to inf)  [ (n+j-1)! / ( j! * (n-1)! ) ] * [ p^n* (1-p)^j ]
    +	 * 
    +	 * 
    + * The terms are not computed individually; instead the incomplete + * beta integral is employed, according to the formula + *

    + * y = nbinomcdfComplemented( p, k, n ) = Gamma.incompleteBeta( k+1, n, 1-p ). + * + * All arguments must be positive, + * @param k (start-1) term. + * @param n the number of trials. + * @param p the probability of success (must be in (0.0,1.0)). + */ + static public double nbinomcdfComplemented( double p, int k, int n ) { + if( (p < 0.0) || (p > 1.0) ) throw new IllegalArgumentException(); + if(k < 0) return 0.0; + + return Gamma.incompleteBeta( k+1, n, 1.0-p ); + } + /** + * Returns the area under the Normal (Gaussian) probability density + * function, integrated from minus infinity to x (assumes mean is zero, variance is one). + *

    +	 * 
    +	 * normcdf(x) = 1/sqrt(2pi) * Integral_(-inf to x) [ e^(-t^2/2) ] dt
    +	 *           =  ( 1 + erf(z) ) / 2
    +	 *           =  erfc(z) / 2
    +	 *           
    +	 * 
    + * where z = x/sqrt(2). + * Computation is via the functions erf and erfComplement. + *

    + * Relation to alpha value (or confidence level): + *

      + *
      Two tailed test: alpha = 2*( 1-normcdf(x) ).
      + *
      one-tailed test: alpha = ( 1-normcdf(x) ).
      + *
    + *

    + * @param a x in the equation above. + */ + static public double normcdf( double a) throws ArithmeticException { + double x, y, z; + + x = a * SQRTH; + z = Math.abs(x); + + if( z < SQRTH ) y = 0.5 + 0.5 * erf(x); + else { + y = 0.5 * erfComplemented(z); + if( x > 0 ) y = 1.0 - y; + } + + return y; + } + /** + * Returns the area under the Normal (Gaussian) probability density + * function, integrated from minus infinity to x when the + * data has not been standardized (i.e. mean ≠0, variance ≠1). + *
    +	 *  
    +	 * normcdf(x,mean,variance) = 1/sqrt(2pi*v) * Integral_(-inf to x) [ e^(-(t-mean)^2 / 2v) ] dt
    +	 *
    +	 * 
    + * where v = variance. + * Computation is via the functions erf. + * + * @param mean the mean of the normal distribution. + * @param variance the variance of the normal distribution. + * @param x the integration limit. + */ + static public double normcdf(double x, double mean, double variance) throws ArithmeticException { + if (x>0) + return 0.5 + 0.5*erf((x-mean)/Math.sqrt(2.0*variance)); + else + return 0.5 - 0.5*erf((-(x-mean))/Math.sqrt(2.0*variance)); + } + /** + * Returns the value, x, for which the area under the + * Normal (Gaussian) probability density function (integrated from + * minus infinity to x) is equal to the argument y + * (assumes mean is zero, variance is one); formerly named ndtri. + * That is, + *

    + * normcdf(x) = y0. + *

    + *

    + * For small arguments 0 < y < exp(-2), the program computes + * z = sqrt( -2.0 * log(y) ); then the approximation is + * x = z - log(z)/z - (1/z) P(1/z) / Q(1/z). + * There are two rational functions P/Q, one for 0 < y < exp(-32) + * and the other for y up to exp(-2). + * For larger arguments, + * w = y - 0.5, and x/sqrt(2pi) = w + w**3 R(w**2)/S(w**2)). + * Finally, this returns -infinity for y0 = 0 + * and +infinity for y0 = 1. + * + * @param y0 the argument to the function + */ + static public double norminv( double y0) throws ArithmeticException { + double x, y, z, y2, x0, x1; + int code; + + final double s2pi = Math.sqrt(2.0*Math.PI); + + if( y0 < 0.0 ) throw new IllegalArgumentException(); + if( y0 > 1.0 ) throw new IllegalArgumentException(); + if( y0==0.0 )return -Double.NEGATIVE_INFINITY; + if( y0==1.0 )return Double.POSITIVE_INFINITY; + + code = 1; + y = y0; + if( y > (1.0 - 0.13533528323661269189) ) { /* 0.135... = exp(-2) */ + y = 1.0 - y; + code = 0; + } + + if( y > 0.13533528323661269189 ) { + y = y - 0.5; + y2 = y * y; + x = y + y * (y2 * Polynomial.polyval( y2, P0)/Polynomial.polyval( y2, Q0)); + x = x * s2pi; + return(x); + } + + x = Math.sqrt( -2.0 * Math.log(y) ); + x0 = x - Math.log(x)/x; + + z = 1.0/x; + if( x < 8.0 ) /* y > exp(-32) = 1.2664165549e-14 */ + x1 = z * Polynomial.polyval( z, P1 )/Polynomial.polyval( z, Q1 ); + else + x1 = z * Polynomial.polyval( z, P2 )/Polynomial.polyval( z, Q2 ); + x = x0 - x1; + if( code != 0 ) + x = -x; + return( x ); + } + /** + * Returns the sum of the first k terms of the Poisson distribution. + *

    +	 * 
    +	 * Sum_(j=0 to k) [ e^(-m) *  m^j /j! ]
    +	 *
    +	 * 
    + * The terms are not summed directly; instead the incomplete + * gamma integral is employed, according to the relation + *

    + * y = poissoncdf( mean, k m ) = Gamma.incompleteGammaComplement( k+1, mean ). + * + * The arguments must both be positive. + * + * @param k number of terms. + * @param mean the mean of the poisson distribution. + */ + static public double poissoncdf( double mean, int k) throws ArithmeticException { + if( mean < 0 ) throw new IllegalArgumentException(); + if( k < 0 ) return 0.0; + return Gamma.incompleteGammaComplement((double)(k+1) ,mean); + } + /** + * Returns the sum of the terms k+1 to Infinity of the Poisson distribution. + *

    +	 *  
    +	 * Sum_(j=k+1 to inf.) [ e^(-m) *  m^j /j! ]
    +	 * 
    +	 * 
    + * The terms are not summed directly; instead the incomplete + * gamma integral is employed, according to the formula + *

    + * y = poissoncdfComplemented( k, m ) = Gamma.incompleteGamma( k+1, m ). + * + * The arguments must both be positive. + * + * @param k (start-1) term. + * @param mean the mean of the poisson distribution. + */ + static public double poissoncdfComplemented(int k, double mean) throws ArithmeticException { + if( mean < 0.0 ) throw new IllegalArgumentException(); + if( k < -1 ) return 0.0; + return Gamma.incompleteGamma((double)(k+1),mean); + } + /** + * Returns the integral from minus infinity to t of the Student-t + * distribution with k > 0 degrees of freedom. + *

    +	 * 
    +	 * Γ((k+1)/2) / [ sqrt(k*pi) * Γ(k/2)  ] * Integral_(-inf to t) [  ( 1+x^2/k )^( (-k+1)/2 ) ] dx
    +	 * 
    +	 * 
    + * Relation to incomplete beta integral: + *

    + *
    tcdf(t,k) = 0.5 * Gamma.incompleteBeta( k/2, 1/2, z ), when t < 0,
    + *
    tcdf(t,k) = 1-0.5 * Gamma.incompleteBeta( k/2, 1/2, z ), when t > 0,
    + *

    + * where z = k/(k + t^2). + * Relation to alpha value (or confidence level): + *
      + *
      Two tailed test: alpha = 2*( 1-tcdf(t,k) ).
      + *
      one-tailed test: alpha = ( 1-tcdf(t,k) ).
      + *
    + * @param k degrees of freedom. + * @param t integration end point. + */ + static public double tcdf(double t, double k) throws ArithmeticException { + if( k <= 0.0 ) throw new IllegalArgumentException(); + if( t == 0.0 ) return( 0.5 ); + + if( t < 0 ){ + return 0.5 * Gamma.incompleteBeta( 0.5*k, 0.5, k / (k + t * t) ); + } + else { + return 1.0 - 0.5 * Gamma.incompleteBeta( 0.5*k, 0.5, k / (k + t * t) ); + } + } + /** + * Returns the value, t, for which the area under the + * Student-t probability density function (integrated from + * minus infinity to t) is equal to p. + * The function uses the tcdf function to determine the return + * value iteratively. + * + * @param p the fcdf value for which to solve for x + * @param k the degrees of freedom + */ + public static double tinv(double p, double k) { + if(p<0 || p>1) throw new IllegalArgumentException(p + "is not a valid value for p"); + + if(p==.5) return 0; + if(p==0.0) return tcdf(1e-8,k); + if(p==1.0) return tcdf(1-1e-8,k); + + + /* if p is in the left region, correct it. */ + double cumProb = p; // Cumulative probability = 1-alpha/2 + int multiplier = 1; + // Solution lies in the left half of the student-T curve ( t < 0) + // so we solve for the equivalent t-value in the right half, and then + // multiply that by -1. + if(cumProb < .5){ + cumProb = 1-cumProb; + multiplier = -1; + } + + double f1,f2,f3; + double x1,x2,x3; + double g,s12; + + // make a first approximation using the norm-inv function. + x1 = norminv(cumProb); + // Return inverse of normal for large size (k > 30 is pretty sufficient usually). + if (k > 200) { + return x1; + } + + /* Find a pair of x1,x2 that bracket zero to + guarantee asymptotic convergence later on */ + f1 = tcdf(x1,k)-cumProb; + x2 = x1; f2 = f1; + do { + if (f1>0) { + x2 = x2/2; // decrease x2 + } else { + x2 = x2+x1; // increase x2 + } + f2 = tcdf(x2,k)-cumProb; // + } while (f1*f2>0); + + // Find better approximation now that f1 and f2 bracket zero. + // Pegasus-method (also known as the false-position-method or regula-falsi-method) + do { + // Calculate slope of secant and t value for which it is 0. + s12 = (f2-f1)/(x2-x1); + x3 = x2 - f2/s12; + + // Calculate function value at x3 + f3 = tcdf(x3,k)-cumProb; + if (Math.abs(f3)<1e-8) { // This criteria needs to be very tight! + // We found a perfect value -> return + return multiplier*x3; + } + + if (f3*f2<0) { + x1=x2; f1=f2; + x2=x3; f2=f3; + } else { + g = f2/(f2+f3); + f1=g*f1; + x2=x3; f2=f3; + } + } while(Math.abs(x2-x1)>0.001); + + if (Math.abs(f2)<=Math.abs(f1)) { + return multiplier*x2; + } else { + return multiplier*x1; + } + } +} diff --git a/drawing/papaya/src/papaya/QR.java b/drawing/papaya/src/papaya/QR.java new file mode 100644 index 0000000..8fc33db --- /dev/null +++ b/drawing/papaya/src/papaya/QR.java @@ -0,0 +1,296 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +/** QR Decomposition. +

    + For an m-by-n matrix A with m ≥ n, the QR decomposition is an m-by-n + orthogonal matrix Q and an n-by-n upper triangular matrix R so that + A = Q*R. +

    + The QR decompostion always exists, even if the matrix does not have + full rank, so the constructor will never fail. The primary use of the + QR decomposition is in the least squares solution of nonsquare systems + of simultaneous linear equations. This will fail if isFullRank() + returns false. +

    +Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +{@link Cast#doubleToFloat(double[][])} if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). + */ + + + + +public class QR { + /* ------------------------ + Class variables + * ------------------------ */ + + /** Array for internal storage of decomposition. + @serial internal array storage. + */ + private double[][] QR; + + /** Row and column dimensions. + @serial column dimension. + @serial row dimension. + */ + private int m, n; + + /** Array for internal storage of diagonal of R. + @serial diagonal of R. + */ + private double[] Rdiag; + + /* ------------------------ + Constructor + * ------------------------ */ + + /** QR Decomposition, computed by Householder reflections. + * @param A Rectangular matrix + */ + + public QR (float[][] A) { + // Initialize. + QR = Cast.floatToDouble(A); + m = A.length; + n = A[0].length; + Rdiag = new double[n]; + + // Main loop. + for (int k = 0; k < n; k++) { + // Compute 2-norm of k-th column without under/overflow. + double nrm = 0; + for (int i = k; i < m; i++) { + nrm = SVD.hypot(nrm,QR[i][k]); + } + + if (nrm != 0.0) { + // Form k-th Householder vector. + if (QR[k][k] < 0) { + nrm = -nrm; + } + for (int i = k; i < m; i++) { + QR[i][k] /= nrm; + } + QR[k][k] += 1.0; + + // Apply transformation to remaining columns. + for (int j = k+1; j < n; j++) { + double s = 0.0; + for (int i = k; i < m; i++) { + s += QR[i][k]*QR[i][j]; + } + s = -s/QR[k][k]; + for (int i = k; i < m; i++) { + QR[i][j] += s*QR[i][k]; + } + } + } + Rdiag[k] = -nrm; + } + } + + /* ------------------------ + Public Methods + * ------------------------ */ + + /** Is the matrix full rank? + @return true if R, and hence A, has full rank. + */ + + public boolean isFullRank () { + for (int j = 0; j < n; j++) { + if (Rdiag[j] == 0) + return false; + } + return true; + } + + /** Return the Householder vectors + @return Lower trapezoidal matrix whose columns define the reflections + */ + + public double[][] getH () { + double[][] H = new double[m][n]; + for (int i = 0; i < m; i++) { + for (int j = 0; j < n; j++) { + if (i >= j) { + H[i][j] = QR[i][j]; + } else { + H[i][j] = 0.0; + } + } + } + return H; + } + + /** Return the upper triangular factor + @return R + */ + + public double[][] getR () { + double[][] R = new double[n][n]; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (i < j) { + R[i][j] = QR[i][j]; + } else if (i == j) { + R[i][j] = Rdiag[i]; + } else { + R[i][j] = 0.0; + } + } + } + return R; + } + + /** Generate and return the (economy-sized) orthogonal factor + @return Q + */ + + public double[][] getQ () { + double[][] Q = new double[m][n]; + for (int k = n-1; k >= 0; k--) { + for (int i = 0; i < m; i++) { + Q[i][k] = 0.0; + } + Q[k][k] = 1.0; + for (int j = k; j < n; j++) { + if (QR[k][k] != 0) { + double s = 0.0; + for (int i = k; i < m; i++) { + s += QR[i][k]*Q[i][j]; + } + s = -s/QR[k][k]; + for (int i = k; i < m; i++) { + Q[i][j] += s*QR[i][k]; + } + } + } + } + return Q; + } + + /** Least squares solution of A*X = b + @param b An array with the same length as the number of rows in A. + @return x that minimizes the two norm of Q*R*x-b. + @exception IllegalArgumentException Matrix row dimensions must agree. + @exception RuntimeException Matrix is rank deficient. + */ + + public double[] solve (float[] b) { + if (b.length != m) { + throw new IllegalArgumentException("Matrix row dimensions must agree."); + } + if (!this.isFullRank()) { + throw new RuntimeException("Matrix is rank deficient."); + } + + // Copy right hand side + int nx = 1; //B[0].length; + double[] X = Cast.floatToDouble(b); + + // Compute Y = transpose(Q)*B + for (int k = 0; k < n; k++) { + double s = 0.0; + for (int i = k; i < m; i++) { + s += QR[i][k]*X[i]; + } + s = -s/QR[k][k]; + for (int i = k; i < m; i++) { + X[i] += s*QR[i][k]; + } + + } + //Mat.print(Cast.doubleToFloat(X),4); + // Solve R*x = y; + for (int k = n-1; k >= 0; k--) { + X[k] /= Rdiag[k]; + + for (int i = 0; i < k; i++) { + X[i] -= X[k]*QR[i][k]; + + } + } + return X; + + } + + /** Least squares solution of A*X = B + @param B A Matrix with as many rows as A and any number of columns. + @return X that minimizes the two norm of Q*R*X-B. + @exception IllegalArgumentException Matrix row dimensions must agree. + @exception RuntimeException Matrix is rank deficient. + */ + + public double[][] solve (float[][] B) { + if (B.length != m) { + throw new IllegalArgumentException("Matrix row dimensions must agree."); + } + if (!this.isFullRank()) { + throw new RuntimeException("Matrix is rank deficient."); + } + + // Copy right hand side + int nx = B[0].length; + double[][] X = Cast.floatToDouble(B); + + // Compute Y = transpose(Q)*B + for (int k = 0; k < n; k++) { + for (int j = 0; j < nx; j++) { + double s = 0.0; + for (int i = k; i < m; i++) { + s += QR[i][k]*X[i][j]; + } + s = -s/QR[k][k]; + for (int i = k; i < m; i++) { + X[i][j] += s*QR[i][k]; + } + } + } + // Solve R*X = Y; + for (int k = n-1; k >= 0; k--) { + for (int j = 0; j < nx; j++) { + X[k][j] /= Rdiag[k]; + } + for (int i = 0; i < k; i++) { + for (int j = 0; j < nx; j++) { + X[i][j] -= X[k][j]*QR[i][k]; + } + } + } + return X; + } +} + + + + + diff --git a/drawing/papaya/src/papaya/Rank.java b/drawing/papaya/src/papaya/Rank.java new file mode 100644 index 0000000..0628635 --- /dev/null +++ b/drawing/papaya/src/papaya/Rank.java @@ -0,0 +1,618 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.io.*; +import processing.core.*; + +/** + *

    Ranking based on the natural ordering on floats for a sequence of data that may also + * contain NaNs.

    + *

    When present, NaNs are treated according to the configured NaNStrategy constants and ties + * are handled using the configured tiesStrategy constants as follows: + * + *

    Strategies for handling NaN values in rank transformations. + *

      + *
    • 0 (REMOVED, default) - NaNs are removed before the rank transform is applied
    • + *
    • 1 (MINIMAL) - NaNs are treated as minimal in the ordering, equivalent to + * (that is, tied with) Float.NEGATIVE_INFINITY.
    • + *
    • 2 (MAXIMAL) - NaNs are treated as maximal in the ordering, equivalent to + * Float.POSITIVE_INFINITY
    • + *
    • 3 (FIXED) - NaNs are left "in place," that is the rank transformation is + * applied to the other elements in the input array, but the NaN elements + * are returned unchanged.
    • + *
    + *

    + * + *

    Strategies for handling tied values in rank transformations: + *

      + *
    • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + * For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
    • + *
    • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + * of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
    • + *
    • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + * of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
    • + *
    • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + * for example (1,3,4,3) is ranked as (1,2,4,3)
    • +
    + *

    + * + * The defaults are 0 (REMOVED) and 0 (AVERAGE) for the NaNStrategy and TiesStrategy respectively. + * + *

    Examples: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    + * Input data: (20, 17, 30, 42.3, 17, 50, Float.NaN, Float.NEGATIVE_INFINITY, 17) + *
    NaNStrategyTiesStrategyrank(data)
    0 (default = NaNs removed)0 (default = ties averaged)(5, 3, 6, 7, 3, 8, 1, 3)
    0 (default = NaNs removed)1 (MINIMUM)(5, 2, 6, 7, 2, 8, 1, 2)
    1 (MINIMAL)0 (default = ties averaged)(6, 4, 7, 8, 4, 9, 1.5, 1.5, 4)
    1 (MINIMAL)2 (MAXIMUM)(6, 5, 7, 8, 5, 9, 2, 2, 5)
    2 (MAXIMAL)2 (MAXIMUM)/td> + * (5, 4, 6, 7, 4, 8, 9, 1, 4)

    + * + * (Code adapted from the org.apache.commons.math.stat.ranking package, and modified extensively). + */ +public class Rank { + + // NaNs ---------------------------------------- + /** NaNs are removed before computing ranks. Corresponds to default */ + private static final int REMOVED = 0; + + /** NaNs are considered maximal in the ordering */ + private static final int MINIMAL = 1; + + /** NaNs are considered minimal in the ordering */ + private static final int MAXIMAL = 2; + + /** NaNs are left in place */ + private static final int FIXED = 3; + + + // TIES ---------------------------------------- + /** Ties get the average of applicable ranks. Corresponds to default */ + private static final int AVERAGE = 0; + + /** Ties get the minimum applicable rank */ + private static final int MINIMUM =1; + + /** Ties get the maximum applicable rank */ + private static final int MAXIMUM = 2; + + /** Ties assigned sequential ranks in order of occurrence */ + private static final int SEQUENTIAL = 3; + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Rank(){} + + /** + * Rank an array containing NaN values using the natural ordering on Floats, with + * NaN values handled according to nanStrategy and ties + * resolved using tiesStrategy. + * + *

    Input values that specify which strategy to use for handling tied values in the + * rank transformations: + *

      + *
    • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + * For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
    • + *
    • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + * of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
    • + *
    • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + * of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
    • + *
    • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + * for example (1,3,4,3) is ranked as (1,2,4,3)
    • + *
    + *

    + * + *

    Input values that specify which strategy to use for handling NaN values in the + * rank transformations: + *

      + *
    • 0 (REMOVED, default) - NaNs are removed before the rank transform is applied
    • + *
    • 1 (MINIMAL) - NaNs are treated as minimal in the ordering, equivalent to + * (that is, tied with) Float.NEGATIVE_INFINITY.
    • + *
    • 2 (MAXIMAL) - NaNs are treated as maximal in the ordering, equivalent to + * Float.POSITIVE_INFINITY
    • + *
    • 3 (FIXED) - NaNs are left "in place," that is the rank transformation is + * applied to the other elements in the input array, but the NaN elements + * are returned unchanged.
    • + *
    + *

    + * If the data array has no NaN values, use {@link rank(float[], int)} instead. It is quicker. + * @param data array to be ranked. This is cast to a float array prior to ranking. + * @param nanStrategy 0,1,2 or 3 corresponding to the NaN strategy to employ. + * @param tiesStrategy 0,1,2 or 3 corresponding to the ties strategy to employ. + * @return array of ranks + */ + public static float[] rank(int[] data, int tiesStrategy, int nanStrategy) { + checkNaNStrategy(nanStrategy); + checkTiesStrategy(tiesStrategy); + // Array recording initial positions of data to be ranked + IntFloatPair[] ranks = new IntFloatPair[data.length]; + for (int i = 0; i < data.length; i++) { + ranks[i] = new IntFloatPair((float)data[i], i); + } + List nanPositions = nanStrategy(ranks, nanStrategy); + // Sort the IntFloatPairs + Arrays.sort(ranks); + float[] out = new float[ranks.length]; + rankIt(ranks,out, tiesStrategy); + + if (nanStrategy==FIXED){ + restoreNaNs(out, nanPositions); + } + return out; + } + + /** + * Rank an array containing NaN values using the natural ordering on Floats, with + * NaN values handled according to nanStrategy and ties + * resolved using tiesStrategy. + * + *

    Input values that specify which strategy to use for handling tied values in the + * rank transformations: + *

      + *
    • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + * For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
    • + *
    • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + * of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
    • + *
    • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + * of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
    • + *
    • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + * for example (1,3,4,3) is ranked as (1,2,4,3)
    • + *
    + *

    + * + *

    Input values that specify which strategy to use for handling NaN values in the + * rank transformations: + *

      + *
    • 0 (REMOVED, default) - NaNs are removed before the rank transform is applied
    • + *
    • 1 (MINIMAL) - NaNs are treated as minimal in the ordering, equivalent to + * (that is, tied with) Float.NEGATIVE_INFINITY.
    • + *
    • 2 (MAXIMAL) - NaNs are treated as maximal in the ordering, equivalent to + * Float.POSITIVE_INFINITY
    • + *
    • 3 (FIXED) - NaNs are left "in place," that is the rank transformation is + * applied to the other elements in the input array, but the NaN elements + * are returned unchanged.
    • + *
    + *

    + * If the data array has no NaN values, use {@link rank(float[], int)} instead. It is quicker. + * @param data array to be ranked + * @param nanStrategy 0,1,2 or 3 corresponding to the NaN strategy to employ. + * @param tiesStrategy 0,1,2 or 3 corresponding to the ties strategy to employ. + * @return array of ranks + */ + public static float[] rank(float[] data, int tiesStrategy, int nanStrategy) { + checkNaNStrategy(nanStrategy); + checkTiesStrategy(tiesStrategy); + // Array recording initial positions of data to be ranked + IntFloatPair[] ranks = new IntFloatPair[data.length]; + for (int i = 0; i < data.length; i++) { + ranks[i] = new IntFloatPair(data[i], i); + } + List nanPositions = nanStrategy(ranks, nanStrategy); + // Sort the IntFloatPairs + Arrays.sort(ranks); + float[] out = new float[ranks.length]; + rankIt(ranks,out, tiesStrategy); + + if (nanStrategy==FIXED){ + restoreNaNs(out, nanPositions); + } + return out; + } + + /** + * Rank an array (with no NaNs) using the natural ordering on Floats with ties + * resolved using tiesStrategy. + *

    Input values that specify which strategy to use for handling NaN values in the + * rank transformations: + *

      + *
    • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + * For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
    • + *
    • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + * of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
    • + *
    • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + * of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
    • + *
    • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + * for example (1,3,4,3) is ranked as (1,2,4,3)
    • + *
    + *

    + * + * @param data array to be ranked. The array is cast to a float array prior to ranking + * @param tiesStrategy the strategy to employ for ties. + * @return array of ranks + */ + public static float[] rank(int[] data, int tiesStrategy) { + checkTiesStrategy(tiesStrategy); + // Array recording initial positions of data to be ranked + IntFloatPair[] ranks = new IntFloatPair[data.length]; + for (int i = 0; i < data.length; i++) { + ranks[i] = new IntFloatPair((float)data[i], i); + } + // Sort the IntFloatPairs + Arrays.sort(ranks); + float[] out = new float[ranks.length]; + rankIt(ranks,out,tiesStrategy); + return out; + } + + /** + * Rank an array (with no NaNs) using the natural ordering on Floats with ties + * resolved using tiesStrategy. + *

    Input values that specify which strategy to use for handling NaN values in the + * rank transformations: + *

      + *
    • 0 (AVERAGE, default) - Tied values are assigned the average of the applicable ranks. + * For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)
    • + *
    • 1 (MINIMUM) - Tied values are assigned the minimum applicable rank, or the rank + * of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)
    • + *
    • 2 (MAXIMUM) - Tied values are assigned the maximum applicable rank, or the rank + * of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)
    • + *
    • 3 (SEQUENTIAL) - Ties are assigned ranks in order of occurrence in the original array, + * for example (1,3,4,3) is ranked as (1,2,4,3)
    • + *
    + *

    + * + * @param data array to be ranked. + * @param tiesStrategy the strategy to employ for ties. + * @return array of ranks + */ + public static float[] rank(float[] data, int tiesStrategy) { + checkTiesStrategy(tiesStrategy); + // Array recording initial positions of data to be ranked + IntFloatPair[] ranks = new IntFloatPair[data.length]; + for (int i = 0; i < data.length; i++) { + ranks[i] = new IntFloatPair(data[i], i); + } + // Sort the IntFloatPairs + Arrays.sort(ranks); + float[] out = new float[ranks.length]; + rankIt(ranks,out,tiesStrategy); + return out; + } + + /** The actual ranking takes place here. + * @param ranks: the IntFloat pair of ranks + * @param out: the output ranks */ + private static void rankIt(IntFloatPair[] ranks, float[] out, int tiesStrategy){ + int pos = 1; // position in sorted array + + // Walk the sorted array, filling output array using sorted positions, + // resolving ties as we go + out[ranks[0].getPosition()] = pos; + List tiesTrace = new ArrayList(); + tiesTrace.add(ranks[0].getPosition()); + for (int i = 1; i < ranks.length; i++) { + if (Float.compare(ranks[i].getValue(), ranks[i - 1].getValue()) > 0) { + // tie sequence has ended (or had length 1) + pos = i + 1; + if (tiesTrace.size() > 1) { // if seq is nontrivial, resolve + resolveTie(out, tiesTrace, tiesStrategy); + } + tiesTrace = new ArrayList(); + tiesTrace.add(ranks[i].getPosition()); + } else { + // tie sequence continues + tiesTrace.add(ranks[i].getPosition()); + } + out[ranks[i].getPosition()] = pos; + } + if (tiesTrace.size() > 1) { // handle tie sequence at end + resolveTie(out, tiesTrace, tiesStrategy); + } + } + + /* Check if the nanStrategy input is one of those specified */ + private static void checkNaNStrategy(int num){ + if(num<0 || num>3) throw new IllegalArgumentException("NaN strategy option has to be 0, 1, 2 or 3."); + } + /* Check if the tiesStrategy input is one of those specified */ + private static void checkTiesStrategy(int num){ + if(num<0 || num>3) throw new IllegalArgumentException("Ties strategy option has to be 0, 1, 2 or 3."); + } + + /** Decide how to proceed with the NaN values */ + private static List nanStrategy(IntFloatPair[] ranks, int nanStrategy){ + List nanPositions = null; + + // Recode, remove or record positions of NaNs + switch (nanStrategy) { + case MAXIMAL: // Replace NaNs with +INFs + recodeNaNs(ranks, Float.POSITIVE_INFINITY); + break; + case MINIMAL: // Replace NaNs with -INFs + recodeNaNs(ranks, Float.NEGATIVE_INFINITY); + break; + case REMOVED: // Drop NaNs from data + ranks = removeNaNs(ranks); + break; + case FIXED: // Record positions of NaNs + nanPositions = getNanPositions(ranks); + break; + } + return nanPositions; + } + + /** + * Returns an array that is a copy of the input array with IntFloatPairs + * having NaN values removed. + * @param ranks input array + * @return array with NaN-valued entries removed + */ + private static IntFloatPair[] removeNaNs(IntFloatPair[] ranks) { + if (!containsNaNs(ranks)) { + return ranks; + } + IntFloatPair[] outRanks = new IntFloatPair[ranks.length]; + int j = 0; + for (int i = 0; i < ranks.length; i++) { + if (Float.isNaN(ranks[i].getValue())) { + // drop, but adjust original ranks of later elements + for (int k = i + 1; k < ranks.length; k++) { + ranks[k] = new IntFloatPair( + ranks[k].getValue(), ranks[k].getPosition() - 1); + } + } else { + outRanks[j] = new IntFloatPair( + ranks[i].getValue(), ranks[i].getPosition()); + j++; + } + } + IntFloatPair[] returnRanks = new IntFloatPair[j]; + System.arraycopy(outRanks, 0, returnRanks, 0, j); + return returnRanks; + } + + /** + * Recodes NaN values to the given value. + * + * @param ranks array to recode + * @param value the value to replace NaNs with + */ + private static void recodeNaNs(IntFloatPair[] ranks, float value) { + for (int i = 0; i < ranks.length; i++) { + if (Float.isNaN(ranks[i].getValue())) { + ranks[i] = new IntFloatPair( + value, ranks[i].getPosition()); + } + } + } + + /** + * Checks for presence of NaNs in ranks. + * + * @param ranks array to be searched for NaNs + * @return true iff ranks contains one or more NaNs + */ + private static boolean containsNaNs(IntFloatPair[] ranks) { + for (int i = 0; i < ranks.length; i++) { + if (Float.isNaN(ranks[i].getValue())) { + return true; + } + } + return false; + } + + /** + * Resolve a sequence of ties, using the configured TiesStrategy. + * The input ranks array is expected to take the same value + * for all indices in tiesTrace. The common value is recoded + * according to the tiesStrategy. For example, if ranks = <5,8,2,6,2,7,1,2>, + * tiesTrace = <2,4,7> and tiesStrategy is MINIMUM, ranks will be unchanged. + * The same array and trace with tiesStrategy AVERAGE will come out + * <5,8,3,6,3,7,1,3>. + * + * @param ranks array of ranks + * @param tiesTrace list of indices where ranks is constant + * -- that is, for any i and j in TiesTrace, ranks[i] == ranks[j] + * + */ + private static void resolveTie(float[] ranks, List tiesTrace, int tiesStrategy) { + + // constant value of ranks over tiesTrace + final float c = ranks[tiesTrace.get(0)]; + + // length of sequence of tied ranks + final int length = tiesTrace.size(); + + switch (tiesStrategy) { + case AVERAGE: // Replace ranks with average + double tmp = (2 * c + length - 1) / 2d; + fill(ranks, tiesTrace, (float)tmp); + break; + case MAXIMUM: // Replace ranks with maximum values + fill(ranks, tiesTrace, c + length - 1); + break; + case MINIMUM: // Replace ties with minimum + fill(ranks, tiesTrace, c); + break; + case SEQUENTIAL: // Fill sequentially from c to c + length - 1 + // walk and fill + Iterator iterator = tiesTrace.iterator(); + float f = (float)Math.round(c); + int i = 0; + while (iterator.hasNext()) { + ranks[iterator.next()] = f + i++; + } + break; + } + } + + /** + * Setsdata[i] = value for each i in tiesTrace. + * + * @param data array to modify + * @param tiesTrace list of index values to set + * @param value value to set + */ + private static void fill(float[] data, List tiesTrace, float value) { + Iterator iterator = tiesTrace.iterator(); + while (iterator.hasNext()) { + data[iterator.next()] = value; + } + } + + /** + * Set ranks[i] = Float.NaN for each i in nanPositions. + * + * @param ranks array to modify + * @param nanPositions list of index values to set to Float.NaN + */ + private static void restoreNaNs(float[] ranks, List nanPositions) { + if (nanPositions.size() == 0) { + return; + } + Iterator iterator = nanPositions.iterator(); + while (iterator.hasNext()) { + ranks[iterator.next().intValue()] = Float.NaN; + } + + } + + /** + * Returns a list of indexes where ranks is NaN. + * + * @param ranks array to search for NaNs + * @return list of indexes i such that ranks[i] = NaN + */ + private static List getNanPositions(IntFloatPair[] ranks) { + ArrayList out = new ArrayList(); + for (int i = 0; i < ranks.length; i++) { + if (Float.isNaN(ranks[i].getValue())) { + out.add(Integer.valueOf(i)); + } + } + return out; + } + + + /** + * Represents the position of a float value in an ordering. + * Comparable interface is implemented so Arrays.sort can be used + * to sort an array of IntFloatPairs by value. Note that the + * implicitly defined natural ordering is NOT consistent with equals. + */ + private static class IntFloatPair implements Comparable { + + /** Value of the pair */ + private final float value; + + /** Original position of the pair */ + private final int position; + + /** + * Construct an IntFloatPair with the given value and position. + * @param value the value of the pair + * @param position the original position + */ + public IntFloatPair(float value, int position) { + this.value = value; + this.position = position; + } + + /** + * Compare this IntFloatPair to another pair. + * Only the values are compared. + * + * @param other the other pair to compare this to + * @return result of Float.compare(value, other.value) + */ + public int compareTo(IntFloatPair other) { + return Float.compare(value, other.value); + } + + /** + * Returns the value of the pair. + * @return value + */ + public float getValue() { + return value; + } + + /** + * Returns the original position of the pair. + * @return position + */ + public int getPosition() { + return position; + } + } +} + +//public class Rank { +// private int[] rank;//= new int[numProducts]; +// private int[] idx;// = new int[numProducts]; +// +// public Rank(float[] sortedArray) { +// int size = sortedArray.length; +// rankTemp = new int[size]; +// int i=0; +// while(i +For an m x n matrix A with m > n, +the singular value decomposition is an m-by-n orthogonal matrix +U, an n-by-n diagonal matrix S, and +an n-by-n orthogonal matrix V so that A = U*S*V'. +

    +The singular values, sigma[k] = S[k][k], are ordered so that +sigma[0] > sigma[1] > ... > sigma[n-1]. +

    +The singular value decompostion always exists, so the constructor will +never fail. The matrix condition number and the effective numerical +rank can be computed from this decomposition. +

    +Shamelessly copied (and modified) from the +JAMA Java +Matrix package. To make things compatible with how most users use Processing, the +class take in float matrices. However, to preserve the acccuracy of the computations, the algorithm +first casts the input into a double array, prior to doing anything. All methods also return doubles; Use +{@link Cast#doubleToFloat(double[][])} if you want/need to cast everything back to floats for +further (non-high-accuracy-dependant) processing (pun intended). + */ + +public class SVD { + + /* ------------------------ + Class variables + * ------------------------ */ + + /** Arrays for internal storage of U and V. + @serial internal storage of U. + @serial internal storage of V. + */ + private double[][] U, V; + + /** Array for internal storage of singular values. + @serial internal storage of singular values. + */ + private double[] s; + + /** Row and column dimensions. + @serial row dimension. + @serial column dimension. + */ + private int m, n; + + /* ------------------------ + Constructor + * ------------------------ */ + + /** Construct the singular value decomposition. At the end of this call, + * U, V, and S have been computed. + @param AA Rectangular matrix + @return + */ + + public SVD (float[][] AA) { + + // Derived from LINPACK code. + // Initialize. + double[][] A = Cast.floatToDouble(AA); + m = AA.length; + n = AA[0].length; + + /* Apparently the failing cases are only a proper subset of (m= n"); } + */ + int nu = Math.min(m,n); + s = new double [Math.min(m+1,n)]; + U = new double [m][nu]; + V = new double [n][n]; + double[] e = new double [n]; + double[] work = new double [m]; + boolean wantu = true; + boolean wantv = true; + + // Reduce A to bidiagonal form, storing the diagonal elements + // in s and the super-diagonal elements in e. + + int nct = Math.min(m-1,n); + int nrt = Math.max(0,Math.min(n-2,m)); + for (int k = 0; k < Math.max(nct,nrt); k++) { + if (k < nct) { + + // Compute the transformation for the k-th column and + // place the k-th diagonal in s[k]. + // Compute 2-norm of k-th column without under/overflow. + s[k] = 0; + for (int i = k; i < m; i++) { + s[k] = hypot(s[k],A[i][k]); + } + if (s[k] != 0.0) { + if (A[k][k] < 0.0) { + s[k] = -s[k]; + } + for (int i = k; i < m; i++) { + A[i][k] /= s[k]; + } + A[k][k] += 1.0; + } + s[k] = -s[k]; + } + for (int j = k+1; j < n; j++) { + if ((k < nct) & (s[k] != 0.0)) { + + // Apply the transformation. + + double t = 0; + for (int i = k; i < m; i++) { + t += A[i][k]*A[i][j]; + } + t = -t/A[k][k]; + for (int i = k; i < m; i++) { + A[i][j] += t*A[i][k]; + } + } + + // Place the k-th row of A into e for the + // subsequent calculation of the row transformation. + + e[j] = A[k][j]; + } + if (wantu & (k < nct)) { + + // Place the transformation in U for subsequent back + // multiplication. + + for (int i = k; i < m; i++) { + U[i][k] = A[i][k]; + } + } + if (k < nrt) { + + // Compute the k-th row transformation and place the + // k-th super-diagonal in e[k]. + // Compute 2-norm without under/overflow. + e[k] = 0; + for (int i = k+1; i < n; i++) { + e[k] = hypot(e[k],e[i]); + } + if (e[k] != 0.0) { + if (e[k+1] < 0.0) { + e[k] = -e[k]; + } + for (int i = k+1; i < n; i++) { + e[i] /= e[k]; + } + e[k+1] += 1.0; + } + e[k] = -e[k]; + if ((k+1 < m) & (e[k] != 0.0)) { + + // Apply the transformation. + + for (int i = k+1; i < m; i++) { + work[i] = 0.0; + } + for (int j = k+1; j < n; j++) { + for (int i = k+1; i < m; i++) { + work[i] += e[j]*A[i][j]; + } + } + for (int j = k+1; j < n; j++) { + double t = -e[j]/e[k+1]; + for (int i = k+1; i < m; i++) { + A[i][j] += t*work[i]; + } + } + } + if (wantv) { + + // Place the transformation in V for subsequent + // back multiplication. + + for (int i = k+1; i < n; i++) { + V[i][k] = e[i]; + } + } + } + } + + // Set up the final bidiagonal matrix or order p. + + int p = Math.min(n,m+1); + if (nct < n) { + s[nct] = A[nct][nct]; + } + if (m < p) { + s[p-1] = 0.0; + } + if (nrt+1 < p) { + e[nrt] = A[nrt][p-1]; + } + e[p-1] = 0.0; + + // If required, generate U. + + if (wantu) { + for (int j = nct; j < nu; j++) { + for (int i = 0; i < m; i++) { + U[i][j] = 0.0; + } + U[j][j] = 1.0; + } + for (int k = nct-1; k >= 0; k--) { + if (s[k] != 0.0) { + for (int j = k+1; j < nu; j++) { + double t = 0; + for (int i = k; i < m; i++) { + t += U[i][k]*U[i][j]; + } + t = -t/U[k][k]; + for (int i = k; i < m; i++) { + U[i][j] += t*U[i][k]; + } + } + for (int i = k; i < m; i++ ) { + U[i][k] = -U[i][k]; + } + U[k][k] = 1.0 + U[k][k]; + for (int i = 0; i < k-1; i++) { + U[i][k] = 0.0; + } + } else { + for (int i = 0; i < m; i++) { + U[i][k] = 0.0; + } + U[k][k] = 1.0; + } + } + } + + // If required, generate V. + + if (wantv) { + for (int k = n-1; k >= 0; k--) { + if ((k < nrt) & (e[k] != 0.0)) { + for (int j = k+1; j < nu; j++) { + double t = 0; + for (int i = k+1; i < n; i++) { + t += V[i][k]*V[i][j]; + } + t = -t/V[k+1][k]; + for (int i = k+1; i < n; i++) { + V[i][j] += t*V[i][k]; + } + } + } + for (int i = 0; i < n; i++) { + V[i][k] = 0.0; + } + V[k][k] = 1.0; + } + } + + // Main iteration loop for the singular values. + + int pp = p-1; + int iter = 0; + double eps = Math.pow(2.0,-52.0); + double tiny = Math.pow(2.0,-966.0); + while (p > 0) { + int k,kase; + + // Here is where a test for too many iterations would go. + + // This section of the program inspects for + // negligible elements in the s and e arrays. On + // completion the variables kase and k are set as follows. + + // kase = 1 if s(p) and e[k-1] are negligible and k

    = -1; k--) { + if (k == -1) { + break; + } + if (Math.abs(e[k]) <= + tiny + eps*(Math.abs(s[k]) + Math.abs(s[k+1]))) { + e[k] = 0.0; + break; + } + } + if (k == p-2) { + kase = 4; + } else { + int ks; + for (ks = p-1; ks >= k; ks--) { + if (ks == k) { + break; + } + double t = (ks != p ? Math.abs(e[ks]) : 0.) + + (ks != k+1 ? Math.abs(e[ks-1]) : 0.); + if (Math.abs(s[ks]) <= tiny + eps*t) { + s[ks] = 0.0; + break; + } + } + if (ks == k) { + kase = 3; + } else if (ks == p-1) { + kase = 1; + } else { + kase = 2; + k = ks; + } + } + k++; + + // Perform the task indicated by kase. + + switch (kase) { + + // Deflate negligible s(p). + + case 1: { + double f = e[p-2]; + e[p-2] = 0.0; + for (int j = p-2; j >= k; j--) { + double t = hypot(s[j],f); + double cs = s[j]/t; + double sn = f/t; + s[j] = t; + if (j != k) { + f = -sn*e[j-1]; + e[j-1] = cs*e[j-1]; + } + if (wantv) { + for (int i = 0; i < n; i++) { + t = cs*V[i][j] + sn*V[i][p-1]; + V[i][p-1] = -sn*V[i][j] + cs*V[i][p-1]; + V[i][j] = t; + } + } + } + } + break; + + // Split at negligible s(k). + + case 2: { + double f = e[k-1]; + e[k-1] = 0.0; + for (int j = k; j < p; j++) { + double t = hypot(s[j],f); + double cs = s[j]/t; + double sn = f/t; + s[j] = t; + f = -sn*e[j]; + e[j] = cs*e[j]; + if (wantu) { + for (int i = 0; i < m; i++) { + t = cs*U[i][j] + sn*U[i][k-1]; + U[i][k-1] = -sn*U[i][j] + cs*U[i][k-1]; + U[i][j] = t; + } + } + } + } + break; + + // Perform one qr step. + + case 3: { + + // Calculate the shift. + + double scale = Math.max(Math.max(Math.max(Math.max( + Math.abs(s[p-1]),Math.abs(s[p-2])),Math.abs(e[p-2])), + Math.abs(s[k])),Math.abs(e[k])); + double sp = s[p-1]/scale; + double spm1 = s[p-2]/scale; + double epm1 = e[p-2]/scale; + double sk = s[k]/scale; + double ek = e[k]/scale; + double b = ((spm1 + sp)*(spm1 - sp) + epm1*epm1)/2.0; + double c = (sp*epm1)*(sp*epm1); + double shift = 0.0; + if ((b != 0.0) | (c != 0.0)) { + shift = Math.sqrt(b*b + c); + if (b < 0.0) { + shift = -shift; + } + shift = c/(b + shift); + } + double f = (sk + sp)*(sk - sp) + shift; + double g = sk*ek; + + // Chase zeros. + + for (int j = k; j < p-1; j++) { + double t = hypot(f,g); + double cs = f/t; + double sn = g/t; + if (j != k) { + e[j-1] = t; + } + f = cs*s[j] + sn*e[j]; + e[j] = cs*e[j] - sn*s[j]; + g = sn*s[j+1]; + s[j+1] = cs*s[j+1]; + if (wantv) { + for (int i = 0; i < n; i++) { + t = cs*V[i][j] + sn*V[i][j+1]; + V[i][j+1] = -sn*V[i][j] + cs*V[i][j+1]; + V[i][j] = t; + } + } + t = hypot(f,g); + cs = f/t; + sn = g/t; + s[j] = t; + f = cs*e[j] + sn*s[j+1]; + s[j+1] = -sn*e[j] + cs*s[j+1]; + g = sn*e[j+1]; + e[j+1] = cs*e[j+1]; + if (wantu && (j < m-1)) { + for (int i = 0; i < m; i++) { + t = cs*U[i][j] + sn*U[i][j+1]; + U[i][j+1] = -sn*U[i][j] + cs*U[i][j+1]; + U[i][j] = t; + } + } + } + e[p-2] = f; + iter = iter + 1; + } + break; + + // Convergence. + + case 4: { + + // Make the singular values positive. + + if (s[k] <= 0.0) { + s[k] = (s[k] < 0.0 ? -s[k] : 0.0); + if (wantv) { + for (int i = 0; i <= pp; i++) { + V[i][k] = -V[i][k]; + } + } + } + + // Order the singular values. + + while (k < pp) { + if (s[k] >= s[k+1]) { + break; + } + double t = s[k]; + s[k] = s[k+1]; + s[k+1] = t; + if (wantv && (k < n-1)) { + for (int i = 0; i < n; i++) { + t = V[i][k+1]; V[i][k+1] = V[i][k]; V[i][k] = t; + } + } + if (wantu && (k < m-1)) { + for (int i = 0; i < m; i++) { + t = U[i][k+1]; U[i][k+1] = U[i][k]; U[i][k] = t; + } + } + k++; + } + iter = 0; + p--; + } + break; + } + } + } + + /* ------------------------ + Public Methods + * ------------------------ */ + + /** Return the left singular vectors + @return U + */ + + public double[][] getU () { + return U; + } + + /** Return the right singular vectors + @return V + */ + + public double[][] getV () { + return V; + } + + /** Return the one-dimensional array of singular values + @return diagonal of S. + */ + + public double[] getSingularValues () { + return s; + } + + /** Return the diagonal matrix of singular values + @return S + */ + + public double[][] getS () { + double[][] S = new double[n][n]; + for (int i = 0; i < n; i++) { + S[i][i] = (double)this.s[i]; + } + return S; + } + + /** Two norm + * @return max(S) + */ + public double norm2 () { + return s[0]; + } + + /** Two norm condition number + @return max(S)/min(S) + */ + public double cond () { + return s[0]/s[Math.min(m,n)-1]; + } + + /** Effective numerical matrix rank + @return Number of nonnegligible singular values. + */ + + public int rank () { + double eps = Math.pow(2.0,-52.0); + double tol = Math.max(m,n)*s[0]*eps; + int r = 0; + for (int i = 0; i < s.length; i++) { + if (s[i] > tol) { + r++; + } + } + return r; + } + + /** sqrt(a^2 + b^2) without under/overflow. **/ + protected static double hypot(double a, double b) { + double r; + if (a*a > b*b) { + r = b/a; + r = Math.abs(a)*Math.sqrt(1+r*r); + } else if (b != 0) { + r = a/b; + r = Math.abs(b)*Math.sqrt(1+r*r); + } else { + r = 0.0; + } + return r; + } + +} + + + + + + + + diff --git a/drawing/papaya/src/papaya/ScatterPlot.java b/drawing/papaya/src/papaya/ScatterPlot.java new file mode 100644 index 0000000..ca9d365 --- /dev/null +++ b/drawing/papaya/src/papaya/ScatterPlot.java @@ -0,0 +1,205 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; +import java.util.Arrays; +import java.io.*; +import java.lang.Object; +import java.lang.String; + +import processing.core.*; + +/** + * A simple class to plot x vs y data as a + * scatter plot. Default is to draw the points as ellipses, + * but you can also use rectangles, and connect the points with + * lines. + * @author Adila Faruk + */ +public class ScatterPlot extends Visuals{ + public boolean asConnectedLines = false; + public boolean asRectangles = false; + public boolean asEllipses = true; + public boolean[] XYLabels = {true,true}; + public boolean[] XYTicks = {true,true}; + + /** + * Specifies whether to draw the bounding rectangle around the plot. + */ + public boolean drawRectangle = true; + /** + * Specifies whether to draw the axes + */ + public boolean drawAxes = true; + + protected PApplet myParent; + + /** + * Specifies the space on the left between the plot area, and the + * bounding rectangle. That is, the left-most point of + * the rectangle is given by plotLeft-leftBound. + */ + public float leftBound = 40; + /** + * Specifies the space on the right betweent the plot area, and the + * bounding rectangle. That is, the right-most point of + * the rectangle is given by plotLeft+plotWidth+rightBound. + */ + public float rightBound=20; + /** + * Specifies the space on the top, between the plot area and the bounding + * rectangle. That is, the top-most point of the rectangle is given by + * plotTop - topBound. + */ + public float topBound = 20; + /** + * Specifies the space on the bottom, between the plot area and the bounding + * rectangle. That is, the bottom-most point of the rectangle is given by + * plotTop + plotHeight + bottomBound. + */ + public float bottomBound=20; + //CENTER = 3; BOTTOM = 102; TOP = 101; BASELINE = 0; LEFT = 37; RIGHT = 39; + + protected float minX; + protected float minY; + protected float maxX; + protected float maxY; // plot min/max + protected float minXDat; + protected float minYDat; + protected float maxXDat; + protected float maxYDat; // data min/max + boolean dataExtremesHaveBeenSet=false; + + public ScatterPlot(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. + * It'll try do it automatically for you, if you don't set it here, + * but no guarantees on the result being a nice number. For example, it might + * go from 61 to 89 instead of 60 to 90. + * @param _minXDat the minimum x value to use. Set to more than the x data minimum. + * @param _maxXDat the maximum x value to use. Set to more than the x data maximum. + * @param _minYDat the minimum y value to use. Set to more than the y data minimum. + * @param _maxYDat the maximum y value to use. Set to more than the y data maximum. + */ + public void setDataExtremes(float _minXDat, float _maxXDat, float _minYDat, float _maxYDat){ + minXDat = _minXDat; maxXDat = _maxXDat; + minYDat = _minYDat; maxYDat = _maxYDat; + dataExtremesHaveBeenSet = true; + } + + /** + * Draws a rectangle around the plot. + *

      + *
    • Left most point: plotLeft-leftBound
    • + *
    • Top most point: plotTop-topBound
    • + *
    • Width: plotWidth+leftBound+rightBound
    • + *
    • Height: plotHeight+topBound+bottomBound
    • + *
    + */ + public void drawRectangle(){ + drawRect(plotLeft-leftBound,plotTop-topBound,plotWidth+leftBound+rightBound,plotHeight+topBound+bottomBound,bgColor); + } + + /** + * Parent function to plot scatter plot of the data. + * @param _xDat x Data array + * @param _yDat y Data array + * @param _sWeight stroke weight + * @param _sColor stroke color + */ + public void drawScatterPlot(float[] _xDat, float[] _yDat, float _sWeight, int _sColor){ + 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(_xDat,minXDat,maxXDat,plotLeft,plotLeft+plotWidth); + float[] yDatMapped = Mat.map(_yDat,minYDat,maxYDat,plotTop+plotHeight,plotTop); + + + if(asConnectedLines){ + drawConnectedWithLines(xDatMapped,yDatMapped,_sWeight,_sColor); + } + if(asRectangles){ + drawAsRectangles(xDatMapped,yDatMapped,_sColor,10,6); + } + if(asEllipses){ + drawAsEllipses(xDatMapped,yDatMapped,_sColor,6); + } + } + + protected void drawScatterPlot(float[] _xDat, float[] _yDat){ + drawScatterPlot(_xDat,_yDat,STROKEWEIGHT[0],GRAY[0]); + } + + /** + * connects the dots + */ + protected void drawConnectedWithLines(float[] xDatMapped, float[] yDatMapped, float _sWeight, int _sColor){ + + myParent.noFill(); + myParent.stroke(_sColor); + myParent.strokeWeight(_sWeight); + + myParent.beginShape(); + for(int i=0; i + * For example, assume we have three arrays X, Y and Z. We want to sort all three arrays by + * X (or some arbitrary comparison function). For example, we have
    + * X={3, 2, 1}, Y={3.0, 1.0, 2.0}, Z={6.0, 7.0, 8.0}. The output should + * be + *
    + * X={1, 2, 3}, Y={2.0, 1.0, 3.0}, Z={8.0, 7.0, 6.0}
    . + * To do this, we can use the indices corresponding to the elements of X sorted + * in ascending order: + *

    + * X={3,2,1} so indicesForSorting = {2,1,0} + * (X[2] holds the smallest value of X, + * X[1] holds the next smallest value of X, and X[0] + * holds the largest value of X). + * The indicesForSorting can then be used to arrange Y and Z + * in the same order. + * + *

    + * The algorithm used to obtain these indices is a modified version of the + * tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + * Sort Function", Software-Practice and Experience, Vol. 23(11) + * P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + * to sort arrays). + *

    It is a modified version in the sense that the original array remains unsorted. Instead, + * a copy of the original array is used in the sorting routine, and the array of + * indices [0,1,2,...N-1] sorted concurrently with the array being sorted. + * + * + * @author Adila Faruk + * + */ +public final class Sorting { + + /** + * Makes this class non instantiable, but still let's others inherit from it. + */ + protected Sorting(){} + + private static final int SMALL = 7; // params used in original paper + private static final int MEDIUM = 40; // params used in original paper + + /** + * Gets the array of indices that can be used to sort the array in ascending or + * descending order. + * + *

    + * The algorithm used to obtain these indices is a modified version of the + * tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + * Sort Function", Software-Practice and Experience, Vol. 23(11) + * P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + * to sort arrays). + *

    It is a modified version in the sense that the original array remains unsorted. Instead, + * a copy of the original array is used in the sorting routine, and the array of + * indices [0,1,2,...N-1] sorted concurrently with the array being sorted. + * + * @param a the input array + * @param isAscending true for data sorted in increasing order. + * @return integar array of indices (with length=data.length) that can be used + * to sort the data from low to high or vice-versa.. + * * @throws IllegalArgumentException if fromIndex > toIndex + * @throws ArrayIndexOutOfBoundsException if fromIndex < 0 or + * toIndex > a.length + * + * + */ + public static int[] indices(float[] a, boolean isAscending) { + return indices(a,0,a.length,isAscending); + } + public static int[] indices(double[] a, boolean isAscending) { + return indices(a,0,a.length,isAscending); + } + public static int[] indices(int[] a, boolean isAscending) { + return indices(a,0,a.length,isAscending); + } + /** + * Gets the array of indices that can be used to sort the section of the + * input array going from fromIndex(inclusive) to toIndex(exclusive) + * in ascending or descending order. + * + *

    + * The algorithm used to obtain these indices is a modified version of the + * tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + * Sort Function", Software-Practice and Experience, Vol. 23(11) + * P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + * to sort arrays). + *

    It is a modified version in the sense that the original array remains unsorted. Instead, + * a copy of the original array is used in the sorting routine, and the array of + * indices [fromIndex,fromIndex+1, ... , toIndex-1] sorted concurrently with the array being sorted. + * @param a the array to be sorted. + * @param fromIndex the index of the first element (inclusive) to be + * sorted. + * @param toIndex the index of the last element (exclusive) to be sorted. + * @param isAscending true for data sorted in increasing order. + * @throws IllegalArgumentException if fromIndex > toIndex + * @throws ArrayIndexOutOfBoundsException if fromIndex < 0 or + * toIndex > a.length + */ + public static int[] indices(float[] a, int fromIndex, int toIndex, boolean isAscending) { + rangeCheck(a.length, fromIndex, toIndex); + int lenToSort = toIndex-fromIndex; + //int[] indicesToSort = Mat.linspace(fromIndex, toIndex-1); + int[] indicesToSort = Mat.linspace(0,a.length-1); + float[] x = Arrays.copyOf(a,a.length); + quickSort1(x, indicesToSort, fromIndex, lenToSort, isAscending); + return indicesToSort; + } + public static int[] indices(double[] a, int fromIndex, int toIndex, boolean isAscending) { + rangeCheck(a.length, fromIndex, toIndex); + int lenToSort = toIndex-fromIndex; + //int[] indicesToSort = Mat.linspace(fromIndex, toIndex-1); + int[] indicesToSort = Mat.linspace(0,a.length-1); + double[] x = Arrays.copyOf(a,a.length); + quickSort1(x, indicesToSort, fromIndex, lenToSort, isAscending); + return indicesToSort; + } + public static int[] indices(int[] a, int fromIndex, int toIndex, boolean isAscending) { + rangeCheck(a.length, fromIndex, toIndex); + int lenToSort = toIndex-fromIndex; + //int[] indicesToSort = Mat.linspace(fromIndex, toIndex-1); + int[] indicesToSort = Mat.linspace(0,a.length-1); + int[] x = Arrays.copyOf(a,a.length); + quickSort1(x, indicesToSort, fromIndex, lenToSort, isAscending); + return indicesToSort; + } + + /** + * Sorts the input x and y arrays according to + * x and going from fromIndex(inclusive) to toIndex(exclusive) + * in ascending or descending order. + * + *

    + * The algorithm used to obtain these indices is a modified version of the + * tuned quicksort proposed by Jon L. Bentley and M. Douglas McIlroy's "Engineering a + * Sort Function", Software-Practice and Experience, Vol. 23(11) + * P. 1249-1265 (November 1993) (program 7 of the paper; currently used in the Arrays.sort() method + * to sort arrays). + *

    It is a modified version in the sense that two arrays are sorted according to the first + * array. At the end of the method, the section of both arrays going from + * fromIndex (inclusive) to toIndex(exclusive) are sorted according + * to the first array's order. Use a copy of both arrays if you want to preserve the natural order of + * the original arrays. + * @param x the array to sort. + * @param y the second array, to sort according to x. + * @param fromIndex the index of the first element (inclusive) to be + * sorted. + * @param toIndex the index of the last element (exclusive) to be sorted. + * @param isAscending true for data sorted in increasing order. + * @throws IllegalArgumentException if fromIndex > toIndex + * @throws ArrayIndexOutOfBoundsException if fromIndex < 0 or + * toIndex > a.length + * @see Arrays#sort(float[]) + */ + public static void twoArrays(float[] x, float[] y, int fromIndex, int toIndex, boolean isAscending) { + rangeCheck(x.length, fromIndex, toIndex); + int lenToSort = toIndex-fromIndex; + quickSort2(x, y, fromIndex, lenToSort, isAscending); + } + public static void twoArrays(double[] x, double[] y, int fromIndex, int toIndex, boolean isAscending) { + rangeCheck(x.length, fromIndex, toIndex); + int lenToSort = toIndex-fromIndex; + quickSort2(x, y, fromIndex, lenToSort, isAscending); + } + public static void twoArrays(int[] x, int[] y, int fromIndex, int toIndex, boolean isAscending) { + rangeCheck(x.length, fromIndex, toIndex); + int lenToSort = toIndex-fromIndex; + quickSort2(x, y, fromIndex, lenToSort, isAscending); + } + + /* Returns the index of the median of the three indexed floats */ + private static int med3(float x[], int a, int b, int c) { + // isAscending/Descending doesn't make a difference since + // we're getting the median + float ab = compare(x[a],x[b],true); + float ac = compare(x[a],x[c],true); + float bc = compare(x[b],x[c],true); + return (ab<0 ? + (bc<0 ? b : ac<0 ? c : a) : + (bc>0 ? b : ac>0 ? c : a)); + } + /* Returns the index of the median of the three indexed floats */ + private static int med3(double x[], int a, int b, int c) { + // isAscending/Descending doesn't make a difference since + // we're getting the median + double ab = compare(x[a],x[b],true); + double ac = compare(x[a],x[c],true); + double bc = compare(x[b],x[c],true); + return (ab<0 ? + (bc<0 ? b : ac<0 ? c : a) : + (bc>0 ? b : ac>0 ? c : a)); + } + /* Returns the index of the median of the three indexed floats */ + private static int med3(int x[], int a, int b, int c) { + // isAscending/Descending doesn't make a difference since + // we're getting the median + int ab = compare(x[a],x[b],true); + int ac = compare(x[a],x[c],true); + int bc = compare(x[b],x[c],true); + return (ab<0 ? + (bc<0 ? b : ac<0 ? c : a) : + (bc>0 ? b : ac>0 ? c : a)); + } + + /* compare(a,b) returns (a-b) if isAscending. else returns b-a*/ + private static void quickSort1(float[] x, int[] indices, int off, int len, boolean isAscending) { + //isAscendingnsertion sort on smallest arrays. (Checked, and works). + if (len < SMALL) { + for (int i=off; i x[j], swap the two + * so that the lower value (x[j]) is now at x[j-1]. + */ + for (int j=i; j>off && compare(x[j-1],x[j],isAscending)>0; j--){ + swap(x, j, j-1); + swap(indices, j, j-1); + } + } + return; + } + // Larger arrays: + // Choose a partition element, v that's the median of the array. + int m = off + len/2; // Small arrays, middle element + if (len > SMALL) { + int l = off; // start + int n = off + len - 1; // end + if (len > MEDIUM) { // Big arrays, pseudomedian of 9 + int s = len/8; + l = med3(x, l, l+s, l+2*s); + m = med3(x, m-s, m, m+s); + n = med3(x, n-2*s, n-s, n); + } + m = med3(x, l, m, n); // Mid-size, med of 3 + } + float v = x[m]; // the partition + + // Establish Invariant: v* (v)* v* (due to Sedgewick) + /* Index b scans up from the bottom of the array until it reaches a + * large element (greater than or equal to the partition value), + * c scans down until it reaches a small element. + * The two array elements are then swapped, and the scans continue until the pointers cross. + */ + int a = off, b = a, c = off + len - 1, d = c; + while(true) { + float comparison; + // while b < last index and x[b]<=x[median] + while (b <= c && (comparison=compare(x[b],v,isAscending))<=0) { + // if x[b]==x[median], x[start++]=x[b], x[b] = x[start++] + if (comparison == 0){ + swap(indices, a, b); + swap(x, a++, b); + } + // increment b + b++; + } + while (c >= b && (comparison=compare(x[c],v,isAscending))>=0) { + if (comparison == 0){ + swap(indices, c, d); + swap(x, c, d--); + } + c--; + } + /*At the end of the partitioning loop, b=c+1. + * Stop, and swap x[0] and x[j] */ + if (b > c) break; + swap(indices, b, c); + swap(x, b++, c--); + } + + // Swap partition elements back to middle + int s, n = off + len; + s = Math.min(a-off, b-a ); + vecswap(x, off, b-s, s); + vecswap(indices, off, b-s, s); + + s = Math.min(d-c, n-d-1); + vecswap(x, b, n-s, s); + vecswap(indices, b, n-s, s); + + + /* call quicksort recursively on the subarrays x[off]...x[b-a] + and x[end-(d-c)]...x[d-c] + */ + if ((s = b-a) > 1){ + quickSort1(x, indices, off, s, isAscending); + } + if ((s = d-c) > 1){ + quickSort1(x, indices, n-s, s, isAscending); + } + } + /* compare(a,b) returns (a-b) if isAscending. else returns b-a*/ + private static void quickSort2(float[] x, float[] y, int off, int len, boolean isAscending) { + //isAscendingnsertion sort on smallest arrays. (Checked, and works). + if (len < SMALL) { + for (int i=off; i x[j], swap the two + * so that the lower value (x[j]) is now at x[j-1]. + */ + for (int j=i; j>off && compare(x[j-1],x[j],isAscending)>0; j--){ + swap(x, j, j-1); + swap(y, j, j-1); + } + } + return; + } + // Larger arrays: + // Choose a partition element, v that's the median of the array. + int m = off + len/2; // Small arrays, middle element + if (len > SMALL) { + int l = off; // start + int n = off + len - 1; // end + if (len > MEDIUM) { // Big arrays, pseudomedian of 9 + int s = len/8; + l = med3(x, l, l+s, l+2*s); + m = med3(x, m-s, m, m+s); + n = med3(x, n-2*s, n-s, n); + } + m = med3(x, l, m, n); // Mid-size, med of 3 + } + float v = x[m]; // the partition + + // Establish Invariant: v* (v)* v* (due to Sedgewick) + /* Index b scans up from the bottom of the array until it reaches a + * large element (greater than or equal to the partition value), + * c scans down until it reaches a small element. + * The two array elements are then swapped, and the scans continue until the pointers cross. + */ + int a = off, b = a, c = off + len - 1, d = c; + while(true) { + float comparison; + // while b < last index and x[b]<=x[median] + while (b <= c && (comparison=compare(x[b],v,isAscending))<=0) { + // if x[b]==x[median], x[start++]=x[b], x[b] = x[start++] + if (comparison == 0){ + swap(y, a, b); + swap(x, a++, b); + } + // increment b + b++; + } + while (c >= b && (comparison=compare(x[c],v,isAscending))>=0) { + if (comparison == 0){ + swap(y, c, d); + swap(x, c, d--); + } + c--; + } + /*At the end of the partitioning loop, b=c+1. + * Stop, and swap x[0] and x[j] */ + if (b > c) break; + swap(y, b, c); + swap(x, b++, c--); + } + + // Swap partition elements back to middle + int s, n = off + len; + s = Math.min(a-off, b-a ); + vecswap(x, off, b-s, s); + vecswap(y, off, b-s, s); + + s = Math.min(d-c, n-d-1); + vecswap(x, b, n-s, s); + vecswap(y, b, n-s, s); + + + /* call quicksort recursively on the subarrays x[off]...x[b-a] + and x[end-(d-c)]...x[d-c] + */ + if ((s = b-a) > 1){ + quickSort2(x, y, off, s, isAscending); + } + if ((s = d-c) > 1){ + quickSort2(x, y, n-s, s, isAscending); + } + } + + /* compare(a,b) returns (a-b) if isAscending. else returns b-a*/ + private static void quickSort1(int[] x, int[] indices, int off, int len, boolean isAscending) { + //isAscendingnsertion sort on smallest arrays. (Checked, and works). + if (len < SMALL) { + for (int i=off; i x[j], swap the two + * so that the lower value (x[j]) is now at x[j-1]. + */ + for (int j=i; j>off && compare(x[j-1],x[j],isAscending)>0; j--){ + swap(x, j, j-1); + swap(indices, j, j-1); + } + } + return; + } + // Larger arrays: + // Choose a partition element, v that's the median of the array. + int m = off + len/2; // Small arrays, middle element + if (len > SMALL) { + int l = off; // start + int n = off + len - 1; // end + if (len > MEDIUM) { // Big arrays, pseudomedian of 9 + int s = len/8; + l = med3(x, l, l+s, l+2*s); + m = med3(x, m-s, m, m+s); + n = med3(x, n-2*s, n-s, n); + } + m = med3(x, l, m, n); // Mid-size, med of 3 + } + int v = x[m]; // the partition + + // Establish Invariant: v* (v)* v* (due to Sedgewick) + /* Index b scans up from the bottom of the array until it reaches a + * large element (greater than or equal to the partition value), + * c scans down until it reaches a small element. + * The two array elements are then swapped, and the scans continue until the pointers cross. + */ + int a = off, b = a, c = off + len - 1, d = c; + while(true) { + int comparison; + // while b < last index and x[b]<=x[median] + while (b <= c && (comparison=compare(x[b],v,isAscending))<=0) { + // if x[b]==x[median], x[start++]=x[b], x[b] = x[start++] + if (comparison == 0){ + swap(indices, a, b); + swap(x, a++, b); + } + // increment b + b++; + } + while (c >= b && (comparison=compare(x[c],v,isAscending))>=0) { + if (comparison == 0){ + swap(indices, c, d); + swap(x, c, d--); + } + c--; + } + /*At the end of the partitioning loop, b=c+1. + * Stop, and swap x[0] and x[j] */ + if (b > c) break; + swap(indices, b, c); + swap(x, b++, c--); + } + + // Swap partition elements back to middle + int s, n = off + len; + s = Math.min(a-off, b-a ); + vecswap(x, off, b-s, s); + vecswap(indices, off, b-s, s); + + s = Math.min(d-c, n-d-1); + vecswap(x, b, n-s, s); + vecswap(indices, b, n-s, s); + + + /* call quicksort recursively on the subarrays x[off]...x[b-a] + and x[end-(d-c)]...x[d-c] + */ + if ((s = b-a) > 1){ + quickSort1(x, indices, off, s, isAscending); + } + if ((s = d-c) > 1){ + quickSort1(x, indices, n-s, s, isAscending); + } + } + /* compare(a,b) returns (a-b) if isAscending. else returns b-a*/ + private static void quickSort2(int[] x, int[] y, int off, int len, boolean isAscending) { + //isAscendingnsertion sort on smallest arrays. (Checked, and works). + if (len < SMALL) { + for (int i=off; i x[j], swap the two + * so that the lower value (x[j]) is now at x[j-1]. + */ + for (int j=i; j>off && compare(x[j-1],x[j],isAscending)>0; j--){ + swap(x, j, j-1); + swap(y, j, j-1); + } + } + return; + } + // Larger arrays: + // Choose a partition element, v that's the median of the array. + int m = off + len/2; // Small arrays, middle element + if (len > SMALL) { + int l = off; // start + int n = off + len - 1; // end + if (len > MEDIUM) { // Big arrays, pseudomedian of 9 + int s = len/8; + l = med3(x, l, l+s, l+2*s); + m = med3(x, m-s, m, m+s); + n = med3(x, n-2*s, n-s, n); + } + m = med3(x, l, m, n); // Mid-size, med of 3 + } + int v = x[m]; // the partition + + // Establish Invariant: v* (v)* v* (due to Sedgewick) + /* Index b scans up from the bottom of the array until it reaches a + * large element (greater than or equal to the partition value), + * c scans down until it reaches a small element. + * The two array elements are then swapped, and the scans continue until the pointers cross. + */ + int a = off, b = a, c = off + len - 1, d = c; + while(true) { + int comparison; + // while b < last index and x[b]<=x[median] + while (b <= c && (comparison=compare(x[b],v,isAscending))<=0) { + // if x[b]==x[median], x[start++]=x[b], x[b] = x[start++] + if (comparison == 0){ + swap(y, a, b); + swap(x, a++, b); + } + // increment b + b++; + } + while (c >= b && (comparison=compare(x[c],v,isAscending))>=0) { + if (comparison == 0){ + swap(y, c, d); + swap(x, c, d--); + } + c--; + } + /*At the end of the partitioning loop, b=c+1. + * Stop, and swap x[0] and x[j] */ + if (b > c) break; + swap(y, b, c); + swap(x, b++, c--); + } + + // Swap partition elements back to middle + int s, n = off + len; + s = Math.min(a-off, b-a ); + vecswap(x, off, b-s, s); + vecswap(y, off, b-s, s); + + s = Math.min(d-c, n-d-1); + vecswap(x, b, n-s, s); + vecswap(y, b, n-s, s); + + + /* call quicksort recursively on the subarrays x[off]...x[b-a] + and x[end-(d-c)]...x[d-c] + */ + if ((s = b-a) > 1){ + quickSort2(x, y, off, s, isAscending); + } + if ((s = d-c) > 1){ + quickSort2(x, y, n-s, s, isAscending); + } + } + /* compare(a,b) returns (a-b) if isAscending. else returns b-a*/ + private static void quickSort1(double[] x, int[] indices, int off, int len, boolean isAscending) { + //isAscendingnsertion sort on smallest arrays. (Checked, and works). + if (len < SMALL) { + for (int i=off; i x[j], swap the two + * so that the lower value (x[j]) is now at x[j-1]. + */ + for (int j=i; j>off && compare(x[j-1],x[j],isAscending)>0; j--){ + swap(x, j, j-1); + swap(indices, j, j-1); + } + } + return; + } + // Larger arrays: + // Choose a partition element, v that's the median of the array. + int m = off + len/2; // Small arrays, middle element + if (len > SMALL) { + int l = off; // start + int n = off + len - 1; // end + if (len > MEDIUM) { // Big arrays, pseudomedian of 9 + int s = len/8; + l = med3(x, l, l+s, l+2*s); + m = med3(x, m-s, m, m+s); + n = med3(x, n-2*s, n-s, n); + } + m = med3(x, l, m, n); // Mid-size, med of 3 + } + double v = x[m]; // the partition + + // Establish Invariant: v* (v)* v* (due to Sedgewick) + /* Index b scans up from the bottom of the array until it reaches a + * large element (greater than or equal to the partition value), + * c scans down until it reaches a small element. + * The two array elements are then swapped, and the scans continue until the pointers cross. + */ + int a = off, b = a, c = off + len - 1, d = c; + while(true) { + double comparison; + // while b < last index and x[b]<=x[median] + while (b <= c && (comparison=compare(x[b],v,isAscending))<=0) { + // if x[b]==x[median], x[start++]=x[b], x[b] = x[start++] + if (comparison == 0){ + swap(indices, a, b); + swap(x, a++, b); + } + // increment b + b++; + } + while (c >= b && (comparison=compare(x[c],v,isAscending))>=0) { + if (comparison == 0){ + swap(indices, c, d); + swap(x, c, d--); + } + c--; + } + /*At the end of the partitioning loop, b=c+1. + * Stop, and swap x[0] and x[j] */ + if (b > c) break; + swap(indices, b, c); + swap(x, b++, c--); + } + + // Swap partition elements back to middle + int s, n = off + len; + s = Math.min(a-off, b-a ); + vecswap(x, off, b-s, s); + vecswap(indices, off, b-s, s); + + s = Math.min(d-c, n-d-1); + vecswap(x, b, n-s, s); + vecswap(indices, b, n-s, s); + + + /* call quicksort recursively on the subarrays x[off]...x[b-a] + and x[end-(d-c)]...x[d-c] + */ + if ((s = b-a) > 1){ + quickSort1(x, indices, off, s, isAscending); + } + if ((s = d-c) > 1){ + quickSort1(x, indices, n-s, s, isAscending); + } + } + /* compare(a,b) returns (a-b) if isAscending. else returns b-a*/ + private static void quickSort2(double[] x, double[] y, int off, int len, boolean isAscending) { + //isAscendingnsertion sort on smallest arrays. (Checked, and works). + if (len < SMALL) { + for (int i=off; i x[j], swap the two + * so that the lower value (x[j]) is now at x[j-1]. + */ + for (int j=i; j>off && compare(x[j-1],x[j],isAscending)>0; j--){ + swap(x, j, j-1); + swap(y, j, j-1); + } + } + return; + } + // Larger arrays: + // Choose a partition element, v that's the median of the array. + int m = off + len/2; // Small arrays, middle element + if (len > SMALL) { + int l = off; // start + int n = off + len - 1; // end + if (len > MEDIUM) { // Big arrays, pseudomedian of 9 + int s = len/8; + l = med3(x, l, l+s, l+2*s); + m = med3(x, m-s, m, m+s); + n = med3(x, n-2*s, n-s, n); + } + m = med3(x, l, m, n); // Mid-size, med of 3 + } + double v = x[m]; // the partition + + // Establish Invariant: v* (v)* v* (due to Sedgewick) + /* Index b scans up from the bottom of the array until it reaches a + * large element (greater than or equal to the partition value), + * c scans down until it reaches a small element. + * The two array elements are then swapped, and the scans continue until the pointers cross. + */ + int a = off, b = a, c = off + len - 1, d = c; + while(true) { + double comparison; + // while b < last index and x[b]<=x[median] + while (b <= c && (comparison=compare(x[b],v,isAscending))<=0) { + // if x[b]==x[median], x[start++]=x[b], x[b] = x[start++] + if (comparison == 0){ + swap(y, a, b); + swap(x, a++, b); + } + // increment b + b++; + } + while (c >= b && (comparison=compare(x[c],v,isAscending))>=0) { + if (comparison == 0){ + swap(y, c, d); + swap(x, c, d--); + } + c--; + } + /*At the end of the partitioning loop, b=c+1. + * Stop, and swap x[0] and x[j] */ + if (b > c) break; + swap(y, b, c); + swap(x, b++, c--); + } + + // Swap partition elements back to middle + int s, n = off + len; + s = Math.min(a-off, b-a ); + vecswap(x, off, b-s, s); + vecswap(y, off, b-s, s); + + s = Math.min(d-c, n-d-1); + vecswap(x, b, n-s, s); + vecswap(y, b, n-s, s); + + + /* call quicksort recursively on the subarrays x[off]...x[b-a] + and x[end-(d-c)]...x[d-c] + */ + if ((s = b-a) > 1){ + quickSort2(x, y, off, s, isAscending); + } + if ((s = d-c) > 1){ + quickSort2(x, y, n-s, s, isAscending); + } + } + + /** Ensures that sgn(compare(x, y)) == + * -sgn(compare(y, x)) for all x and y. (This + * implies that compare(x, y) must throw an exception if and only + * if compare(y, x) throws an exception.)

    + * + * The implementor must also ensure that the relation is transitive: + * ((compare(x, y)>0) && (compare(y, z)>0)) implies + * compare(x, z)>0.

    + * + * Finally, the implementer must ensure that compare(x, y)==0 + * implies that sgn(compare(x, z))==sgn(compare(y, z)) for all + * z.

    + * + */ + private static float compare(float value1, float value2, boolean isAscending) { + if (isAscending) return value1 - value2; + return value2 - value1; + } + private static double compare(double value1, double value2, boolean isAscending) { + if (isAscending) return value1 - value2; + return value2 - value1; + } + private static int compare(int value1, int value2, boolean isAscending) { + if (isAscending) return value1 - value2; + return value2 - value1; + } + /** Swaps x[a] with x[b]. */ + private static void swap(float x[], int a, int b) { + float t = x[a]; x[a] = x[b]; x[b] = t; + } + /** Swaps x[a] with x[b]. */ + private static void swap(double x[], int a, int b) { + double t = x[a]; x[a] = x[b]; x[b] = t; + } + /** Swaps x[a] with x[b]. */ + private static void swap(int x[], int a, int b) { + int t = x[a]; x[a] = x[b]; x[b] = t; + } + + /** Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].*/ + private static void vecswap(float x[], int a, int b, int n) { + for (int i=0; i toIndex) + throw new IllegalArgumentException("fromIndex(" + fromIndex + + ") > toIndex(" + toIndex+")"); + if (fromIndex < 0) + throw new ArrayIndexOutOfBoundsException("from index: "+fromIndex); + if (toIndex > arrayLen) + throw new ArrayIndexOutOfBoundsException("to index: "+toIndex); + } +} diff --git a/drawing/papaya/src/papaya/SubPlot.java b/drawing/papaya/src/papaya/SubPlot.java new file mode 100644 index 0000000..1ad1d1b --- /dev/null +++ b/drawing/papaya/src/papaya/SubPlot.java @@ -0,0 +1,192 @@ +/** + * papaya: A collection of utilities for Statistics and Matrix-related manipulations + * http://adilapapaya.com/papayastatistics/, 1.1.0 + * Created by Adila Faruk, http://adilapapaya.com, May 2012, Last Updated April 2014 + * + * + * Copyright (C) 2014 Adila Faruk http://adilapapaya.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package papaya; +import java.util.Arrays; +import java.io.*; +import java.lang.Object; +import java.lang.String; + +import processing.core.*; + +/** + * Convenient class for drawing multiple scatter plots. + * @author Adila Faruk + */ +public class SubPlot extends Visuals { + + /** + * Specifies whether to draw the bounding rectangle around the plot. + */ + public boolean drawRectangle = false; + /** + * Specifies whether to draw the axes + */ + public boolean drawAxes = true; + + /** + * Specifies the space on the left between the plot area, and the + * bounding rectangle. That is, the left-most point of + * the rectangle is given by plotLeft-leftBound. + */ + public float leftBound = 40; + /** + * Specifies the space on the right betweent the plot area, and the + * bounding rectangle. That is, the right-most point of + * the rectangle is given by plotLeft+plotWidth+rightBound. + */ + public float rightBound=20; + /** + * Specifies the space on the top, between the plot area and the bounding + * rectangle. That is, the top-most point of the rectangle is given by + * plotTop - topBound. + */ + public float topBound = 20; + /** + * Specifies the space on the bottom, between the plot area and the bounding + * rectangle. That is, the bottom-most point of the rectangle is given by + * plotTop + plotHeight + bottomBound. + */ + public float bottomBound=20; + + + private PApplet myParent; + + + //CENTER = 3; BOTTOM = 102; TOP = 101; BASELINE = 0; LEFT = 37; RIGHT = 39; + + + boolean dataExtremesHaveBeenSet=false; + public float[][] xLefts; public float[][] yTops; + public float xW; public float yH; + public float ySpacing = 80; + public float xSpacing = 100; + public ScatterPlot[][] s; + + + /** + Creates numX*numY plots, each of with xWidth, and height yHeight. + subplot(1,1) has its top left corner situated at xLeft, yTop. + subplot(1,2) has its top left corner situated at xLeft, yTop + yHeight + yInterval. + ... + ... + subplot(1,numY) has its top left corner situated at xLeft, yTop + (numY-1)*(yHeight+ySpacing) + + */ + public SubPlot(PApplet theParent, float xLeft, float yTop, float xWidth, float yHeight, int numX, int numY) { + super(theParent,xLeft,yTop,xWidth,yHeight); + myParent = theParent; + xLefts = new float[numX][numY]; + yTops = new float[numX][numY]; + s = new ScatterPlot[numX][numY]; + + // get the x and y spacing. + yH = (yHeight - (numY-1)*ySpacing)/numY; + xW = (xWidth-(numX-1)*xSpacing)/numX; + + for (int i=0; iunsorted array's unique elements, + * the indices of these elements, and the number of times the elements occur. + *

    This class is overkill if: + *
    + * you want to store only the unique elements. Use a Java + * Set instead. + *
    + * you don't want to store everything in a class. Use the + * {@link Descriptive#frequencies} method instead. + */ +public class Unique { + + /** + * ArrayList containing the unique values + */ + public ArrayList values = new ArrayList(); + /** + * ArrayList containing the frequencies of the corresponding unique value + */ + public ArrayList frequencies = new ArrayList(); + /** + * Class containing the integer arrays that hold the indices of each unique value. + */ + public int[][] idx; + + /** + * Class for storing the unique values in an unsorted data array. Does essentially the same + * thing as the Descriptive.frequencies method would, except: + *


    + * - The input data array is unsorted. + *
    + *
    + * - You can choose to store the indices of each unique value as well by setting the @param storeIndices + * to true. + *
    + *
    + * - It (currently) only works for float arrays. + *
    + *

    Example:

    + *

    + * data = (8,5,6,7,8,5,5) --> values = (5,6,7,8), frequencies = (3,1,1,2), + * idx[0] = {1,5,6}, idx[1] = {2}, idx[2] = {3}, idx[3] = {0,4} + *

    + * + * @param data the data array + * @param storeIndices set to true if you want to store the indices, + * else set to false + * It: + *
    + * 1. Contains some useful functions for the visual representation + * of your data (e.g. setting up your font, writing labels, mapping + * arrays to the plot right-left-top-bottom parameters, xTicks, yTicks, + * etc.) that should help you reduce the amount of code you end up + * writing. + *
    + * 2. Is extended by the available "Plotting" classes used to quickly give a + * visual snapshot of your data. + *

    + * + */ + +public class Visuals implements PapayaConstants{ + + /* + * Processing applet + */ + protected PApplet myParent; + + PFont plotFont = new PFont(); + + + // protected variables ------------------------------------------- + // can be set only using get/set methods + // or in the constructor + + protected float plotLeft=10; + protected float plotWidth=180; + + protected float plotTop=10; + protected float plotHeight=180; + + /** + * Specifies the plot background color + */ + public int bgColor = GRAY[4]; + + //CENTER = 3; BOTTOM = 102; TOP = 101; BASELINE = 0; LEFT = 37; RIGHT = 39; + + /** The parent class behind the other plotting classes. + * + *

    + * Visuals contains some useful functions for the (elementary!) visual representation + * of your data (e.g. setting up your font, writing labels, mapping + * arrays to the plot right-left-top-bottom parameters, xTicks, yTicks,legends, + * etc). Nothing very fancy like writing x-labels at an angle or computing your + * tax returns for you though so don't get your hopes up. Sorry. + * + * + * @param _theParent the Processing papplet. Just "this" in your sketch. + * @param _plotLeft the plot left + * @param _plotTop the plot top (in Processing coordinates!) + * @param _plotWidth the plot width + * @param _plotHeight the plot height. + *

    The bottom of the plot area is then given by _plotTop + _plotHeight + * while the right is _plotLeft + _plotWidth.

    + */ + public Visuals(PApplet _theParent, float _plotLeft, float _plotTop, float _plotWidth, float _plotHeight){ + myParent = _theParent; + plotLeft = _plotLeft; + plotWidth = _plotWidth; + plotTop = _plotTop; + plotHeight = _plotHeight; + plotFont = myParent.createFont(FONTNAME,12f,true); + } + + /** + * Maps the x-data from the range min(data) to max(data) to + * the plotLeft and plotLeft+plotWidth. That is, + * mappedData[i] = plotLeft + (data[i] - min) / (max-min) * plotWidth. + * This is not done directly though, but rather, the + * {@link Mat#map(float[] data, float low1, float high1, float low2, float high2)} + * function is used. + * @param data the x data to map. + * @return the mapped data. + */ + public float[] mapXData(float[] data){ + float min = Descriptive.min(data); + float max = Descriptive.max(data); + return Mat.map( data,min,max,plotLeft,plotLeft + plotWidth); + } + /** + * Maps the x-data from the range minXDat to maxXDat to + * the plotLeft and plotRight. That is, + * mappedData[i] = plotLeft + (data[i] - minXDat) / (maxXDat-minXDat) * plotWidth. + * This is not done directly though, but rather, the + * {@link Mat#map(float[] data, float low1, float high1, float low2, float high2)} + * function is used. + *

    + * Note: No internal checks are done to make sure that the min/max values are in the + * data range. + *

    + * + * @param data the x data to map. + * @param minXDat the minimum value to use in the data mapping. + * @param maxXDat the maximum value to use in the data mapping. + * @return the mapped data. + */ + public float[] mapXData(float[] data, float minXDat, float maxXDat){ + return Mat.map( data,minXDat,maxXDat,plotLeft,plotLeft + plotWidth); + } + + /** + * Maps the y-data from the range min(data) to max(data) to + * the plotBottom and plotTop. That is, + * mappedData[i] = plotBottom + (data[i] - min) / (max-min) * (-plotHeight). + * (The minus sign above accounts for the difference in Processing's coordinate system + * and what we associate with Top/Bottom). + * The computation above is not done directly though, but rather, the + * {@link Mat#map(float[] data, float low1, float high1, float low2, float high2)} + * function is used. + * @param data the y data to map. + * @return the mapped data. + */ + public float[] mapYData(float[] data){ + float min = Descriptive.min(data); + float max = Descriptive.max(data); + return Mat.map( data, min, max, plotTop + plotHeight, plotTop); + } + + /** + * Maps the y-data from the range minYDat to maxYDat to + * the plotBottom and plotTop. That is, + * mappedData[i] = plotBottom + (data[i] - minYDat) / (maxYDat-minYDat) * (-plotHeight). + * (The minus sign above accounts for the difference in Processing's coordinate system + * and what we associate with Top/Bottom). + * The computation above is not done directly though, but rather, the + * {@link Mat#map(float[] data, float low1, float high1, float low2, float high2)} + * function is used. + *

    + * Note: No internal checks are done to make sure that the min/max values are in the + * data range. + *

    + * + * @param data the x data to map. + * @param minYDat the minimum value to use in the data mapping. + * @param maxYDat the maximum value to use in the data mapping. + * @return the mapped data. + */ + public float[] mapYData(float[] data, float minYDat, float maxYDat){ + return Mat.map( data,minYDat,maxYDat,plotTop + plotHeight, plotTop); + } + + + /** + * Draws the plot axes using a line with color _sColor, and weight _sWeight + */ + public void drawAxes(int _sColor, float _sWeight){ + horizLine(plotLeft,plotLeft+plotWidth,plotTop+plotHeight,_sColor,_sWeight); + vertLine(plotTop,plotTop+plotHeight,plotLeft,_sColor,_sWeight); + } + + /** + * Draw the plot background rectangle using the default plot + * dimensions and background color. + * + *
  • Left most point: plotLeft
  • + *
  • Top most point: plotTop
  • + *
  • Width: plotWidth
  • + *
  • Height: plotHeight
  • + * + */ + public void drawRect(){ + drawRect(plotLeft,plotTop,plotWidth,plotHeight,bgColor); + } + + /** + * Draws the plot background rectangle using the input dimensions and + * background color. + * @param _left the left-most point of the rectangle + * @param _top the top-most point of the rectangle + * @param _width the width of the rectangle + * @param _height the height of the rectangle + * @param _rectColor the rectangle color. + */ + public void drawRect(float _left,float _top,float _width,float _height, int _rectColor){ + myParent.stroke(150); + myParent.strokeWeight(.5f); + myParent.fill(_rectColor); + myParent.pushStyle(); + myParent.rectMode(CORNER); + myParent.rect(_left,_top,_width,_height); + myParent.popStyle(); + } + + /** + * Draws a legend going downwards with the first element situated at (x,y). + * Useful for situations where you are plotting more than one dataset. + * + * @param colors the legend colors + * @param labels labels that go with each color + */ + public void legendVert(float x, float y, int[] colors, String[] labels){ + int num = labels.length; + if(num != colors.length) throw new IllegalArgumentException("The label and color arrays have different lengths"); + + myParent.textAlign(LEFT,TOP); + + for(int i=0; i