Commit 2b7b4649 authored by Davis King's avatar Davis King

Added probability_gradient_greater_than() and probability_gradient_less_than()

global functions.
parent 16d4d5d8
......@@ -151,6 +151,51 @@ namespace dlib
matrix<double,2,1> w;
double residual_squared;
};
// ----------------------------------------------------------------------------------------
template <
typename T
>
double probability_gradient_less_than (
const T& container,
double thresh
)
{
running_gradient g;
for(auto&& v : container)
g.add(v);
// make sure requires clause is not broken
DLIB_ASSERT(g.current_n() > 2,
"\t double probability_gradient_less_than()"
<< "\n\t You need more than 2 elements in the given container to call this function."
);
return g.probability_gradient_less_than(thresh);
}
template <
typename T
>
double probability_gradient_greater_than (
const T& container,
double thresh
)
{
running_gradient g;
for(auto&& v : container)
g.add(v);
// make sure requires clause is not broken
DLIB_ASSERT(g.current_n() > 2,
"\t double probability_gradient_greater_than()"
<< "\n\t You need more than 2 elements in the given container to call this function."
);
return g.probability_gradient_greater_than(thresh);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RuNNING_GRADIENT_Hh_
......
......@@ -116,6 +116,45 @@ namespace dlib
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
template <
typename T
>
double probability_gradient_less_than (
const T& container,
double thresh
);
/*!
requires
- container muse be a container of double values that can be enumerated with a
range based for loop.
- The container must contain more than 2 elements.
ensures
- Puts all the elements of container into a running_gradient object, R, and
then returns R.probability_gradient_less_than(thresh).
!*/
template <
typename T
>
double probability_gradient_greater_than (
const T& container,
double thresh
);
/*!
requires
- container muse be a container of double values that can be enumerated with a
range based for loop.
- The container must contain more than 2 elements.
ensures
- Puts all the elements of container into a running_gradient object, R, and
then returns R.probability_gradient_greater_than(thresh).
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_RuNNING_GRADIENT_ABSTRACT_Hh_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment