mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Removed the max_n feature from the running_stats object since it's actually
been broken for a while and I doubt anyone ever used it (this also simplifies it's interface). Note that this change, along with the previous change by Steven breaks backwards compatibility with the previous serialization format for running_stats object.
This commit is contained in:
parent
a75645b1af
commit
e66d588cd7
@ -40,18 +40,10 @@ namespace dlib
|
||||
sum_four = 0;
|
||||
|
||||
n = 0;
|
||||
maximum_n = std::numeric_limits<T>::max();
|
||||
min_value = std::numeric_limits<T>::infinity();
|
||||
max_value = -std::numeric_limits<T>::infinity();
|
||||
}
|
||||
|
||||
void set_max_n (
|
||||
const T& val
|
||||
)
|
||||
{
|
||||
maximum_n = val;
|
||||
}
|
||||
|
||||
void add (
|
||||
const T& val
|
||||
)
|
||||
@ -66,14 +58,7 @@ namespace dlib
|
||||
if (val > max_value)
|
||||
max_value = val;
|
||||
|
||||
if (n < maximum_n)
|
||||
++n;
|
||||
}
|
||||
|
||||
T max_n (
|
||||
) const
|
||||
{
|
||||
return maximum_n;
|
||||
++n;
|
||||
}
|
||||
|
||||
T current_n (
|
||||
@ -204,15 +189,6 @@ namespace dlib
|
||||
const running_stats& rhs
|
||||
) const
|
||||
{
|
||||
// make sure requires clause is not broken
|
||||
DLIB_ASSERT(max_n() == rhs.max_n(),
|
||||
"\trunning_stats running_stats::operator+(rhs)"
|
||||
<< "\n\t invalid inputs were given to this function"
|
||||
<< "\n\t max_n(): " << max_n()
|
||||
<< "\n\t rhs.max_n(): " << rhs.max_n()
|
||||
<< "\n\t this: " << this
|
||||
);
|
||||
|
||||
running_stats temp(*this);
|
||||
|
||||
temp.sum += rhs.sum;
|
||||
@ -243,7 +219,6 @@ namespace dlib
|
||||
T sum_cub;
|
||||
T sum_four;
|
||||
T n;
|
||||
T maximum_n;
|
||||
T min_value;
|
||||
T max_value;
|
||||
|
||||
@ -265,7 +240,6 @@ namespace dlib
|
||||
serialize(item.sum_cub, out);
|
||||
serialize(item.sum_four, out);
|
||||
serialize(item.n, out);
|
||||
serialize(item.maximum_n, out);
|
||||
serialize(item.min_value, out);
|
||||
serialize(item.max_value, out);
|
||||
}
|
||||
@ -286,7 +260,6 @@ namespace dlib
|
||||
deserialize(item.sum_cub, in);
|
||||
deserialize(item.sum_four, in);
|
||||
deserialize(item.n, in);
|
||||
deserialize(item.maximum_n, in);
|
||||
deserialize(item.min_value, in);
|
||||
deserialize(item.max_value, in);
|
||||
}
|
||||
|
@ -116,28 +116,12 @@ namespace dlib
|
||||
- T must be a float, double, or long double type
|
||||
|
||||
INITIAL VALUE
|
||||
- max_n() == std::numeric_limits<T>::max()
|
||||
- mean() == 0
|
||||
- current_n() == 0
|
||||
|
||||
WHAT THIS OBJECT REPRESENTS
|
||||
This object represents something that can compute the running mean,
|
||||
variance, skewness, and excess kurtosis of a stream of real numbers.
|
||||
|
||||
As this object accumulates more and more numbers it will be the case
|
||||
that each new number impacts the current mean and variance estimate
|
||||
less and less. This may be what you want. But it might not be.
|
||||
|
||||
For example, your stream of numbers might be non-stationary, that is,
|
||||
the mean and variance might change over time. To enable you to use
|
||||
this object on such a stream of numbers this object provides the
|
||||
ability to set a "max_n." The meaning of the max_n() parameter
|
||||
is that after max_n() samples have been seen each new sample will
|
||||
have the same impact on the mean and variance estimates from then on.
|
||||
|
||||
So if you have a highly non-stationary stream of data you might
|
||||
set the max_n to a small value while if you have a very stationary
|
||||
stream you might set it to a very large value.
|
||||
!*/
|
||||
public:
|
||||
|
||||
@ -156,27 +140,11 @@ namespace dlib
|
||||
- clears all memory of any previous data points
|
||||
!*/
|
||||
|
||||
void set_max_n (
|
||||
const T& val
|
||||
);
|
||||
/*!
|
||||
ensures
|
||||
- #max_n() == val
|
||||
!*/
|
||||
|
||||
T max_n (
|
||||
) const;
|
||||
/*!
|
||||
ensures
|
||||
- returns the max value that current_n() is allowed to take on
|
||||
!*/
|
||||
|
||||
T current_n (
|
||||
) const;
|
||||
/*!
|
||||
ensures
|
||||
- returns the number of points given to this object so far or
|
||||
max_n(), whichever is smallest.
|
||||
- returns the number of points given to this object so far.
|
||||
!*/
|
||||
|
||||
void add (
|
||||
@ -191,10 +159,7 @@ namespace dlib
|
||||
- #variance() == the updated variance that takes this new value into account.
|
||||
- #skewness() == the updated skewness that takes this new value into account.
|
||||
- #ex_kurtosis() == the updated kurtosis that takes this new value into account.
|
||||
- if (current_n() < max_n()) then
|
||||
- #current_n() == current_n() + 1
|
||||
- else
|
||||
- #current_n() == current_n()
|
||||
- #current_n() == current_n() + 1
|
||||
!*/
|
||||
|
||||
T mean (
|
||||
@ -277,8 +242,6 @@ namespace dlib
|
||||
const running_stats& rhs
|
||||
) const;
|
||||
/*!
|
||||
requires
|
||||
- max_n() == rhs.max_n()
|
||||
ensures
|
||||
- returns a new running_stats object that represents the combination of all
|
||||
the values given to *this and rhs. That is, this function returns a
|
||||
|
@ -422,8 +422,6 @@ namespace
|
||||
DLIB_TEST(std::abs((rc1+rc2).covariance() - rc3.covariance()) < 1e-13);
|
||||
DLIB_TEST((rc1+rc2).current_n() == rc3.current_n());
|
||||
|
||||
rs1.set_max_n(50);
|
||||
DLIB_TEST(rs1.max_n() == 50);
|
||||
}
|
||||
|
||||
void test_average_precision()
|
||||
|
Loading…
Reference in New Issue
Block a user