Skip to content
Snippets Groups Projects

new tag

Merged Joan Vallvé Navarro requested to merge devel into main
8 files
+ 1582
58
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 58
0
 
/*
 
* chisquare_ci.h
 
*
 
* Created on: Jul 28, 2021
 
* Author: joanvallve
 
*/
 
 
#ifndef INCLUDE_GNSS_UTILS_UTILS_CHISQUARE_CI_H_
 
#define INCLUDE_GNSS_UTILS_UTILS_CHISQUARE_CI_H_
 
 
#include "chisquare_ci_maps.h"
 
 
namespace GnssUtils
 
{
 
 
double chisq2ci(double chisq, int dof)
 
{
 
assert(dof > 0);
 
 
if (dof > 30)
 
dof = 30;
 
 
if (chisq_2_CI.at(dof).count(chisq) == 1)
 
return chisq_2_CI.at(dof).at(chisq);
 
 
auto upper = chisq_2_CI.at(dof).upper_bound(chisq);
 
 
if (upper == chisq_2_CI.at(dof).begin())
 
return upper->second;
 
 
auto lower = std::prev(upper);
 
 
return lower->second + (chisq - lower->first) / (upper->first - lower->first) * (upper->second - lower->second);
 
};
 
 
double ci2chisq(double ci, int dof)
 
{
 
assert(dof > 0);
 
 
if (dof > 30)
 
dof = 30;
 
 
if (CI_2_chisq.at(dof).count(ci) == 1)
 
return CI_2_chisq.at(dof).at(ci);
 
 
auto upper = CI_2_chisq.at(dof).upper_bound(ci);
 
 
if (upper == CI_2_chisq.at(dof).begin())
 
return upper->second;
 
 
auto lower = std::prev(upper);
 
 
return lower->second + (ci - lower->first) / (upper->first - lower->first) * (upper->second - lower->second);
 
};
 
 
} // namespace GnssUtils
 
 
#endif /* INCLUDE_GNSS_UTILS_UTILS_CHISQUARE_CI_H_ */
Loading