public YIntervalSeries getYIntervalSeries(String rowname, long factor) { YIntervalSeries mydataset = new YIntervalSeries(rowname); double sdcount = 0; double total = 0; Vector<Double> totalvalues = new Vector<Double>(); double avgtotal = 0; double minus = 0; double plus = 0; double zero = 0; for (Integer key : ysum.keySet()) { Double value = ysum.get(key) / (double) count.get(key); Double point = (double) xsum.get(key) / (double) count.get(key); Vector<Double> listofvalues = values.get(key); double sumofdiff = 0.0; for (Double onevalue : listofvalues) { sumofdiff += Math.pow(onevalue - value, 2); sdcount++; total += Math.pow(onevalue, 2); avgtotal += onevalue; totalvalues.add(onevalue); if (onevalue == 1) { plus++; } ; if (onevalue == -1) { minus++; } ; if (onevalue == 0) { zero++; } ; } double sd = Math.sqrt(sumofdiff / count.get(key)); // mydataset.add(point/factor, value,value+sd,value-sd); // mydataset.add(point/factor, value,value,value); mydataset.add( point / factor, value, value + 1.96 * (sd / Math.sqrt(count.get(key))), value - 1.96 * (sd / Math.sqrt(count.get(key)))); } double sdtotal = 0; double avgsd = total / sdcount; double test = 0; for (Double onevalue : totalvalues) { sdtotal += Math.pow(Math.pow(onevalue, 2) - (total / sdcount), 2); test += onevalue; } // System.out.println(rowname+" mean square: "+avgsd+" // +/-95%:"+1.96*Math.sqrt(sdtotal/sdcount)/Math.sqrt(sdcount)); // System.out.println("total -1:"+minus+" total +1:"+plus+" zero: "+zero // +" total:"+sdcount); return mydataset; }
/** epsilon efektywny wg skryptu Misiaszka - wzor dzielony */ private double FEPSM(double er, double h, double w, double t) { if (w / h < 1) { return (er + 1) / 2 + ((er - 1) / 2) * (1 / Math.sqrt(1 + 12 * h / w) + 0.04 * (1 - w / h) * (1 - w / h)) - (er - 1) / 4.6 * t / (h * Math.sqrt(w / h)); } else { return (er + 1) / 2 + ((er - 1) / 2) / (Math.sqrt(1 + 12 * h / w)) - (er - 1) / 4.6 * t / (h * Math.sqrt(w / h)); } }
static { // data[] is a bitmap image of the ball of radius R data = new byte[R * 2 * R * 2]; for (int Y = -R; Y < R; Y++) { int x0 = (int) (Math.sqrt(R * R - Y * Y) + 0.5); for (int X = -x0; X < x0; X++) { // sqrt(x^2 + y^2) gives distance from the spot light int x = X + hx, y = Y + hy; int r = (int) (Math.sqrt(x * x + y * y) + 0.5); // set the maximal intensity to the maximal distance // (in pixels) from the spot light if (r > maxr) maxr = r; data[(Y + R) * (R * 2) + (X + R)] = (r <= 0) ? 1 : (byte) r; } } }
public static double getDist(Atom a, Atom b) { double xDist = a.getPoint().x - b.getPoint().x; double yDist = a.getPoint().y - b.getPoint().y; double dist = Math.sqrt((xDist * xDist) + (yDist * yDist)); return dist; }
private void normalize(double[] vector) { double length = Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1] + vector[2] * vector[2]); vector[0] /= length; vector[1] /= length; vector[2] /= length; }
public static double dist(double long1, double lat1, double long2, double lat2) { double R = 6371; // earth radius in km double long_diff = Math.toRadians(long2 - long1); double lat_diff = Math.toRadians(lat2 - lat1); lat1 = Math.toRadians(lat1); lat2 = Math.toRadians(lat2); double temp1 = Math.sin(lat_diff / 2) * Math.sin(lat_diff / 2) + Math.sin(long_diff / 2) * Math.sin(long_diff / 2) * Math.cos(lat1) * Math.cos(lat2); return 2 * R * Math.asin(Math.sqrt(temp1)); }
public static double length(Vector vector) { return Math.sqrt(vector.getA() * vector.getA() + vector.getB() * vector.getB()); }
// to measure euclidean distance (not yet used) final int distance(int x, int y, int i, int j) { double dis = Math.sqrt((x - i) * (x - i) + (y - j) * (y - j)); return (int) Math.round(dis); }
public static float norm(float[] v) { return (float) Math.sqrt(dot(v, v)); }
/** epsilon efektywny */ private double FEPS(double er, double h, double w, double t) { return (er + 1) / 2 + ((er - 1) / 2) / (Math.sqrt(1 + 10 * h / w)) - (er - 1) / 4.6 * t / (h * Math.sqrt(w / h)); }
/** wyliczenie Z0 dla w/h >= 1 */ private double FZ2(double epf, double we, double h) { FZType = "FZ2"; /* slad - ktory wzor byl ostatni */ return 376.7 / (Math.sqrt(epf) * (we / h + 1.393 + 0.667 * Math.log(we / h + 1.444))); }
/** wyliczenie Z0 dla w/h <= 1 */ private double FZ1(double epf, double we, double h) { FZType = "FZ1"; /* slad - ktory wzor byl ostatni */ return 60 / Math.sqrt(epf) * Math.log(8 * h / we + 0.25 * we / h); }
public double getStd() { return Math.sqrt(getVar()); }
static int squareroot(double x) { double a = Math.sqrt(x); return (int) a; }