#NEWLINE# def jackknifed_sdf_variance( yk , eigvals , sides = 'onesided' , adaptive = True ) : #NEWLINE# #INDENT# "\n    Returns the variance of the log-sdf estimated through jack-knifing\n    a group of independent sdf estimates.\n\n    Parameters\n    ----------\n\n    yk : ndarray (K, L)\n       The K DFTs of the tapered sequences\n    eigvals : ndarray (K,)\n       The eigenvalues corresponding to the K DPSS tapers\n    sides : str, optional\n       Compute the jackknife pseudovalues over as one-sided or\n       two-sided spectra\n    adpative : bool, optional\n       Compute the adaptive weighting for each jackknife pseudovalue\n\n    Returns\n    -------\n\n    var : The estimate for log-sdf variance\n\n    Notes\n    -----\n\n    The jackknifed mean estimate is distributed about the true mean as\n    a Student's t-distribution with (K-1) degrees of freedom, and\n    standard error equal to sqrt(var). However, Thompson and Chave [1]\n    point out that this variance better describes the sample mean.\n\n\n    [1] Thomson D J, Chave A D (1991) Advances in Spectrum Analysis and Array\n    Processing (Prentice-Hall, Englewood Cliffs, NJ), 1, pp 58-113.\n    " #NEWLINE# K = yk . shape [ 0 ] #NEWLINE# from nitime.algorithms import mtm_cross_spectrum #NEWLINE# all_orders = set ( range ( K ) ) #NEWLINE# jk_sdf = [ ] #NEWLINE# for i in range ( K ) : #NEWLINE# #INDENT# items = list ( all_orders . difference ( [ i ] ) ) #NEWLINE# spectra_i = np . take ( yk , items , axis = 0 ) #NEWLINE# eigs_i = np . take ( eigvals , items ) #NEWLINE# if adaptive : #NEWLINE# #INDENT# ( weights , _ ) = adaptive_weights ( spectra_i , eigs_i , sides = sides ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# weights = eigs_i [ : , None ] #NEWLINE# #UNINDENT# jk_sdf . append ( mtm_cross_spectrum ( spectra_i , spectra_i , weights , sides = sides ) ) #NEWLINE# #UNINDENT# jk_sdf = np . log ( jk_sdf ) #NEWLINE# jk_avg = jk_sdf . mean ( axis = 0 ) #NEWLINE# K = float ( K ) #NEWLINE# jk_var = ( jk_sdf - jk_avg ) #NEWLINE# np . power ( jk_var , 2 , jk_var ) #NEWLINE# jk_var = jk_var . sum ( axis = 0 ) #NEWLINE# f = ( ( ( ( K - 1 ) ** 2 ) / K ) / ( K - 0.5 ) ) #NEWLINE# jk_var *= f #NEWLINE# return jk_var