Commit c324a65e authored by Davis King's avatar Davis King

Added get_double_in_range() to dlib::rand.

parent 1970bf29
...@@ -137,6 +137,15 @@ namespace dlib ...@@ -137,6 +137,15 @@ namespace dlib
return (a<<32)|b; return (a<<32)|b;
} }
double get_double_in_range (
double begin,
double end
)
{
DLIB_ASSERT(begin <= end);
return begin + get_random_double()*(end-begin);
}
double get_random_double ( double get_random_double (
) )
{ {
......
...@@ -135,6 +135,20 @@ namespace dlib ...@@ -135,6 +135,20 @@ namespace dlib
- returns a random double number N where: 0.0 <= N < 1.0. - returns a random double number N where: 0.0 <= N < 1.0.
!*/ !*/
double get_double_in_range (
double begin,
double end
);
/*!
requires
- begin <= end
ensures
- if (begin < end) then
- returns a random double number N where: begin <= N < end.
- else
- returns begin
!*/
double get_random_gaussian ( double get_random_gaussian (
); );
/*! /*!
......
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