diff --git a/src/lib-base/src/MatplotACF.cpp b/src/lib-base/src/MatplotACF.cpp index bdaad83..9542f3a 100644 --- a/src/lib-base/src/MatplotACF.cpp +++ b/src/lib-base/src/MatplotACF.cpp @@ -36,7 +36,8 @@ void MatplotACF::Plot(const EnjoLib::VecD & dat, int lags, const EnjoLib::Str & AlgoSTDIVec().Reverse(&reversed); //ofs << dat.PrintPython("dat") << Nl; ofs << reversed.PrintPython("dat") << Nl; - ofs << "plotData(dat, " << lags << ", '" << title << "')" << Nl; + ofs << "plotACF(dat, " << lags << ", '" << title << "')" << Nl; + ofs << "plotPACF(dat, " << lags << ", '" << title << "')" << Nl; } ToolsMixed().SystemCallWarn("python3 " + scriptOut, "MatplotACF::Plot()"); diff --git a/src/lib-base/src/OptimizerBase.cpp b/src/lib-base/src/OptimizerBase.cpp index dc1ce48..6f55104 100644 --- a/src/lib-base/src/OptimizerBase.cpp +++ b/src/lib-base/src/OptimizerBase.cpp @@ -123,7 +123,7 @@ void OptimizerBase::operator()() Consume(dataNewT.at(i)); if (gcfgMan.cfgOpti->OPTI_RANDOM_EARLY_STOP && IsEarlyStop()) { - LOGL << "Early stop. The recent changes were less than " << gcfgMan.cfgOpti->OPTI_RANDOM_MIN_DIFF_PROMILE << " ‰ after " << i << " iterations.\n"; + LOGL << "Early stop. The recent variance changes were less than " << gcfgMan.cfgOpti->OPTI_RANDOM_MIN_DIFF_PROMILE << " ‰ after " << i << " iterations.\n"; break; } } @@ -251,7 +251,7 @@ void OptimizerBase::PlotVariance() const const float scaleY = 0.5; const Formatters fmt; ELO - GnuplotPlotTerminal1d(m_goalsMod.Diffs().Smooth(GetSmoothing()), "Variance changes:", scaleX, scaleY); + GnuplotPlotTerminal1d(m_goalsMod.Diffs().Smooth(GetSmoothing()), "Variance changes (low values mean that no better solution can be found):", scaleX, scaleY); LOG << "Best │ " << fmt.VecLabel() << " │\n"; LOG << fmt.FormatVar(m_goalMax) << " " << fmt.FormatVec(m_goals) << Endl; const StatsUtil::Distrib & distrib = StatsUtil().GetDistrib(m_goals); diff --git a/src/tsqsim-lib/static/scripts/plot_acf_pacf.py b/src/tsqsim-lib/static/scripts/plot_acf_pacf.py index 3c9dd5e..fe8a3a3 100644 --- a/src/tsqsim-lib/static/scripts/plot_acf_pacf.py +++ b/src/tsqsim-lib/static/scripts/plot_acf_pacf.py @@ -15,11 +15,28 @@ #from pandas.plotting import register_matplotlib_converters #from statsmodels.graphics.tsaplots import plot_acf, plot_pacf #register_matplotlib_converters() +from statsmodels.tsa.stattools import acf, pacf -def plotData(data, lags): +def plotACF(data, lags, title): obj = pd.plotting.autocorrelation_plot(data) obj.set_xlim([0, lags]) + obj.set_title("Autocorr. (" + str(lags) + ") " + title) + plt.show() + +def plotPACF(data, lags, title): + pacf_vals = pacf(data) + #fig = plt.figure() + y = pacf_vals#[:lags] + length = len(y) + if lags > length: + lags = length + x = list(range(lags)) + print(len(x)) + print(length) + plt.bar(x, y) + plt.grid() + plt.title("Partial Autocorr. (" + str(lags) + ") " + title) plt.show() def demo(): @@ -41,7 +58,8 @@ def demo(): #acf_plot = plot_acf(df_ice_cream.production, lags=100) a = [1, 2, 3, 4, 5, 6] - plotData(a, 4) + plotACF(a, 4, "demo") + plotPACF(a, 4, "demo") #obj = pd.plotting.autocorrelation_plot(df_ice_cream.production) #plt.show() @@ -49,4 +67,4 @@ def demo(): #acf_plot = plot_acf(a, lags=5) #acf_plot.show() -#demo() +demo()