Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
c338b12f
Commit
c338b12f
authored
Jun 19, 2020
by
Alessio Netti
Browse files
Analytics: minor fix to percentile computation
parent
7f514bfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
analytics/includes/CommonStatistics.h
View file @
c338b12f
...
...
@@ -97,8 +97,8 @@ void computePercentiles(std::vector<reading_t> &data, const std::vector<size_t>
// Sorting the sensor reading buffer to extract quantiles
std
::
sort
(
data
.
begin
(),
data
.
end
(),
[
](
const
reading_t
&
lhs
,
const
reading_t
&
rhs
)
{
return
lhs
.
value
<
rhs
.
value
;
});
for
(
const
auto
&
q
:
percentilePositions
)
{
idx
=
(
data
.
size
()
*
q
)
/
100
;
mod
=
(
data
.
size
()
*
q
)
%
100
;
idx
=
(
(
data
.
size
()
-
1
)
*
q
)
/
100
;
mod
=
(
(
data
.
size
()
-
1
)
*
q
)
%
100
;
percentiles
.
push_back
((
mod
==
0
||
idx
==
data
.
size
()
-
1
)
?
data
[
idx
].
value
:
(
data
[
idx
].
value
+
data
[
idx
+
1
].
value
)
/
2
);
}
}
...
...
analytics/operators/regressor/RegressorOperator.cpp
View file @
c338b12f
...
...
@@ -233,15 +233,13 @@ bool RegressorOperator::computeFeatureVector(U_Ptr unit) {
std
::
sort
(
_buffer
.
begin
(),
_buffer
.
end
(),
[](
const
reading_t
&
lhs
,
const
reading_t
&
rhs
)
{
return
lhs
.
value
<
rhs
.
value
;
});
// Computing 25th PERCENTILE
qId
=
(
_buffer
.
size
()
*
25
)
/
100
;
qMod
=
(
_buffer
.
size
()
*
25
)
%
100
;
_qtl25
=
(
qMod
==
0
||
qId
==
_buffer
.
size
()
-
1
)
?
_buffer
[
qId
].
value
:
(
_buffer
[
qId
].
value
+
_buffer
[
qId
+
1
].
value
)
/
2
;
qId
=
((
_buffer
.
size
()
-
1
)
*
25
)
/
100
;
qMod
=
((
_buffer
.
size
()
-
1
)
*
25
)
%
100
;
_qtl25
=
(
qMod
==
0
||
qId
==
_buffer
.
size
()
-
1
)
?
_buffer
[
qId
].
value
:
(
_buffer
[
qId
].
value
+
_buffer
[
qId
+
1
].
value
)
/
2
;
// Computing 75th PERCENTILE
qId
=
(
_buffer
.
size
()
*
75
)
/
100
;
qMod
=
(
_buffer
.
size
()
*
75
)
%
100
;
_qtl75
=
(
qMod
==
0
||
qId
==
_buffer
.
size
()
-
1
)
?
_buffer
[
qId
].
value
:
(
_buffer
[
qId
].
value
+
_buffer
[
qId
+
1
].
value
)
/
2
;
qId
=
((
_buffer
.
size
()
-
1
)
*
75
)
/
100
;
qMod
=
((
_buffer
.
size
()
-
1
)
*
75
)
%
100
;
_qtl75
=
(
qMod
==
0
||
qId
==
_buffer
.
size
()
-
1
)
?
_buffer
[
qId
].
value
:
(
_buffer
[
qId
].
value
+
_buffer
[
qId
+
1
].
value
)
/
2
;
fIdx
=
idx
*
REG_NUMFEATURES
;
// Casting and storing the statistical features
...
...
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