Skip to content

Commit 55479ec

Browse files
committed
optimize fit performance
1 parent 278ebcf commit 55479ec

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "AlphaStableDistributions"
22
uuid = "f20549b4-2d50-407f-863c-cdd202ba59a3"
33
authors = ["Fredrik Bagge Carlson", "Too Yuen Min"]
4-
version = "0.1.1"
4+
version = "0.1.2"
55

66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"

src/AlphaStableDistributions.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ c is computed based on Fama & Roll (1971) fractile.
6767
δ is the 50% trimmed mean of the sample.
6868
"""
6969
function Distributions.fit(d::Type{<:AlphaStable}, x)
70-
δ = mean(StatsBase.trim(x,prop=0.25))
71-
p = quantile.(Ref(sort(x)), (0.05, 0.25, 0.28, 0.72, 0.75, 0.95), sorted=true)
70+
sx = sort(x)
71+
δ = mean(@view(sx[end÷4:(3*end)÷4]))
72+
p = quantile.(Ref(sx), (0.05, 0.25, 0.28, 0.72, 0.75, 0.95), sorted=true)
7273
c = (p[4]-p[3])/1.654
7374
an = (p[6]-p[1])/(p[5]-p[2])
7475
if an < 2.4388

0 commit comments

Comments
 (0)