# 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