question: public static double [ ] arrayResize ( double [ ] source , int targetSize ) { if ( source . length == targetSize ) { return source ; } int sourceSize = source . length ; double fraction = ( double ) source . length / ( double ) targetSize ; double [ ] newSignal = new double [ targetSize ] ; for ( int i = 0 ; i < targetSize ; i ++ ) { double posIdx = fraction * i ; int nVal = ( int ) Math . floor ( posIdx ) ; double diffVal = posIdx - nVal ; if ( nVal >= sourceSize - 1 ) { newSignal [ i ] = source [ sourceSize - 1 ] ; continue ; } double fVal = ( diffVal * source [ nVal + 1 ] ) + ( ( 1 - diffVal ) * source [ nVal ] ) ; newSignal [ i ] = fVal ; } return newSignal ; }
target:  array resize to target size using linear interpolation