Esempio n. 1
0
def transform_tev(t, rho, df):
    '''t-EV model of Demarta and McNeil 2005

    restrictions:
     - rho in (-1,1)
     - x > 0
    '''
    x = df  # alias, Genest and Segers use chi, copual package uses df

    def _check_args(rho, x):
        cond1 = (x > 0)
        cond2 = (rho > 0) and (rho < 1)
        return cond1 and cond2

    if not np.all(_check_args(rho, x)):
        raise ValueError('invalid args')

    from scipy.stats import t as stats_t
    # use special if I want to avoid stats import

    term1 = (np.power(t/(1.-t), 1./x) - rho)  # for t
    term2 = (np.power((1.-t)/t, 1./x) - rho)  # for 1-t
    term0 = np.sqrt(1. + x) / np.sqrt(1 - rho*rho)
    z1 = term0 * term1
    z2 = term0 * term2
    transf = t * stats_t._cdf(z1, x+1) + (1 - t) * stats_t._cdf(z2, x+1)
    return transf
Esempio n. 2
0
 def _argcheck(self, df, a, b):
     self.a = a
     self.b = b
     self._nb = t._cdf(b, df)
     self._na = t._cdf(a, df)
     self._delta = self._nb - self._na
     self._logdelta = np.log(self._delta)
     return (a != b)
Esempio n. 3
0
    def evaluate(self, t, rho, df):
        x = df  # alias, Genest and Segers use chi, copual package uses df
        # if not np.all(self, _check_args(rho, x)):
        #    raise ValueError('invalid args')

        from scipy.stats import t as stats_t
        # use special if I want to avoid stats import

        term1 = (np.power(t / (1. - t), 1. / x) - rho)  # for t
        term2 = (np.power((1. - t) / t, 1. / x) - rho)  # for 1-t
        term0 = np.sqrt(1. + x) / np.sqrt(1 - rho * rho)
        z1 = term0 * term1
        z2 = term0 * term2
        transf = t * stats_t._cdf(z1, x + 1) + (1 - t) * stats_t._cdf(
            z2, x + 1)
        return transf
Esempio n. 4
0
def transform_tev(t, rho, x):
    '''t-EV model of Demarta and McNeil 2005

    restrictions:
     - rho in (-1,1)
     - x > 0
    '''
    def _check_args(rho, x):
        cond1 = (x > 0)
        cond2 = (rho > 0) and (rho < 1)
        return cond1 and cond2

    if not np.all(_check_args(rho, x)):
        raise ValueError('invalid args')

    from scipy.stats import t as stats_t  #use special if I want to avoid stats import

    z = np.sqrt(1. + x) * (np.power(t / (1. - t), 1. / x) - rho)
    z /= np.sqrt(1 - rho * rho)
    transf = (1 - t) * stats_t._cdf(z, x + 1) + t * stats_t._cdf(z, x + 1)
    return transf
Esempio n. 5
0
def transform_tev(t, rho, x):
    '''t-EV model of Demarta and McNeil 2005

    restrictions:
     - rho in (-1,1)
     - x > 0
    '''

    def _check_args(rho, x):
        cond1 = (x > 0)
        cond2 = (rho > 0) and (rho < 1)
        return cond1 and cond2

    if not np.all(_check_args(rho, x)):
        raise ValueError('invalid args')

    from scipy.stats import t as stats_t  #use special if I want to avoid stats import

    z = np.sqrt(1. + x) * (np.power(t/(1.-t), 1./x) - rho)
    z /= np.sqrt(1 - rho*rho)
    transf = (1 - t) * stats_t._cdf(z, x+1) + t * stats_t._cdf(z, x+1)
    return transf
Esempio n. 6
0
 def _cdf(self, x, df, a, b):
     result = np.zeros_like(x)
     mask = (x >= a) * (x <= b)
     result[mask] = (t._cdf(x[mask], df) - self._na) / self._delta
     result[x > b] = 1.
     return result