Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
94aa5080
Commit
94aa5080
authored
Feb 06, 2016
by
Hahn, Steven
Browse files
Try making RHEL6 happy.
parent
3a007ca2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Framework/Kernel/src/Statistics.cpp
View file @
94aa5080
...
...
@@ -12,6 +12,7 @@
#include
<functional>
#include
<boost/accumulators/accumulators.hpp>
#include
<boost/accumulators/statistics/stats.hpp>
#include
<boost/accumulators/statistics/min.hpp>
#include
<boost/accumulators/statistics/max.hpp>
#include
<boost/accumulators/statistics/variance.hpp>
...
...
@@ -151,46 +152,46 @@ std::vector<double> getModifiedZscore(const vector<TYPE> &data,
*/
template
<
typename
TYPE
>
Statistics
getStatistics
(
const
vector
<
TYPE
>
&
data
,
const
unsigned
int
flags
)
{
Statistics
stats
=
getNanStatistics
();
Statistics
stat
istic
s
=
getNanStatistics
();
size_t
num_data
=
data
.
size
();
// cache since it is frequently used
if
(
num_data
==
0
)
{
// don't do anything
return
stats
;
return
stat
istic
s
;
}
// calculate the mean if this or the stddev is requested
const
bool
stddev
=
((
flags
&
StatOptions
::
UncorrectedStdDev
)
||
(
flags
&
StatOptions
::
CorrectedStdDev
));
if
(
stddev
)
{
using
namespace
boost
::
accumulators
;
accumulator_set
<
TYPE
,
feature
s
<
tag
::
min
,
tag
::
max
,
tag
::
variance
>>
acc
;
accumulator_set
<
double
,
stat
s
<
tag
::
min
,
tag
::
max
,
tag
::
variance
>>
acc
;
for
(
auto
&
value
:
data
)
{
acc
(
value
);
acc
(
static_cast
<
double
>
(
value
)
)
;
}
stats
.
minimum
=
min
(
acc
);
stats
.
maximum
=
max
(
acc
);
stats
.
mean
=
mean
(
acc
);
stat
istic
s
.
minimum
=
min
(
acc
);
stat
istic
s
.
maximum
=
max
(
acc
);
stat
istic
s
.
mean
=
mean
(
acc
);
double
var
=
variance
(
acc
);
if
(
flags
&
StatOptions
::
CorrectedStdDev
)
{
double
ndofs
=
static_cast
<
double
>
(
data
.
size
());
var
*=
ndofs
/
(
ndofs
-
1.0
);
}
stats
.
standard_deviation
=
std
::
sqrt
(
var
);
stat
istic
s
.
standard_deviation
=
std
::
sqrt
(
var
);
}
else
if
(
flags
&
StatOptions
::
Mean
)
{
using
namespace
boost
::
accumulators
;
accumulator_set
<
TYPE
,
feature
s
<
tag
::
mean
>>
acc
;
accumulator_set
<
double
,
stat
s
<
tag
::
mean
>>
acc
;
for
(
auto
&
value
:
data
)
{
acc
(
value
);
acc
(
static_cast
<
double
>
(
value
)
)
;
}
stats
.
mean
=
mean
(
acc
);
stat
istic
s
.
mean
=
mean
(
acc
);
}
// calculate the median if requested
if
(
flags
&
StatOptions
::
Median
)
{
stats
.
median
=
getMedian
(
data
,
num_data
,
flags
&
StatOptions
::
SortedData
);
stat
istic
s
.
median
=
getMedian
(
data
,
num_data
,
flags
&
StatOptions
::
SortedData
);
}
return
stats
;
return
stat
istic
s
;
}
/// Getting statistics of a string array should just give a bunch of NaNs
...
...
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