FashionVictimModel.py 文件源码

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

项目:HARK 作者: econ-ark 项目源码 文件源码
def calcFashionEvoFunc(pNow):
    '''
    Calculates a new approximate dynamic rule for the evolution of the proportion
    of punks as a linear function and a "shock width".

    Parameters
    ----------
    pNow : [float]
        List describing the history of the proportion of punks in the population.

    Returns
    -------
    (unnamed) : FashionEvoFunc
        A new rule for the evolution of the population punk proportion, based on
        the history in input pNow.
    '''
    pNowX = np.array(pNow)
    T = pNowX.size
    p_t   = pNowX[100:(T-1)]
    p_tp1 = pNowX[101:T]
    pNextSlope, pNextIntercept, trash1, trash2, trash3 = stats.linregress(p_t,p_tp1)
    pPopExp  = pNextIntercept + pNextSlope*p_t
    pPopErrSq= (pPopExp - p_tp1)**2
    pNextStd  = np.sqrt(np.mean(pPopErrSq))
    print(str(pNextIntercept) + ', ' + str(pNextSlope) + ', ' + str(pNextStd))
    return FashionEvoFunc(pNextIntercept,pNextSlope,2*pNextStd)


###############################################################################
###############################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号