baker_jayaram_2008.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pygmm 作者: arkottke 项目源码 文件源码
def calc_correls(periods: ArrayLike, period_cond: float) -> np.ndarray:
    """Baker and Jayaram (2008, :cite:`baker08`) correlation model.

    Parameters
    ----------
    periods : array_like
        Periods at which the correlation should be computed.
    period_cond : float
        Conditioning period

    Returns
    -------
    correls : :class:`np.ndarray`
        Correlation coefficients
    """
    periods = np.asarray(periods)
    periods_min = np.minimum(periods, period_cond)
    periods_max = np.maximum(periods, period_cond)

    c_1 = (1 - np.cos(np.pi / 2 - 0.366 * np.log(periods_max / np.maximum(
        periods_min, 0.109))))

    c_2 = np.select([periods_max < 0.2, True], [
        1 - 0.105 * (1 - 1 / (1 + np.exp(100 * periods_max - 5))) *
        (periods_max - periods_min) / (periods_max - 0.0099), 0
    ])

    c_3 = np.select([periods_max < 0.109, True], [c_2, c_1])

    c_4 = (c_1 + 0.5 * (np.sqrt(c_3) - c_3) *
           (1 + np.cos(np.pi * periods_min / 0.109)))

    correls = np.select(
        [periods_max < 0.109, periods_min > 0.109, periods_max < 0.200, True],
        [c_2, c_1, np.minimum(c_2, c_4), c_4], )

    return correls
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号