Java Code Examples for cern.colt.list.DoubleArrayList#set()

The following examples show how to use cern.colt.list.DoubleArrayList#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UnknownDoubleQuantileEstimator.java    From database with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Computes the specified quantile elements over the values previously added.
 * @param phis the quantiles for which elements are to be computed. Each phi must be in the interval (0.0,1.0]. <tt>phis</tt> must be sorted ascending.
 * @return the approximate quantile elements.
 */
public DoubleArrayList quantileElements(DoubleArrayList phis) {
	if (precomputeEpsilon<=0.0) return super.quantileElements(phis);
	
	int quantilesToPrecompute = (int) Utils.epsilonCeiling(1.0 / precomputeEpsilon);
	/*
	if (phis.size() > quantilesToPrecompute) {
		// illegal use case!
		// we compute results, but loose explicit approximation guarantees.
		return super.quantileElements(phis);
	}
	*/
 
	//select that quantile from the precomputed set that corresponds to a position closest to phi.
	phis = phis.copy();
	double e = precomputeEpsilon;
	for (int index=phis.size(); --index >= 0;) {
		double phi = phis.get(index);
		int i = (int) Math.round( ((2.0*phi/e) - 1.0 ) / 2.0); // finds closest
		i = Math.min(quantilesToPrecompute-1, Math.max(0,i));
		double augmentedPhi = (e/2.0)*(1+2*i);
		phis.set(index,augmentedPhi);				
	}
	
	return super.quantileElements(phis);
}
 
Example 2
Source File: UnknownDoubleQuantileEstimator.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Computes the specified quantile elements over the values previously added.
 * @param phis the quantiles for which elements are to be computed. Each phi must be in the interval (0.0,1.0]. <tt>phis</tt> must be sorted ascending.
 * @return the approximate quantile elements.
 */
public DoubleArrayList quantileElements(DoubleArrayList phis) {
	if (precomputeEpsilon<=0.0) return super.quantileElements(phis);
	
	int quantilesToPrecompute = (int) Utils.epsilonCeiling(1.0 / precomputeEpsilon);
	/*
	if (phis.size() > quantilesToPrecompute) {
		// illegal use case!
		// we compute results, but loose explicit approximation guarantees.
		return super.quantileElements(phis);
	}
	*/
 
	//select that quantile from the precomputed set that corresponds to a position closest to phi.
	phis = phis.copy();
	double e = precomputeEpsilon;
	for (int index=phis.size(); --index >= 0;) {
		double phi = phis.get(index);
		int i = (int) Math.round( ((2.0*phi/e) - 1.0 ) / 2.0); // finds closest
		i = Math.min(quantilesToPrecompute-1, Math.max(0,i));
		double augmentedPhi = (e/2.0)*(1+2*i);
		phis.set(index,augmentedPhi);				
	}
	
	return super.quantileElements(phis);
}
 
Example 3
Source File: KnownDoubleQuantileEstimator.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 */
protected DoubleArrayList preProcessPhis(DoubleArrayList phis) {
	if (beta>1.0) {
		phis = phis.copy();
		for (int i=phis.size(); --i >=0;) {
			phis.set(i, (2*phis.get(i) + beta - 1) / (2*beta));
		}		
	}
	return phis;
}
 
Example 4
Source File: KnownDoubleQuantileEstimator.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 */
protected DoubleArrayList preProcessPhis(DoubleArrayList phis) {
	if (beta>1.0) {
		phis = phis.copy();
		for (int i=phis.size(); --i >=0;) {
			phis.set(i, (2*phis.get(i) + beta - 1) / (2*beta));
		}		
	}
	return phis;
}
 
Example 5
Source File: QuantileBin1D.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
Divides (rebins) a copy of the receiver at the given <i>interval boundaries</i> into bins and returns these bins, such that each bin <i>approximately</i> reflects the data elements of its range.

For each interval boundary of the axis (including -infinity and +infinity), computes the percentage (quantile inverse) of elements less than the boundary.
Then lets {@link #splitApproximately(DoubleArrayList,int)} do the real work.

@param axis an axis defining interval boundaries.
@param resolution a measure of accuracy; the desired number of subintervals per interval. 
*/
public synchronized MightyStaticBin1D[] splitApproximately(hep.aida.IAxis axis, int k) {
	DoubleArrayList percentages = new DoubleArrayList(new hep.aida.ref.Converter().edges(axis));
	percentages.beforeInsert(0,Double.NEGATIVE_INFINITY);
	percentages.add(Double.POSITIVE_INFINITY);
	for (int i=percentages.size(); --i >= 0; ) {
		percentages.set(i, quantileInverse(percentages.get(i)));
	}
	
	return splitApproximately(percentages,k); 
}