Can we get some ECDF functions added to the Tools.Internal?
So far I've got this to help with visualizations, but could be useful for others as well:
`
/**
Returns the ECDF y-values given data and associated xvalues
@param data data to compute the ecdf on
@param ecdf_xvals x values for the ecdf range (note: this can be calculated once which is why it isn't in the function itself given data min, max and length)
@return
*/
public static double[] getECDF(double[] data, double[] ecdf_xvals) {
double tmpVal;
double[] yvals= new double[ecdf_xvals.length];
for (int i = 0; i < ecdf_xvals.length; i++) {
tmpVal=ECDFhelper(data, ecdf_xvals[i]); // Get all of the values <= X value
yvals[i]=tmpVal/data.length;
}
return(yvals);
}
/**
Subsets values of the data array for values <= value of interest
@param data data to compute the ecdf on
@param x x value for computing this specific probability
@return
*/
public static double ECDFhelper(double[] data, double x){
double count =0;
for (int i = 0; i < data.length; i++) {
if(data[i]<=x){
count+=1;
}
}
return(count);
}
/**
Get the x values to use for an ecdf calculation...
@param x The raw data array used for ecdf calculations
*/
public static double[] getECDF_XPoints(double[] x){
Array.sort(x);
double[] xnew = Arrays.stream(x).distinct().toArray(); // unique values only
return(xnew);
}
`
Can we get some ECDF functions added to the Tools.Internal?
So far I've got this to help with visualizations, but could be useful for others as well:
` /**
@return */ public static double[] getECDF(double[] data, double[] ecdf_xvals) { double tmpVal; double[] yvals= new double[ecdf_xvals.length]; for (int i = 0; i < ecdf_xvals.length; i++) { tmpVal=ECDFhelper(data, ecdf_xvals[i]); // Get all of the values <= X value yvals[i]=tmpVal/data.length; } return(yvals); }
/**
@return */ public static double ECDFhelper(double[] data, double x){ double count =0; for (int i = 0; i < data.length; i++) { if(data[i]<=x){ count+=1; } } return(count); }
/**