I am trying to predict using wrapcauchy. This was the best fit when running the fit_transform() method.

Unfortunately, I am running into some issues. I keep receiving the error:

'tuple' object has no attribute 'rvs'

thrown on this line:

next_value = dist1.rvs(size=1)

The code:

from scipy.stats import wrapcauchy

# get the historical data up to the second to last value in the sequence
historical_data = dfp["R1"][:-1]

# fit the distribution to the historical data
dist1 = wrapcauchy.fit(historical_data)

# predict the next value
next_value = dist1.rvs(size=1)

# predict the next value
#next_value = dist1.predict([historical_data[-1]])["y"][0]

print("Predicted next value:", next_value[0])

Could someone explain the issue? Thanks

  • $\begingroup$ From reading the scipy documentation, wrapcauchy.fit() returns a tuple of best fit parameters for a wrapped cauchy random variable - not the random variable itself. The rvs() method is a method of wrapcauchy, and you pass the results of wrapcauchy.fit() as arguments to wrapcauchy.rvs(). $\endgroup$
    – Lynn
    Mar 18 at 12:09


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.