Function wSTDEV, Array, weights, Mean
;
;+
; NAME:
;	wSTDEV   - altered library procedure.
;
; PURPOSE:
;	Compute the standard deviation and, optionally, the
;	weighted mean of any array.
;
; CATEGORY:
;	G1- Simple calculations on statistical data.
;
; CALLING SEQUENCE:
;	Result = wSTDEV(Array,weights [, Mean])
;
; INPUTS:
;	Array:	The data array.  Array may be any type except string.
;
; OUTPUTS:
;	STDEV returns the standard deviation (sample variance
;	because the divisor is N-1) of Array.
;		
; OPTIONAL OUTPUT PARAMETERS:
;	Mean:	Upon return, this parameter contains the mean of the values
;		in the data array.
;
; COMMON BLOCKS:
;	None.
;
; SIDE EFFECTS:
;	None.
;
; RESTRICTIONS:
;	None.
;
; PROCEDURE:
;	Mean = TOTAL(Array*weights)/total(weights)
;	Stdev = SQRT(TOTAL((Array*-Mean)^2/(N-1)))(* look this up....
;
; MODIFICATION HISTORY:
;	DMS, RSI, Sept. 1983.
;	ATP, ISAS, mar 1992
;-
	on_error,2		;return to caller if error
	n = n_elements(array)	;# of points.
	if n le 1 then message, 'Number of data points must be > 1'
;
        mean = total(array*weights)/total(weights)	;yes.
        return,sqrt(total((array-mean)^2)/(n-1))

       end

