MulaiMulai sekarang secara gratis

Can't Forecast White Noise

A white noise time series is simply a sequence of uncorrelated random variables that are identically distributed. Stock returns are often modeled as white noise. Unfortunately, for white noise, we cannot forecast future observations based on the past - autocorrelations at all lags are zero.

You will generate a white noise series and plot the autocorrelation function to show that it is zero for all lags. You can use np.random.normal() to generate random returns. For a Gaussian white noise process, the mean and standard deviation describe the entire process.

Plot this white noise series to see what it looks like, and then plot the autocorrelation function.

Latihan ini adalah bagian dari kursus

Time Series Analysis in Python

Lihat Kursus

Petunjuk latihan

  • Generate 1000 random normal returns using np.random.normal() with mean 2% (0.02) and standard deviation 5% (0.05), where the argument for the mean is loc and the argument for the standard deviation is scale.
  • Verify the mean and standard deviation of returns using np.mean() and np.std().
  • Plot the time series.
  • Plot the autocorrelation function using plot_acf with lags=20.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import the plot_acf module from statsmodels
from statsmodels.graphics.tsaplots import plot_acf

# Simulate white noise returns
returns = np.random.normal(loc=___, scale=___, size=___)

# Print out the mean and standard deviation of returns
mean = np.mean(___)
std = np.std(___)
print("The mean is %5.3f and the standard deviation is %5.3f" %(mean,std))

# Plot returns series
plt.plot(___)
plt.show()

# Plot autocorrelation function of white noise returns
plot_acf(___, lags=___)
plt.show()
Edit dan Jalankan Kode