Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
2b7b4649
Commit
2b7b4649
authored
Feb 06, 2016
by
Davis King
Browse files
Added probability_gradient_greater_than() and probability_gradient_less_than()
global functions.
parent
16d4d5d8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
dlib/statistics/running_gradient.h
dlib/statistics/running_gradient.h
+45
-0
dlib/statistics/running_gradient_abstract.h
dlib/statistics/running_gradient_abstract.h
+39
-0
No files found.
dlib/statistics/running_gradient.h
View file @
2b7b4649
...
@@ -151,6 +151,51 @@ namespace dlib
...
@@ -151,6 +151,51 @@ namespace dlib
matrix
<
double
,
2
,
1
>
w
;
matrix
<
double
,
2
,
1
>
w
;
double
residual_squared
;
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_
#endif // DLIB_RuNNING_GRADIENT_Hh_
...
...
dlib/statistics/running_gradient_abstract.h
View file @
2b7b4649
...
@@ -116,6 +116,45 @@ namespace dlib
...
@@ -116,6 +116,45 @@ namespace dlib
/*!
/*!
provides serialization support
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_
#endif // DLIB_RuNNING_GRADIENT_ABSTRACT_Hh_
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment