package DataStructure; class ratioElem { SingleBTS top; SingleBTS bottom; double ratioDL; double ratioUL; double varDL; double varUL; public ratioElem(SingleBTS top, SingleBTS bottom) { // if (top==null||bottom==null){ // return null; // } this.top = top; this.bottom = bottom; // double topUL = top.getDldB(); // double bottomUL = bottom.getDldB(); // ratioDL = top.getDldB() - bottom.getDldB(); ratioDL = top.getStrictDLdBAverage() - bottom.getStrictDLdBAverage(); ratioUL = top.getUldB() - bottom.getUldB(); // varDL = Math.sqrt(Math.pow(top.getVarianceDLdB(), 2)); // - Math.pow(bottom.getVarianceDLdB(), 2)); // varUL = Math.sqrt(Math.pow(top.getVarianceULdB(), 2) // - Math.pow(bottom.getVarianceULdB(), 2)); varDL = top.getVarianceDLdB() + bottom.getVarianceDLdB(); varUL = top.getVarianceULdB() + bottom.getVarianceULdB(); // if (varDL != 0 && varDL != Double.NaN) { // System.out.println("var ungleich 0"); // } } public String toString() { return "RatioDL: " + ratioDL + ", varDl: " + varDL + " (" + top.ARFCN + "-" + bottom.ARFCN + ")"; } public double probability(ratioElem vector) { if (top.ARFCN != vector.top.ARFCN || bottom.ARFCN != vector.bottom.ARFCN) { System.out.println("Sortierung falsch!"); } if (Double.isNaN(vector.ratioDL) || Double.isNaN(this.ratioDL)) { System.out.println("das sollte nicht passieren"); if (Double.isNaN(vector.ratioDL) && Double.isNaN(this.ratioDL)) { // ratio between both bts cannot been built. This means top or // bottom bts is not received. let's say a cell phone has a poor // antenna, than this would not neccesarily mean that the // probability of beeing there is one. It can although be used // to // boost the probability return 1; } else return 0; } if (vector.varDL == 0 && this.varDL == 0) { if (Math.abs(vector.ratioDL - this.ratioDL) <= 1) { return 1; } else { return 0; } } /* * if (this.ratioDL == Double.NaN && vector.ratioDL == Double.NaN) { * return 1; } else if (this.ratioDL != Double.NaN && vector.ratioDL == * Double.NaN) { return Double.MIN_VALUE; } else if (this.ratioDL == * Double.NaN && vector.ratioDL != Double.NaN) { return * Double.MIN_VALUE; } else if (this.ratioDL == 0 && vector.ratioDL == * 0) { return 1; } else if (this.ratioDL == 0 && vector.ratioDL == * Double.NaN) { return 1; } else if (this.ratioDL == Double.NaN && * vector.ratioDL == 0) { return 1; } * * else */if (vector.varDL == 0 && this.varDL != 0) { // compute just value at given point. No integration! double std = Math.sqrt(varDL); double x = vector.ratioDL; double u = this.ratioDL; double sqrtPI = Math.sqrt(2 * Math.PI); double exp = Math.exp(-0.5 * Math.pow((x - u) / std, 2)); double result = (1 / (std * sqrtPI)) * exp; if (Double.isNaN(result)) return 0; return result; } else if (this.varDL == 0 && vector.varDL != 0) { // compute just value at given point. No integration! double std = Math.sqrt(vector.varDL); double x = ratioDL; double u = vector.ratioDL; double sqrtPI = Math.sqrt(2 * Math.PI); double exp = Math.exp(-0.5 * Math.pow((x - u) / std, 2)); double result = (1 / (std * sqrtPI)) * exp; if (Double.isNaN(result)) return 0; return result; } else { // integration! // System.out.println("Integration now implemented!"); return new NormDistribution(ratioDL, varDL) .intersection(new NormDistribution(vector.ratioDL, vector.varDL)); } } }