diff --git a/PA/code/stationary diff.py b/PA/code/stationary diff.py new file mode 100644 index 0000000..efd409b --- /dev/null +++ b/PA/code/stationary diff.py @@ -0,0 +1,16 @@ +def difference(timeseries, interval=1): + diff = [] + for i in range(interval, len(timeseries)): + value = timeseries[i] - timeseries[i - interval] + diff.append(value) + return np.array(diff) + +diff_ts = difference(trend_ts) + +plt.figure(figsize=(12, 6)) +plt.plot(time[1:], diff_ts, label='Дифференцированный ряд') +plt.legend() +plt.title('Ряд после дифференцирования') +plt.show() + +adf_test(diff_ts) \ No newline at end of file diff --git a/PA/code/stationary log.py b/PA/code/stationary log.py new file mode 100644 index 0000000..f343356 --- /dev/null +++ b/PA/code/stationary log.py @@ -0,0 +1,8 @@ +volatile_ts = np.exp(np.linspace(0, 2, n)) * np.random.normal(size=n) + +plt.figure(figsize=(12, 6)) +plt.plot(time, volatile_ts, label='Исходный ряд') +plt.plot(time, np.log(volatile_ts), label='Логарифмированный ряд') +plt.legend() +plt.title('Логарифмическое преобразование') +plt.show() \ No newline at end of file diff --git a/PA/code/stationary season.py b/PA/code/stationary season.py new file mode 100644 index 0000000..915b580 --- /dev/null +++ b/PA/code/stationary season.py @@ -0,0 +1,12 @@ +# Создаем сезонный ряд +seasonal_ts = 5 * np.sin(np.linspace(0, 10*np.pi, n)) + np.linspace(0, 5, n) + np.random.normal(size=n) + +# Сезонное дифференцирование с периодом 30 дней +seasonal_diff = seasonal_ts[30:] - seasonal_ts[:-30] + +plt.figure(figsize=(12, 6)) +plt.plot(time, seasonal_ts, label='Исходный ряд') +plt.plot(time[30:], seasonal_diff, label='Сезонно дифференцированный ряд') +plt.legend() +plt.title('Сезонное дифференцирование') +plt.show() \ No newline at end of file diff --git a/PA/code/stationary test.py b/PA/code/stationary test.py new file mode 100644 index 0000000..a32e3bd --- /dev/null +++ b/PA/code/stationary test.py @@ -0,0 +1,39 @@ +import pandas as pd +import matplotlib.pyplot as plt +import numpy as np +from statsmodels.tsa.stattools import adfuller, kpss + + +# Пример временного ряда +np.random.seed(42) +n = 100 +time = pd.date_range(start='2020-01-01', periods=n, freq='D') +stationary_ts = np.random.normal(loc=0, scale=1, size=n) +trend_ts = np.linspace(0, 10, n) + stationary_ts + +plt.figure(figsize=(12, 6)) +plt.plot(time, stationary_ts, label='Стационарный ряд') +plt.plot(time, trend_ts, label='Нестационарный ряд с трендом') +plt.legend() +plt.title('Визуальная проверка стационарности') +plt.show() + +def adf_test(timeseries): + print("Результаты теста Дики-Фуллера:") + dftest = adfuller(timeseries, autolag='AIC') + dfoutput = pd.Series(dftest[0:4], + index=['Тестовая статистика', 'p-value', + 'Количество лагов', 'Количество наблюдений']) + for key, value in dftest[4].items(): + dfoutput[f'Критическое значение ({key})'] = value + print(dfoutput) + + if dftest[1] <= 0.05: + print("Вывод: ряд стационарный (отвергаем H0)") + else: + print("Вывод: ряд нестационарный (не отвергаем H0)") + + +adf_test(stationary_ts) +print("\n") +adf_test(trend_ts) \ No newline at end of file diff --git a/PA/datasets/NN3_COMPLETE.xls b/PA/datasets/NN3_COMPLETE.xls new file mode 100644 index 0000000..16c7ed5 Binary files /dev/null and b/PA/datasets/NN3_COMPLETE.xls differ diff --git a/PA/datasets/NN3_REDUCED.xls b/PA/datasets/NN3_REDUCED.xls new file mode 100644 index 0000000..ec3213d Binary files /dev/null and b/PA/datasets/NN3_REDUCED.xls differ diff --git a/PA/datasets/cif-dataset.xls b/PA/datasets/cif-dataset.xls new file mode 100644 index 0000000..8750d08 Binary files /dev/null and b/PA/datasets/cif-dataset.xls differ diff --git a/PA/datasets/statistic.xls b/PA/datasets/statistic.xls new file mode 100644 index 0000000..ff7f79b Binary files /dev/null and b/PA/datasets/statistic.xls differ diff --git a/PA/РџРђ 6 сглаживание.pptx b/PA/РџРђ 6 сглаживание.pptx index 6917911..b36bab9 100644 Binary files a/PA/РџРђ 6 сглаживание.pptx and b/PA/РџРђ 6 сглаживание.pptx differ diff --git a/PA/РџРђ 7 прогнозирование.pptx b/PA/РџРђ 7 прогнозирование.pptx index 117d6df..c58ab31 100644 Binary files a/PA/РџРђ 7 прогнозирование.pptx and b/PA/РџРђ 7 прогнозирование.pptx differ diff --git a/PA/Практические задания.docx b/PA/Практические задания.docx new file mode 100644 index 0000000..6e6d583 Binary files /dev/null and b/PA/Практические задания.docx differ