[Positioner] Measurement: rename variance variables
We compute only the variance for the milliwatt values, so the variance-related variables are renamed with the _mw suffix.
This commit is contained in:
parent
812c616841
commit
b952dc94ab
|
@ -108,15 +108,15 @@ void Measurement::merge(const Measurement &source)
|
||||||
/**
|
/**
|
||||||
* - #ap is not deleted, only initialised to NULL.
|
* - #ap is not deleted, only initialised to NULL.
|
||||||
* - #ss_list is cleared.
|
* - #ss_list is cleared.
|
||||||
* - #average_dbm, #average_mw and #variance are reset to 0.
|
* - #average_dbm, #average_mw and #variance_mw are reset to 0.
|
||||||
*/
|
*/
|
||||||
void Measurement::clear()
|
void Measurement::clear()
|
||||||
{
|
{
|
||||||
ss_list.clear() ;
|
ss_list.clear() ;
|
||||||
average_dbm = 0 ;
|
average_dbm = 0 ;
|
||||||
average_mw = 0 ;
|
average_mw = 0 ;
|
||||||
variance = 0 ;
|
variance_mw = 0 ;
|
||||||
variance_m2 = 0 ;
|
variance_mw_m2 = 0 ;
|
||||||
ap = NULL ;
|
ap = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +137,12 @@ float Measurement::similarity(const Measurement &source) const
|
||||||
return ss_square_distance(source) ;
|
return ss_square_distance(source) ;
|
||||||
|
|
||||||
if (algorithm == "interval")
|
if (algorithm == "interval")
|
||||||
return 1 / nb_in_interval(source, get_std_deviation()) ;
|
return 1 / nb_in_interval(source, get_std_deviation_mw()) ;
|
||||||
/* Note: this score ranges from 0 (excluded) to 1 (obviously). */
|
/* Note: this score ranges from 0 (excluded) to 1 (obviously). */
|
||||||
|
|
||||||
if (algorithm == "interval2")
|
if (algorithm == "interval2")
|
||||||
{
|
{
|
||||||
float std_dev = get_std_deviation() ;
|
float std_dev = get_std_deviation_mw() ;
|
||||||
float interval1 = nb_in_interval(source, 0.674 * std_dev) ;
|
float interval1 = nb_in_interval(source, 0.674 * std_dev) ;
|
||||||
float interval2 = nb_in_interval(source, std_dev) ;
|
float interval2 = nb_in_interval(source, std_dev) ;
|
||||||
/* Explanation: with a normal distribution, we normally have:
|
/* Explanation: with a normal distribution, we normally have:
|
||||||
|
@ -184,8 +184,8 @@ void Measurement::recalculate_average()
|
||||||
{
|
{
|
||||||
average_dbm = 0 ;
|
average_dbm = 0 ;
|
||||||
average_mw = 0 ;
|
average_mw = 0 ;
|
||||||
variance = 0 ;
|
variance_mw = 0 ;
|
||||||
variance_m2 = 0 ;
|
variance_mw_m2 = 0 ;
|
||||||
|
|
||||||
for (map<pkt_id_t, ss_t>::const_iterator
|
for (map<pkt_id_t, ss_t>::const_iterator
|
||||||
i = ss_list.begin() ; i != ss_list.end() ; ++i)
|
i = ss_list.begin() ; i != ss_list.end() ; ++i)
|
||||||
|
@ -204,9 +204,9 @@ void Measurement::update_average(ss_t ss_dbm)
|
||||||
average_dbm = 10.0 * log10(average_mw) ;
|
average_dbm = 10.0 * log10(average_mw) ;
|
||||||
|
|
||||||
// Update the variance:
|
// Update the variance:
|
||||||
variance_m2 += delta * (ss_mw - average_mw) ;
|
variance_mw_m2 += delta * (ss_mw - average_mw) ;
|
||||||
if (ss_list.size() > 1)
|
if (ss_list.size() > 1)
|
||||||
variance = variance_m2 / (ss_list.size() - 1) ;
|
variance_mw = variance_mw_m2 / (ss_list.size() - 1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -223,8 +223,8 @@ Measurement& Measurement::operator=(const Measurement &m)
|
||||||
ss_list = m.ss_list ;
|
ss_list = m.ss_list ;
|
||||||
average_dbm = m.average_dbm ;
|
average_dbm = m.average_dbm ;
|
||||||
average_mw = m.average_mw ;
|
average_mw = m.average_mw ;
|
||||||
variance = m.variance ;
|
variance_mw = m.variance_mw ;
|
||||||
variance_m2 = m.variance_m2 ;
|
variance_mw_m2 = m.variance_mw_m2 ;
|
||||||
|
|
||||||
return *this ;
|
return *this ;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ ostream &operator<<(ostream &os, const Measurement &m)
|
||||||
os << static_cast<int_fast16_t>(i->second)
|
os << static_cast<int_fast16_t>(i->second)
|
||||||
<< '(' << i->first << ')' ;
|
<< '(' << i->first << ')' ;
|
||||||
}
|
}
|
||||||
os << " [AVG=" << m.average_dbm << "]" ;
|
os << " [AVG_dBm=" << m.average_dbm << ";AVG_mW=" << m.average_mw << ";VAR_mW=" << m.variance_mw << ";STD_mW=" << m.get_std_deviation_mw() << "]" ;
|
||||||
|
|
||||||
return os ;
|
return os ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,12 @@ protected:
|
||||||
float average_dbm ;
|
float average_dbm ;
|
||||||
/// Average of all the captured signal strengths (mW)
|
/// Average of all the captured signal strengths (mW)
|
||||||
float average_mw ;
|
float average_mw ;
|
||||||
/// Variance of all the captured signal strengths
|
/// Variance of all the captured signal strengths (mW)
|
||||||
float variance ;
|
float variance_mw ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Intermediate variable used to compute the variance
|
/// Intermediate variable used to compute the variance
|
||||||
float variance_m2 ;
|
float variance_mw_m2 ;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -54,12 +54,12 @@ protected:
|
||||||
public:
|
public:
|
||||||
Measurement(const AccessPoint *_ap = NULL):
|
Measurement(const AccessPoint *_ap = NULL):
|
||||||
ap(const_cast<AccessPoint*>(_ap)), average_dbm(0),
|
ap(const_cast<AccessPoint*>(_ap)), average_dbm(0),
|
||||||
average_mw(0), variance(0), variance_m2(0) {}
|
average_mw(0), variance_mw(0), variance_mw_m2(0) {}
|
||||||
|
|
||||||
Measurement(const Measurement &source):
|
Measurement(const Measurement &source):
|
||||||
ap(source.ap), ss_list(source.ss_list),
|
ap(source.ap), ss_list(source.ss_list),
|
||||||
average_dbm(source.average_dbm), average_mw(source.average_mw),
|
average_dbm(source.average_dbm), average_mw(source.average_mw),
|
||||||
variance(source.variance), variance_m2(0) {}
|
variance_mw(source.variance_mw), variance_mw_m2(0) {}
|
||||||
|
|
||||||
~Measurement(void) ;
|
~Measurement(void) ;
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ public:
|
||||||
/// Returns the mean of the SS list, in dBm
|
/// Returns the mean of the SS list, in dBm
|
||||||
float get_average_dbm() const ;
|
float get_average_dbm() const ;
|
||||||
/// Returns the variance of the SS list
|
/// Returns the variance of the SS list
|
||||||
float get_variance() const ;
|
float get_variance_mw() const ;
|
||||||
/// Returns the standard deviation of the SS list
|
/// Returns the standard deviation of the SS list
|
||||||
float get_std_deviation() const ;
|
float get_std_deviation_mw() const ;
|
||||||
/// Returns the number of SS in the SS list
|
/// Returns the number of SS in the SS list
|
||||||
int get_nb_ss() const ;
|
int get_nb_ss() const ;
|
||||||
//@}
|
//@}
|
||||||
|
@ -101,10 +101,10 @@ public:
|
||||||
float ss_square_distance(const Measurement &source) const ;
|
float ss_square_distance(const Measurement &source) const ;
|
||||||
/// Computes the distance to another SS value (in dBm)
|
/// Computes the distance to another SS value (in dBm)
|
||||||
float ss_square_distance(const float &ss_dbm) const ;
|
float ss_square_distance(const float &ss_dbm) const ;
|
||||||
/// Computes the distance to another Measurement's variance
|
/// Computes the distance to another Measurement's variance (mW)
|
||||||
float variance_square_distance(const Measurement &source) const ;
|
float variance_mw_square_distance(const Measurement &source) const ;
|
||||||
/// Computes the distance to another variance value
|
/// Computes the distance to another variance value in mW
|
||||||
float variance_square_distance(const float &var) const ;
|
float variance_mw_square_distance(const float &var) const ;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** @name Operators */
|
/** @name Operators */
|
||||||
|
@ -142,15 +142,15 @@ inline float Measurement::get_average_dbm() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float Measurement::get_variance() const
|
inline float Measurement::get_variance_mw() const
|
||||||
{
|
{
|
||||||
return variance ;
|
return variance_mw ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float Measurement::get_std_deviation() const
|
inline float Measurement::get_std_deviation_mw() const
|
||||||
{
|
{
|
||||||
return sqrt(variance) ;
|
return sqrt(variance_mw) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,16 +188,16 @@ inline float Measurement::ss_square_distance(const float &ss_dbm) const
|
||||||
|
|
||||||
|
|
||||||
inline float Measurement::
|
inline float Measurement::
|
||||||
variance_square_distance(const Measurement &source) const
|
variance_mw_square_distance(const Measurement &source) const
|
||||||
{
|
{
|
||||||
return variance_square_distance(source.variance) ;
|
return variance_mw_square_distance(source.variance_mw) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float Measurement::
|
inline float Measurement::
|
||||||
variance_square_distance(const float &var) const
|
variance_mw_square_distance(const float &var) const
|
||||||
{
|
{
|
||||||
return ((var - variance) * (var - variance)) ;
|
return ((var - variance_mw) * (var - variance_mw)) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue