Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
dcdb
dcdb
Commits
bea7ae7c
Commit
bea7ae7c
authored
Jan 25, 2021
by
Alessio Netti
Browse files
Analytics: improving normalization in CS plugin
parent
97e618bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
analytics/operators/cssignatures/CSOperator.cpp
View file @
bea7ae7c
...
...
@@ -429,13 +429,13 @@ void CSOperator::computeSignature(U_Ptr unit, uint64_t nowTs) {
// Normalizes sensor data
void
CSOperator
::
normalize
(
std
::
vector
<
reading_t
>
&
v
,
size_t
idx
)
{
int64_t
denom
=
_max
[
idx
]
!=
_min
[
idx
]
?
(
_max
[
idx
]
-
_min
[
idx
])
:
1
;
double
denom
=
_max
[
idx
]
!=
_min
[
idx
]
?
(
double
)
_scalingFactor
/
(
double
)
(
_max
[
idx
]
-
_min
[
idx
])
:
(
double
)
_scalingFactor
;
for
(
size_t
idx2
=
0
;
idx2
<
v
.
size
();
idx2
++
)
{
if
(
v
[
idx2
].
value
>
_max
[
idx
])
v
[
idx2
].
value
=
_max
[
idx
];
else
if
(
v
[
idx2
].
value
<
_min
[
idx
])
v
[
idx2
].
value
=
_min
[
idx
];
v
[
idx2
].
value
=
(
v
[
idx2
].
value
-
_min
[
idx
])
*
_scalingFactor
/
denom
;
v
[
idx2
].
value
=
(
int64_t
)((
double
)
(
v
[
idx2
].
value
-
_min
[
idx
])
*
denom
)
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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