function CDFmatch_filter( outFile, inFile, cdf_abscissa )

N_train = length( cdf_abscissa );

[ x_in, fs ] = readsph( inFile );

x = filter( [ 1 1 1 1 1 ] / 5, 1, x_in );
x = circshift( x, -2 );

N_test = length( x );

[ ~, I ] = sort( x );

output_indices = round( N_train * ( 1 : N_test ) / N_test );

x_out = x;

x_out( I ) = cdf_abscissa( output_indices );

x_m = zeros( length( x_in ), 1 );

for kk = 1 : length( x_in )

	x_m( kk ) = x_in( kk ) + x_out( kk ) - x( kk );

end

%x_out = 0.98 * x_out / max( abs( x_out ) );

wavwrite( 0.98 * x_m / max( abs( x_m ) ), fs, outFile );
