Getting Started

Hurst.jl allows you to calculate Generalised Hurst Exponents (GHEs) in a robust and performant way.

Install Hurst.jl

Before anything else, install Hurst.jl in the usual way:

using Pkg
Pkg.add("Hurst")
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
   Installed Hurst ─ v0.1.4
    Updating `~/work/Hurst.jl/Hurst.jl/docs/Project.toml`
  [f5425a1d] ~ Hurst v0.1.4 `~/work/Hurst.jl/Hurst.jl` ⇒ v0.1.4
    Updating `~/work/Hurst.jl/Hurst.jl/docs/Manifest.toml`
  [f5425a1d] ~ Hurst v0.1.4 `~/work/Hurst.jl/Hurst.jl` ⇒ v0.1.4
Precompiling project...
Hurst
  1 dependency successfully precompiled in 1 seconds. 174 already precompiled.
  1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version

Get some data

The easiest way to demonstrate how to use Hurst.jl is with Gaussian data, so we will generate a Gaussian walk ($Z(t) = \sum_\tau X(\tau), X(\tau) \sim \mathcal{N}(0, 1)$).

using Hurst, Plots, Random
Random.seed!(1)
X = cumsum(randn(3000))
plot(X, label = "Gaussian walk", xlabel = "t", ylabel = "X(t)")

Define your $\tau$ range

Hurst.jl calculates the Hurst exponent $H$ by estimating the moments of the absolute increments over some time delay $\tau$. If that sounds like gibberish, take a look at the Troubleshooting section which explains things in more detail. τ_range = 30:250 is a good place to start:

τ_range = 30:250
30:250

Calculate $H$

Calclating $H$ is as simple as:

H, SD = hurst_exponent(X, τ_range)
1×2 Matrix{Float64}:
 0.538966  0.00533621

Notice that hurst_exponent returns a 1x2 array. This is because we want to be able to calculate the Generalised Hurst Exponent (GHE) quickly as well and have a consistent API:

q_range = 0.1:0.1:1.
GHE_data = generalised_hurst_range(X, τ_range, q_range)
10×2 Matrix{Float64}:
 0.608744  0.000868118
 0.60024   0.00164312
 0.591881  0.00233345
 0.583698  0.00294632
 0.575709  0.00348828
 0.567926  0.00396541
 0.560357  0.00438345
 0.553006  0.00474784
 0.545876  0.00506378
 0.538966  0.00533621
plot(q_range, GHE_data[:,1], yerror = GHE_data[:, 2], xlabel = "q",
    ylabel = "H(q)", label = nothing, ylims = (0, 1))

Further analysis

If you are trying to reproduce some results from papers that use the GHE, you might be interested in the quantity $\zeta(q) = qH(q)$:

zeta_data = Hurst.zeta_estimator_range(X, τ_range, q_range)
plot(q_range, zeta_data[:,1], yerror = zeta_data[:, 2], xlabel = "q",
    ylabel = "ζ(q)", label = nothing)

If you want to see if the data is multi-scaling, you can fit parabola to this data with Polynomials.jl:

using Polynomials
quadratic_fit = fit(q_range, zeta_data[:, 1], 2)
scatter!(q_range, zeta_data[:, 1], label = nothing)
plot!(quadratic_fit, extrema(q_range)..., label = "Quadratic fit")
#first coefficient should be almost zero...
coeffs(quadratic_fit)
3-element Vector{Float64}:
  0.0008941043312817613
  0.6097195292824368
 -0.07192541203048461