package uk.ac.leeds.ccg.cluster; import java.awt.*; import java.awt.event.*; import java.util.*; //import com.sun.java.util.collections.*; //change for 1.2! import uk.ac.leeds.ccg.geotools.*; // import uk.ac.leeds.ccg.geotools.classification.*; /** A class that implements Besag and Newell Cluster Hunt * The main class BandN creates the main frame and proivides 3 buttons * modified to use the new results object - 31/01/01 */ public class Larsen extends SimpleMethod implements Method, Runnable { // Members LarsenTimeParameters parameters; LarsenTimeParametersViewer parametersViewer; Database database; Results results; Viewer viewer; // Geotools viewer GeoRectangle geoRectangle = null; // Geotools geoRectangle Shader shader; // Geotools shader EqualInterval2 equalinterval2; // Methods public static void main(String args[]){ Larsen larsen = new Larsen(); larsen.run(); } public Larsen(){ parameters = new LarsenTimeParameters(); parametersViewer = new LarsenTimeParametersViewer(parameters); } public String toString() {return "Larsen";} public Parameters getParameters() {return parameters;} public ParametersViewer getParametersViewer() {return parametersViewer;} public void setShader(Shader s) {shader=s;} public void setViewer(Viewer v) {viewer=v;} public void setData(Database d) {database=d;} public SignificanceTest getSignificanceTest(){return significanceTest;} public void setSearch(GeoRectangle r) {geoRectangle=r;} public Results getResults(){return results;} public void run(){ int ecells = 0, cells = 0, yr1 = 0, K = 0; double EK, VarK, Z; int r, r1, m=0, dm, t, N = 0; double prob = 0., p; double bL, bU, to, from; results = new Results(); int numbin = parameters.getNumBin(); double bin[] = new double[numbin]; double mintime = parameters.getStartTime(); double maxtime = parameters.getEndTime(); double thresh = parameters.getSignificanceThreshold(); double norm[] = {0.0, 1.645, 1.75, 1.88, 2.05, 2.32, 2.37, 2.41, 2.46, 2.51, 2.57, 2.65, 2.75, 2.88, 3.09, 3.29}; double thre[] = {0.5, 0.05, 0.04, 0.03, 0.02, 0.01, 0.009, 0.008, 0.007, 0.006, 0.005, 0.004, 0.003, 0.002, 0.001, 0.0005}; // MyPoint p; double stat = (double) 0.0; // System.out.println("Larsen "+significanceTest); // if (significanceTest == null) { // System.out.println("Larsen started with a null sig test using Poisson"); // significanceTest = new PoissonTest(); // significanceTest.setParameters(parameters); // } System.out.println(""+this+" "+significanceTest); GeoData gcases = database.getCaseVals(); // Vector tcases = database.getCases(); Vector points = database.getPoints(); equalinterval2 = new EqualInterval2(gcases, numbin, mintime, maxtime); for (int j=0; j= bU || to < bL) continue; if (from < mintime) from=mintime; if (to > maxtime) to = maxtime; if (to == from){ bin[j]++; continue; } double length = to - from; if (from <= bL){ if (to < bU) bin[j] += (to - bL)/length; else bin[j] += (bU - bL)/length; } else{ if (to < bU) bin[j] += 1.; else bin[j] += (bU - from)/length; } } // System.out.println(bin[j]); } // for (int i=1; i<=gcases.getSize(); i++){ // if (gcases.getValue(i) < mintime || gcases.getValue(i) > maxtime) continue; // bin[ equalinterval2.classify((double) gcases.getValue(i)) ]++; // } for (int i=0; i