Skip to main content

Fractional Brownian Motion

Project description

Exact methods for simulating fractional Brownian motion (fBm) or fractional Gaussian noise (fGn) in python.

The three methods are Hosking’s method, the Cholesky method, and the Davies Harte method. All three methods are exact in generating a discretely sampled fBm/fGn.

Usage:

from fbm import FBM


f = FBM(n=16, hurst=0.75, length=1, method='daviesharte')

# Generate a fBm realization
fbm_sample = f.fbm()

# Generate a fGn realization
fgn_sample = f.fgn()

# Get the times associated with the fBm
times = f.times()

where n is the number of equispaced increments desired for a fBm with Hurst parameter hurst on the interval [0, length]. Method can be either 'hosking', 'cholesky', or 'daviesharte'. The fbm() method returns a length n+1 array of discrete values for the fBm (includes 0). The fgn() method returns a length n array of fBm increments, or fGn. The times() method returns a length n+1 array of times corresponding to the fBm realizations.

For simulating multiple realizations use the FBM class provided as above. For one-off samples of fBm or fGn there are also functions available which handle the FBM object themselves:

from fbm import fbm, fgn, times


# Generate a fBm realization
fbm_sample = fbm(n=16, hurst=0.75, length=1, method='daviesharte')

# Generate a fGn realization
fgn_sample = fgn(n=16, hurst=0.75, length=1, method='daviesharte')

# Get the times associated with the fBm
times = times(n=16, length=1)

For fastest performance use the Davies and Harte method. It is much faster than both other methods especially for larger increment quantities. Note that the Davies and Harte method can fail if the Hurst parameter hurst is close to 1 and there are a small amount of increments n. If this occurs, python will print a warning to the console and fallback to using Hosking’s method to generate the realization. See page 412 of the following paper for a more detailed explanation:

  • Wood, Andrew TA, and Grace Chan. “Simulation of stationary Gaussian processes in [0, 1] d.” Journal of computational and graphical statistics 3, no. 4 (1994): 409-432.

Hosking’s method:

  • Hosking, Jonathan RM. “Modeling persistence in hydrological time series using fractional differencing.” Water resources research 20, no. 12 (1984): 1898-1908.

Cholesky method:

  • Asmussen, Søren. Stochastic simulation with a view towards stochastic processes. University of Aarhus. Centre for Mathematical Physics and Stochastics (MaPhySto)[MPS], 1998.

Davies Harte method:

  • Davies, Robert B., and D. S. Harte. “Tests for Hurst effect.” Biometrika 74, no. 1 (1987): 95-101.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fbm-0.1.0.zip (7.6 kB view details)

Uploaded Source

File details

Details for the file fbm-0.1.0.zip.

File metadata

  • Download URL: fbm-0.1.0.zip
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fbm-0.1.0.zip
Algorithm Hash digest
SHA256 0a94a0809ab88ef543aa66589084f618b39cab9a474c50d5a3785b74f317f897
MD5 62214ca03d2ca3d7eff4f0fc8f4c85b2
BLAKE2b-256 fe9a7e0b4bda73c0276d0b4d609814bb0e44bb3894a3db4f1f875e10bc4007ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page