Created
August 11, 2023 20:51
-
-
Save quantra-go-algo/7a4618f4c9f0e3f074ff332f1a7be349 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to get the ARFIMA weights | |
def getWeights_FFD(d, thres, lim): | |
# Set w as a list and k as one | |
w, k = [1.], 1 | |
ctr = 0 | |
while True: | |
# Create the new weight value | |
w_ = -w[-1] / k * (d - k + 1) | |
# End the loop in case the threshold is breached | |
if abs(w_) < thres: | |
break | |
# Append the new value of w | |
w.append(w_) | |
# Update k and ctr | |
k += 1 | |
ctr += 1 | |
# End the loop in case it breaches the limit | |
if ctr == lim - 1: | |
break | |
# Convert the w from list to a numpy array | |
w = np.array(w[::-1]).reshape(-1, 1) | |
return w |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment