function WVALSTHR, x ;+ ;NAME: ; WVALSTHR ; ;PURPOSE: ; To perform adaptive threshold selection ; using principle of Stein's Unbiased Risk Estimate (SURE) ; ;CATEGORY: ; Wavelets. ; ;CALLING SEQUENCE: ; thresh = WVALSTHR(x) ; ;INPUTS: ; x = Noisy Data with Std. Deviation = 1 ; ;OUTPUTS: ; thresh = Value of Threshold ; ; ;EXAMPLE: ; ;SEE ALSO: ; wsoftthr, wsurethr, wdoshrnk ; ; ;MODIFICATION HISTORY: ; Written by: Amara Graps December, 1994 ;Translated from MatLab Wavelab routine: valsurethresh.m ;- a = WMSORT(abs(x))^2 b = WCUMSUM(a) n = N_ELEMENTS(x) c = WLNSPACE(n-1,0,n) s = b+c*a ;use the IDL way to create an index array lo = 1 & incr = 1 & hi = n indx_array = WMKIARRY( lo, incr, hi) + 1 ;WMKIARRY starts at (indx-1) risk = (n - ( 2.0 * indx_array) + s)/FLOAT(n) guess = WMMIN(risk,ibest) ;ibest returns the IDL "n-1" index thresh = SQRT(a(ibest)) ; ; Algorithm Source: WaveLab Version 0.600 ; WaveLab WWW site: http://playfair.stanford.edu/ ; WaveLab Questions? e-mail wavelab@playfair.stanford.edu ; RETURN, thresh END ;***************************************************