Skip to content
Snippets Groups Projects
Commit 3d8e4e1e authored by Carl Philipp Klemm's avatar Carl Philipp Klemm
Browse files

add multiply add and constant score functions

parent bba6cede
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,12 @@ std::complex<fvalue> eis::absGrad(const std::vector<eis::DataPoint>& data, size_
std::abs((data[index+1].im.imag()-data[index-1].im.imag())/(data[index+1].omega-data[index-1].omega)));
}
void mulitplyAdd(std::vector<eis::DataPoint>& data, fvalue mult, fvalue add)
{
for(eis::DataPoint& point : data)
point.im = point.im*mult + add;
}
fvalue eis::grad(const std::vector<fvalue>& data, const std::vector<fvalue>& omega, size_t index)
{
assert(data.size() == omega.size());
......@@ -197,6 +203,28 @@ fvalue eis::pearsonCorrelation(const std::vector<eis::DataPoint>& data)
return sumDeltaReDeltaIm/(sqrt(sumDeltaReSq)*sqrt(sumDeltaImSq));
}
fvalue eis::nonConstantScore(const std::vector<eis::DataPoint>& data)
{
std::complex<fvalue> meanValue = mean(data);
fvalue reDeviationMax = std::numeric_limits<fvalue>::min();
fvalue imDeviationMax = std::numeric_limits<fvalue>::min();
for(const eis::DataPoint& point : data)
{
fvalue reDeviation = 1-(std::abs(point.im.real())/std::abs(meanValue.real()));
fvalue imDeviation = 1-(std::abs(point.im.imag())/std::abs(meanValue.imag()));
if(reDeviationMax < reDeviation)
reDeviationMax = reDeviation;
if(imDeviationMax < imDeviation)
imDeviationMax = imDeviation;
}
return std::min(reDeviationMax, imDeviationMax);
}
fvalue eis::nyquistAreaVariance(const std::vector<eis::DataPoint>& data, eis::DataPoint* centroid)
{
assert(data.size() > 2);
......
......@@ -30,6 +30,8 @@ namespace eis
* @{
*/
void mulitplyAdd(std::vector<eis::DataPoint>& data, fvalue mult, fvalue add);
/**
* @brief Calculates the element wise absolute gradient at the given point of the data given.
*
......@@ -117,6 +119,8 @@ namespace eis
*/
fvalue pearsonCorrelation(const std::vector<eis::DataPoint>& data);
fvalue nonConstantScore(const std::vector<eis::DataPoint>& data);
/**
* @brief Calculates the variance of the distance of the data from a centroid in the nyquist plane.
*
......
......@@ -576,6 +576,14 @@ std::vector<size_t> Model::getRecommendedParamIndices(eis::Range omegaRange, dou
continue;
}
fvalue nonConstantess = std::abs(pearsonCorrelation(data));
if(nonConstantess < 0.1)
{
eis::Log(eis::Log::DEBUG)<<"skipping output for step "<<i
<<" as data is too constant: "<<nonConstantess;
continue;
}
std::vector<std::vector<eis::DataPoint>>::iterator search;
if(threaded)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment