00001 package commandline.Distributions;
00002
00003 import junit.framework.Assert;
00004
00005 import commandline.ImageStuff.GeometricObjects.GenericEdge;
00006
00007 public class NormalIndicesDistribution_1A_paper extends
00008 NormalIndicesDistribution {
00009 VerticalDistribution verticalDistribution_discr;
00010 public NormalIndicesDistribution_1A_paper(VerticalDistribution verticalDistribution_discr) {
00011 super();
00012 this.verticalDistribution_discr=verticalDistribution_discr;
00013
00014 }
00015
00016 @Override
00017 protected double evaluatePDF(double x, float n_0,
00018 float n_1, GenericEdge edge) {
00019 float lambda_streep=verticalDistribution_discr.getSchatter();
00020 double H=edge.getHoogte();
00021 double length=edge.getEuclidischeLengte();
00022 double i=x-length/2;
00023 if(i>=0){
00024 if(i<H*H/(2*length)){ return getPartI_right(i,H,length,lambda_streep,n_0,n_1);}
00025 else {return getPartII_right(i,H,length,lambda_streep,n_0,n_1);}
00026 }else{
00027 if(Math.abs(i)<H*H/(2*length)){ return getPartI_left(i,H,length,lambda_streep,n_0,n_1);}
00028 else {return getPartII_left(i,H,length,lambda_streep,n_0,n_1);}
00029 }
00030 }
00031
00032
00043 private double getPartI_right(double x, double H, double length,
00044 float lambda_streep, float n_0, float n_1){
00045 Assert.assertTrue(x>=0);
00046 double h_0=super.scaleLambaEstimator(lambda_streep,n_0);
00047 double h_1=super.scaleLambaEstimator(lambda_streep,n_1);
00048 double i=x;
00049 double l=length;
00050 double prob=-(-(float)Math.exp((0.2e1f * (0.1e1f / H * i * l - H / 0.2e1f) * h_0 * H + 0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) - (float)Math.exp((0.1e1f / H * i * l - H / 0.2e1f) * h_0 + (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 + H * h_1) + 0.2e1f * (float)Math.exp((0.2e1f * (0.1e1f / H * i * l - H / 0.2e1f) * h_0 * H + 0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + H * H * h_1 + h_1 * l * l) / H / 0.2e1f) - (float)Math.exp(0.1e1f / H * h_1 * l * l / 0.2e1f) + 0.2e1f * (float)Math.exp(H * h_1 + (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0) + 0.2e1f * (float)Math.exp((0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) - (float)Math.exp(H * h_1) - 0.4e1f * (float)Math.exp((H * H * h_1 + 0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) + 0.2e1f * (float)Math.exp(h_1 * (H * H + l * l) / H / 0.2e1f)) / l * (float)Math.exp(-(H * H * h_1 + 0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) / 0.4e1f + h_0 * (l - 0.2e1f * i) * (float)Math.exp(-h_0 / H * Math.abs(-0.2e1f * i * l + H * H) / 0.2e1f) / l / 0.4e1f;
00051 return prob;
00052 }
00053
00064 private double getPartII_right(double x, double H, double length,
00065 float lambda_streep, float n_0, float n_1){
00066 Assert.assertTrue(x>=0);
00067 double h_0=super.scaleLambaEstimator(lambda_streep,n_0);
00068 double h_1=super.scaleLambaEstimator(lambda_streep,n_1);
00069 double i=x;
00070 double l=length;
00071 double prob= -((float)Math.exp((0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) + (float)Math.exp(H * h_1 + (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0) - 0.2e1f * (float)Math.exp((H * H * h_1 + 0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) - (float)Math.exp((0.2e1f * (0.1e1f / H * i * l - H / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f) - (float)Math.exp(H * h_1 + (0.1e1f / H * i * l - H / 0.2e1f) * h_0) + 0.2e1f * (float)Math.exp((H * H * h_1 + 0.2e1f * (0.1e1f / H * i * l - H / 0.2e1f) * h_0 * H + h_1 * l * l) / H / 0.2e1f)) / l * (float)Math.exp(-(0.2e1f * (0.1e1f / H * i * l - H / 0.2e1f) * h_0 * H + 0.2e1f * (-H / 0.2e1f + 0.1e1f / H * l * l / 0.2e1f) * h_0 * H + H * H * h_1 + h_1 * l * l) / H / 0.2e1f) / 0.4e1f + h_0 * (l - 0.2e1f * i) * (float)Math.exp(-h_0 / H * Math.abs(-0.2e1f * i * l + H * H) / 0.2e1f) / l / 0.4e1f;
00072 return prob;
00073 }
00074
00075 private double getPartI_left(double x, double H, double length,
00076 float lambda_streep, float n_0, float n_1){
00077 Assert.assertTrue(x<0);
00078 double prob= getPartI_right(Math.abs(x), H, length,
00079 lambda_streep, n_1, n_0);
00080 return prob;
00081 }
00082
00083 private double getPartII_left(double x, double H, double length,
00084 float lambda_streep, float n_0, float n_1){
00085 Assert.assertTrue(x<0);
00086 double prob= getPartII_right(Math.abs(x), H, length,
00087 lambda_streep, n_1, n_0);
00088 return prob;
00089 }
00090 }