Skip to content

Commit

Permalink
added an errors() call with returns the scaled standard deviation, ref
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Benazera committed Mar 9, 2015
1 parent d4b54ef commit 2e049b2
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/cmasolutions.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,11 @@ namespace libcmaes
}

/**
* \returns standard deviation vector
* @return standard deviation vector
* \returns the unscaled standard deviation vector
* Note: this is only useful to compare amond standard deviations
* To get the true rescaled estimate of the error, use errors()
* @param cmaparams parameter object that hold the genotype/phenotype transform
* @return unscaled standard deviation vector
*/
template<class TGenoPheno=GenoPheno<NoBoundStrategy>>
inline dVec stds(const CMAParameters<TGenoPheno> &cmaparams) const
Expand All @@ -300,6 +303,23 @@ namespace libcmaes
return dVec(); // should never reach here.
}

/**
* \returns standard deviation vector
* @param cmaparams parameter object that hold the genotype/phenotype transform
* @return standard deviation vector
*/
template<class TGenoPheno=GenoPheno<NoBoundStrategy>>
inline dVec errors(const CMAParameters<TGenoPheno> &cmaparams) const
{
if (!cmaparams.is_sep() && !cmaparams.is_vd())
return cmaparams.get_gp().pheno(static_cast<dVec>(std::sqrt(_sigma)*_cov.diagonal().cwiseSqrt()));
else if (cmaparams.is_sep())
return cmaparams.get_gp().pheno(static_cast<dVec>(std::sqrt(_sigma)*_sepcov.cwiseSqrt()));
else if (cmaparams.is_vd())
return cmaparams.get_gp().pheno(static_cast<dVec>(std::sqrt(_sigma)*(dVec::Constant(cmaparams.dim(),1.0)+_v.cwiseProduct(_v)).cwiseSqrt().cwiseProduct(_sepcov)));
return dVec(); // should never reach here.
}

/**
* \brief returns correlation matrix
* @return correlation matrix
Expand Down

0 comments on commit 2e049b2

Please sign in to comment.