arfit.py
def arfit(data, pmin=1, pmax=40, selector='sbc'):
    '''perform auto-regeressive order selection/estimation
    @data: input array in shape [frame_len, ]
    @pmin: minimal AR order to select, default 1
    @pmax: maximum AR order to select, default 40
    @selector: order selection criterion
    @no_const: decision on no intercept vector to be fitted

    @return: an integer of selected order
    '''
    n = data.shape[0]
    m = 1 # number of variables (dimension of state vectors)
    ntr = 1 # number of realizations (trials)

    mcor = 1 # num. intercept vectors

    assert pmin <= pmax
    assert n > pmax

    ne = ntr * (n-pmax)
    npmax = m * pmax + mcor

    # compute QR factorization for model of order pmax
    R, scale = arqr(data, pmax, mcor)

    # compute approximate order selection criteria for models 
    # of order pmin:pmax
    sbc, fpe = arord(R, m, mcor, ne, pmin, pmax)

    # get index iopt of order that minimizes the order selection 
    # criterion specified by the variable selector
    if selector == 'sbc':
        iopt = np.argmin(sbc)
    else:
        iopt = np.argmin(fpe)

    # select order of model
    popt = pmin + iopt # estimated optimum order 

    return popt
perform auto-regeressive order selection/estimation
    @data: input array in shape [frame_len, ]
    @pmin: minimal AR order to select, default 1
    @pmax: maximum AR order to select, default 40
    @selector: order selection criterion
    @no_const: decision on no intercept vector to be fitted

    @return: an integer of selected order
    
perform auto-regeressive order selection/estimation
perform auto - regeressive order selection / estimation
def arfit(data, pmin=1, pmax=40, selector='sbc'):
    n = data.shape[0]
    m = 1 
    ntr = 1 
    mcor = 1 
    assert pmin <= pmax
    assert n > pmax
    ne = ntr * (n-pmax)
    npmax = m * pmax + mcor
    R, scale = arqr(data, pmax, mcor)
    sbc, fpe = arord(R, m, mcor, ne, pmin, pmax)
    if selector == 'sbc':
        iopt = np.argmin(sbc)
    else:
        iopt = np.argmin(fpe)
    popt = pmin + iopt 
    return popt
def arfit ( data , pmin = 1 , pmax = 40 , selector = 'sbc' ) : n = data . shape [ 0 ] m = 1 ntr = 1 mcor = 1 assert pmin <= pmax assert n > pmax ne = ntr * ( n - pmax ) npmax = m * pmax + mcor R , scale = arqr ( data , pmax , mcor ) sbc , fpe = arord ( R , m , mcor , ne , pmin , pmax ) if selector == 'sbc' : iopt = np . argmin ( sbc ) else : iopt = np . argmin ( fpe ) popt = pmin + iopt return popt
perform auto-regeressive order selection/estimation
perform auto - regeressive order selection / estimation
'''perform auto-regeressive order selection/estimation
    @data: input array in shape [frame_len, ]
    @pmin: minimal AR order to select, default 1
    @pmax: maximum AR order to select, default 40
    @selector: order selection criterion
    @no_const: decision on no intercept vector to be fitted

    @return: an integer of selected order
    ''' # number of variables (dimension of state vectors) # number of realizations (trials) # num. intercept vectors # compute QR factorization for model of order pmax # compute approximate order selection criteria for models  # of order pmin:pmax # get index iopt of order that minimizes the order selection  # criterion specified by the variable selector # select order of model # estimated optimum order 
an integer of selected order
an integer of selected order
data
pmin
pmax
selector
data
input array in shape [frame_len, ]
input array in shape [ frame_len ]
pmin
minimal AR order to select, default 1
minimal AR order to select default 1
pmax
maximum AR order to select, default 40
maximum AR order to select default 40
selector
order selection criterion
order selection criterion
no_const
decision on no intercept vector to be fitted
decision on no intercept vector to be fitted