oas_dev/util/slice_average/significance.py
def calc_sign_over_fields(da1, da2, avg_dim='time', ci=.95):
    """
    Source: Modern Mathematical Statistics with Applications by Devore & Berk
    Assumptions:
    - data consists of independently selected pairs (X1,Y1)
    - Di=Xi-Yi are assumed to be normally distributed.

    :param da1:
    :param da2:
    :param avg_dim:
    :param ci:
    :return:
    """
    D = da1 - da2
    n = len(D.coords[avg_dim])
    mean_D = D.mean(avg_dim)
    # sample std:
    # population std= sqrt(sum((xi-mu)^2)/n)
    # sample std =  sqrt(sum((xi-mu)^2)/(n-1))
    # sample std = (population std)*(sqrt(n/(n-1))
    s_std = D.std(avg_dim) * np.sqrt(n / (n - 1))
    t = mean_D / (s_std / np.sqrt(n))
    # for small samples (<50) we use t-statistics
    # n = 9, degree of freedom = 9-1 = 8
    # for 99% confidence interval, alpha = 1% = 0.01 and alpha/2 = 0.005
    T = stats.t.ppf(1 - ((1 - ci) / 2), n - 1)  # 99% CI, t8,0.005
    sig_map = (t > T) | (t < -T)
    return T, sig_map, t

    Source: Modern Mathematical Statistics with Applications by Devore & Berk
    Assumptions:
    - data consists of independently selected pairs (X1,Y1)
    - Di=Xi-Yi are assumed to be normally distributed.

    :param da1:
    :param da2:
    :param avg_dim:
    :param ci:
    :return:
    
Modern Mathematical Statistics with Applications by Devore & Berk
Assumptions:
data consists of independently selected pairs (X1,Y1)
Di=Xi-Yi are assumed to be normally distributed.
Modern Mathematical Statistics with Applications by Devore & Berk Assumptions : data consists of independently selected pairs ( X1 Y1 ) Di = Xi - Yi are assumed to be normally distributed .
def calc_sign_over_fields(da1, da2, avg_dim='time', ci=.95):
    D = da1 - da2
    n = len(D.coords[avg_dim])
    mean_D = D.mean(avg_dim)
    s_std = D.std(avg_dim) * np.sqrt(n / (n - 1))
    t = mean_D / (s_std / np.sqrt(n))
    T = stats.t.ppf(1 - ((1 - ci) / 2), n - 1)  
    sig_map = (t > T) | (t < -T)
    return T, sig_map, t
def calc_sign_over_fields ( da1 , da2 , avg_dim = 'time' , ci = .95 ) : D = da1 - da2 n = len ( D . coords [ avg_dim ] ) mean_D = D . mean ( avg_dim ) s_std = D . std ( avg_dim ) * np . sqrt ( n / ( n - 1 ) ) t = mean_D / ( s_std / np . sqrt ( n ) ) T = stats . t . ppf ( 1 - ( ( 1 - ci ) / 2 ) , n - 1 ) sig_map = ( t > T ) | ( t < - T ) return T , sig_map , t
Source: Modern Mathematical Statistics with Applications by Devore & Berk
Assumptions:
 data consists of independently selected pairs (X1,Y1)
 Di=Xi-Yi are assumed to be normally distributed.
Source : Modern Mathematical Statistics with Applications by Devore & Berk Assumptions : data consists of independently selected pairs ( X1 Y1 ) Di = Xi - Yi are assumed to be normally distributed .
"""
    Source: Modern Mathematical Statistics with Applications by Devore & Berk
    Assumptions:
    - data consists of independently selected pairs (X1,Y1)
    - Di=Xi-Yi are assumed to be normally distributed.

    :param da1:
    :param da2:
    :param avg_dim:
    :param ci:
    :return:
    """ # sample std: # population std= sqrt(sum((xi-mu)^2)/n) # sample std =  sqrt(sum((xi-mu)^2)/(n-1)) # sample std = (population std)*(sqrt(n/(n-1)) # for small samples (<50) we use t-statistics # n = 9, degree of freedom = 9-1 = 8 # for 99% confidence interval, alpha = 1% = 0.01 and alpha/2 = 0.005 # 99% CI, t8,0.005
None
da1
None
da2
None
avg_dim
None
ci
None