/** * max * @param values values in int * @return max */ public static int max( int[] values ) { return max(values, 0, values.length); }
/** * Mean * * @return mean */ public int mean() { return Int.mean(values, end); }
/** * Calculate Median * @param values values * @return median */ public static int median(int[] values) { return median(values, 0, values.length); }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ public static int[] slc( int[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); final int newLength = end - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, end index %d, length %d", startIndex, endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
return add( array, v ); final int index = calculateIndex( array, idx );
/** * Sum * Provides overflow protection. * @param values values in int * @return sum */ public static int sum( int[] values, int length ) { return sum( values, 0, length); }
/** * Returns the value at the given index. * @param array the array you are getting the from. * @return the value */ public static int idx( final int[] array, final int index ) { final int i = calculateIndex( array, index ); return array[ i ]; }
/** * Min * @param values values in int * @return min */ public static int min( int[] values, int length ) { return min(values, 0, length); }
/** * variance * * @return variance */ public int variance() { return Int.variance(values, end); }
/** * Sum * Provides overflow protection. * @param values values in int * @return sum */ public static long bigSum( int[] values, int length ) { return bigSum(values, 0, length); }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ public static int[] endSliceOf( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ public static int[] sliceOf( int[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); final int newLength = end - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, end index %d, length %d", startIndex, endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }
return add( array, v ); final int index = calculateIndex( array, idx );
/** * Sums the values with bounds checking. * @return sum */ public int sum() { return Int.sum(values, end); }
/** * Returns the value at the given index. * @param array the array you are getting the from. * @return the value */ public static int idx( final int[] array, final int index ) { final int i = calculateIndex( array, index ); return array[ i ]; }
/** * Min * @param values values in int * @return min */ public static int min( int[] values, int length ) { return min(values, 0, length); }
/** * Calculate standard deviation. * * @return standard deviation */ public static double standardDeviation(Collection<?> inputList, String propertyPath) { double variance = variance(inputList, propertyPath); return Math.round(Math.sqrt(variance)); }
/** * Sum * Provides overflow protection. * @param values values in int * @return sum */ public static long bigSum( int[] values, int length ) { return bigSum(values, 0, length); }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param endIndex the end index of the slice * @return the new slice */ public static int[] endSliceOf( int[] array, int endIndex ) { final int end = calculateEndIndex( array, endIndex ); final int newLength = end; // + (endIndex < 0 ? 1 : 0); if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, length %d", endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, 0, newArray, 0, newLength ); return newArray; }
/** * Grabs a slice of this array * @param array the array you are getting slice from * @param startIndex the start index of the slice * @param endIndex the end index of the slice * @return the new slice */ public static int[] slc( int[] array, int startIndex, int endIndex ) { final int start = calculateIndex( array, startIndex ); final int end = calculateEndIndex( array, endIndex ); final int newLength = end - start; if ( newLength < 0 ) { throw new ArrayIndexOutOfBoundsException( String.format( "start index %d, end index %d, length %d", startIndex, endIndex, array.length ) ); } int[] newArray = new int[ newLength ]; System.arraycopy( array, start, newArray, 0, newLength ); return newArray; }