Skip to content

Commit

Permalink
Merge 9fdb007 into 11bc8ce
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Oct 15, 2014
2 parents 11bc8ce + 9fdb007 commit 87ee4f7
Show file tree
Hide file tree
Showing 35 changed files with 2,090 additions and 133 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Documentation Status](https://readthedocs.org/projects/arch/badge/?version=latest)](https://readthedocs.org/projects/arch/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/arch/badge/?version=latest)](http://arch.readthedocs.org/en/latest/)
[![CI Status](https://travis-ci.org/bashtage/arch.svg?branch=master)](https://travis-ci.org/bashtage/arch)
[![Coverage Status](https://coveralls.io/repos/bashtage/arch/badge.png?branch=master)](https://coveralls.io/r/bashtage/arch?branch=master)

Expand All @@ -11,20 +11,20 @@ This is a work-in-progress for ARCH and related models, written in Python
## What is this repository for?

* Mean models
* Constant mean
* Heterogeneous Autoregression (HAR)
* Autoregression (AR)
* Zero mean
* Models with and without exogensou regressors
* Constant mean
* Heterogeneous Autoregression (HAR)
* Autoregression (AR)
* Zero mean
* Models with and without exogenous regressors
* Volatility models
* ARCH
* GARCH
* TARCH
* EGARCH
* EWMA/RiskMetrics
* ARCH
* GARCH
* TARCH
* EGARCH
* EWMA/RiskMetrics
* Distributions
* Normal
* Student's T
* Normal
* Student's T

## Examples

Expand Down
3 changes: 2 additions & 1 deletion arch/bootstrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__author__ = 'kevin.sheppard'
from .base import IIDBootstrap, CircularBlockBootstrap, MovingBlockBootstrap, \
StationaryBootstrap
37 changes: 37 additions & 0 deletions arch/bootstrap/_samplers.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import numpy as np
cimport numpy as np
cimport cython

@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
def stationary_bootstrap_sample(int[:] indices,
double[:] u,
double p):
"""
Parameters
-------
indices: 1-s arrah
Array containing draws from randint with the same size as the data in
the range of [0,nobs)
u : 1-d array
Array of standard uniforms
p : float
Probability that a new block is started in the stationary bootstrap.
The multiplicative reciprocal of the window length
Returns
-------
indices: 1-d array
Indices for an iteration of the stationary bootstrap
"""
cdef Py_ssize_t num_items, i
num_items = indices.shape[0]

for i in range(1, num_items):
if u[i] > p:
indices[i] = indices[i - 1] + 1
if indices[i] == num_items:
indices[i] = 0

return indices
31 changes: 31 additions & 0 deletions arch/bootstrap/_samplers_python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import absolute_import, division
from ..compat.numba import jit


@jit
def stationary_bootstrap_sample(indices, u, p):
"""
Parameters
-------
indices: 1-s arrah
Array containing draws from randint with the same size as the data in
the range of [0,nobs)
u : 1-d array
Array of standard uniforms
p : float
Probability that a new block is started in the stationary bootstrap.
The multiplicative reciprocal of the window length
Returns
-------
indices: 1-d array
Indices for an iteration of the stationary bootstrap
"""
num_items = indices.shape[0]
for i in range(1, num_items):
if u[i] > p:
indices[i] = indices[i - 1] + 1
if indices[i] == num_items:
indices[i] = 0

return indices
Loading

0 comments on commit 87ee4f7

Please sign in to comment.