Changeset 242 for trunk/SRC/ToBeReviewed/STATISTICS/a_timecorrelate.pro
- Timestamp:
- 04/06/07 10:35:17 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/STATISTICS/a_timecorrelate.pro
r232 r242 2 2 ; 3 3 ; @file_comments 4 ;5 4 ; 6 5 ; @categories … … 8 7 ; 9 8 ; @param X {in}{required}{type=array} 10 ; An Array which last dimension is the time dimension so9 ; An array which last dimension is the time dimension so 11 10 ; size n. 12 11 ; 13 12 ; @param M 14 13 ; 15 ;16 14 ; @param NT 17 15 ; 18 ;19 16 ; @keyword ZERO2NAN 20 ;21 17 ; 22 18 ; @keyword DOUBLE … … 26 22 ; @examples 27 23 ; 28 ;29 24 ; @history 30 ;31 25 ; 32 26 ; @version … … 35 29 ;- 36 30 FUNCTION timeauto_cov, X, M, nT, Double = Double, zero2nan = zero2nan 37 ;Sample autocovariance function38 31 ; 39 32 compile_opt idl2, strictarrsubs 40 33 ; 34 ;Sample autocovariance function 41 35 TimeDim = size(X, /n_dimensions) 42 36 Xmean = TOTAL(X, TimeDim, Double = Double) / nT … … 66 60 END 67 61 ;+ 62 ; 68 63 ; @file_comments 69 64 ; Same function as A_CORRELATE but accept array (until 4 … … 79 74 ; 80 75 ; @param X {in}{required}{type=array} 81 ; An Array which last dimension is the time dimension so76 ; An array which last dimension is the time dimension so 82 77 ; size n. 83 78 ; 84 79 ; @param LAG {in}{required}{type=scalar or vector} 85 ; A scalar or n-element vector, in the interval [-(n-2),(n-2)],86 ; of type integer that specifies the absolute distance(s) between 80 ; A scalar or n-elements vector, in the interval [-(n-2),(n-2)], 81 ; of type integer that specifies the absolute distance(s) between 87 82 ; indexed elements of X. 88 83 ; … … 96 91 ; 97 92 ; @examples 98 ; Define an n-elementsample population.99 ; 93 ; Define an n-elements sample population. 94 ; IDL> x = [3.73, 3.67, 3.77, 3.83, 4.67, 5.87, 6.70, 6.97, 6.40, 5.57] 100 95 ; 101 ; 102 ; 103 ; 96 ; Compute the autocorrelation of X for LAG = -3, 0, 1, 3, 4, 8 97 ; IDL> lag = [-3, 0, 1, 3, 4, 8] 98 ; IDL> result = a_correlate(x, lag) 104 99 ; 105 ; 106 ; 100 ; The result should be: 101 ; [0.0146185, 1.00000, 0.810879, 0.0146185, -0.325279, -0.151684] 107 102 ; 108 103 ; @history … … 118 113 ; 119 114 ;- 120 115 ; 121 116 FUNCTION a_timecorrelate, X, Lag, COVARIANCE = Covariance, DOUBLE = Double 122 117 ; … … 134 129 ;Check length. 135 130 if nT lt 2 then $ 136 MESSAGE, "Time axis of X array must contain 2 or more elements."137 131 ras= report("Time axis of X array must contain 2 or more elements.") 132 138 133 ;If the DOUBLE keyword is not set then the internal precision and 139 134 ;result are identical to the type of input. … … 141 136 Double = (SIZE(X, /type) eq 5) 142 137 143 138 144 139 if n_elements(lag) EQ 0 then lag = 0 145 140 nLag = N_ELEMENTS(Lag) … … 169 164 endcase 170 165 endif else begin ;Compute Autocovariance. 171 for k = 0, nLag-1 do $ 166 for k = 0, nLag-1 do $ 172 167 case XNDim of 173 168 1:Auto[k] = TimeAuto_Cov(X, ABS(Lag[k]), nT, Double = Double) / nT
Note: See TracChangeset
for help on using the changeset viewer.