#include "stdafx.h"
#include "kronecker.h"
Go to the source code of this file.
|
void | GetMinMax (const TFltPrV &XYValV, double &Min, double &Max, const bool &ResetMinMax) |
|
void | PlotGrad (const TFltPrV &EstLLV, const TFltPrV &TrueLLV, const TVec< TFltPrV > &GradVV, const TFltPrV &AcceptV, const TStr &OutFNm, const TStr &Desc) |
|
void | PlotAutoCorrelation (const TFltV &ValV, const int &MaxK, const TStr &OutFNm, const TStr &Desc) |
|
void | McMcGetAvgAvg (const TFltV &AvgJV, double &AvgAvg) |
|
void | McMcGetAvgJ (const TVec< TFltV > &ChainLLV, TFltV &AvgJV) |
|
void | PlotTrueAndEst (const TStr &OutFNm, const TStr &Desc, const TStr &YLabel, const TFltPrV &EstV, const TFltPrV &TrueV) |
|
void GetMinMax |
( |
const TFltPrV & |
XYValV, |
|
|
double & |
Min, |
|
|
double & |
Max, |
|
|
const bool & |
ResetMinMax |
|
) |
| |
Definition at line 1732 of file kronecker.cpp.
1734 for (
int i = 0; i < XYValV.
Len(); i++) {
1735 Min =
TMath::Mn(Min, XYValV[i].Val2.Val);
1736 Max =
TMath::Mx(Max, XYValV[i].Val2.Val);
static const T & Mn(const T &LVal, const T &RVal)
static const T & Mx(const T &LVal, const T &RVal)
TSizeTy Len() const
Returns the number of elements in the vector.
void McMcGetAvgAvg |
( |
const TFltV & |
AvgJV, |
|
|
double & |
AvgAvg |
|
) |
| |
Definition at line 1876 of file kronecker.cpp.
1878 for (
int j = 0; j < AvgJV.
Len(); j++) {
1879 AvgAvg += AvgJV[j]; }
1880 AvgAvg /= AvgJV.
Len();
TSizeTy Len() const
Returns the number of elements in the vector.
Definition at line 1883 of file kronecker.cpp.
1884 for (
int j = 0; j < ChainLLV.
Len(); j++) {
1885 const TFltV& ChainV = ChainLLV[j];
1887 for (
int i = 0; i < ChainV.
Len(); i++) {
1890 AvgJV.
Add(Avg/ChainV.
Len());
TSizeTy Len() const
Returns the number of elements in the vector.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void PlotAutoCorrelation |
( |
const TFltV & |
ValV, |
|
|
const int & |
MaxK, |
|
|
const TStr & |
OutFNm, |
|
|
const TStr & |
Desc |
|
) |
| |
Definition at line 1773 of file kronecker.cpp.
1774 double Avg=0.0, Var=0.0;
1775 for (
int i = 0; i < ValV.
Len(); i++) { Avg += ValV[i]; }
1776 Avg /= (double) ValV.
Len();
1777 for (
int i = 0; i < ValV.
Len(); i++) { Var +=
TMath::Sqr(ValV[i]-Avg); }
1779 for (
int k = 0; k <
TMath::Mn(ValV.
Len(), MaxK); k++) {
1781 for (
int i = 0; i < ValV.
Len() - k; i++) {
1782 corr += (ValV[i]-Avg)*(ValV[i+k]-Avg);
1788 GP.AddPlot(ACorrV,
gpwLines,
"",
"linewidth 1");
1789 GP.SetXYLabel(
"Lag, k",
"Autocorrelation, r_k");
static const T & Mn(const T &LVal, const T &RVal)
TSizeTy Len() const
Returns the number of elements in the vector.
static double Sqr(const double &x)
TPair< TFlt, TFlt > TFltPr
static TStr Fmt(const char *FmtStr,...)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Vector is a sequence TVal objects representing an array that can change in size.
Definition at line 1740 of file kronecker.cpp.
1741 double Min, Max, Min1, Max1;
1744 GP.AddPlot(EstLLV,
gpwLines,
"Esimated LL",
"linewidth 1");
1745 if (! TrueLLV.
Empty()) { GP.AddPlot(TrueLLV,
gpwLines,
"TRUE LL",
"linewidth 1"); }
1748 GP.SetXYLabel(
"Sample Index (time)",
"Log-likelihood");
1751 {
TGnuPlot GP(
"sAcc-"+OutFNm,
TStr::Fmt(
"Pct. accepted rnd moves (over 1k samples). %s", Desc.
CStr()),
true);
1752 GP.AddPlot(AcceptV,
gpwLines,
"Pct accepted swaps",
"linewidth 1");
1753 GP.SetXYLabel(
"Sample Index (time)",
"Pct accept permutation swaps");
1758 for (
int g = 0; g < GradVV.
Len(); g++) {
1760 GetMinMax(GradVV[g], Min1, Max1,
false);
1764 GP.SetYRange((
int)floor(Min-1), (
int)ceil(Max+1));
1765 GP.SetXYLabel(
"Sample Index (time)",
"Gradient");
1768 GPAll.SetYRange((
int)floor(Min1-1), (
int)ceil(Max1+1));
1769 GPAll.SetXYLabel(
"Sample Index (time)",
"Gradient");
TSizeTy Len() const
Returns the number of elements in the vector.
void GetMinMax(const TFltPrV &XYValV, double &Min, double &Max, const bool &ResetMinMax)
bool Empty() const
Tests whether the vector is empty.
static TStr Fmt(const char *FmtStr,...)
Definition at line 2009 of file kronecker.cpp.
2012 if (! TrueV.
Empty()) { GP.AddPlot(TrueV,
gpwLines,
"TRUE"); }
2013 GP.SetXYLabel(
"Gradient descent iterations", YLabel);
bool Empty() const
Tests whether the vector is empty.
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())