Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
StatsHelper.java
Go to the documentation of this file.
1
// Copyright 2014 Cloudera Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
package
com.cloudera.impala.util;
16
28
public
class
StatsHelper<T
extends
Number> {
29
30
private
long
count_ = 0;
31
32
// Current mean
33
private
double
mean_ = 0.0d;
34
35
// Sum of the square differences from the mean
36
private
double
m2_ = 0.0d;
37
38
public
void
addSample
(T val) {
39
++count_;
40
mean_ += (val.doubleValue() - mean_) / count_;
41
m2_ += Math.pow(val.doubleValue() - mean_, 2);
42
}
43
44
public
long
count
() {
return
count_; }
45
46
public
double
mean
() {
47
return
count_ > 0 ? mean_ : 0.0;
48
}
49
50
public
double
variance
() {
51
return
count_ > 1 ? m2_ / (count_ - 1) : 0.0d;
52
}
53
54
public
double
stddev
() {
55
return
Math.sqrt(variance());
56
}
57
}
com.cloudera.impala.util.StatsHelper< T extends Number >.variance
double variance()
Definition:
StatsHelper.java:50
com.cloudera.impala.util.StatsHelper< T extends Number >.stddev
double stddev()
Definition:
StatsHelper.java:54
com.cloudera.impala.util.StatsHelper< T extends Number >.mean
double mean()
Definition:
StatsHelper.java:46
com.cloudera.impala.util.StatsHelper< T extends Number >.addSample
void addSample(T val)
Definition:
StatsHelper.java:38
com.cloudera.impala.util.StatsHelper< T extends Number >.count
long count()
Definition:
StatsHelper.java:44
fe
src
main
java
com
cloudera
impala
util
StatsHelper.java
Generated on Thu May 7 2015 16:10:39 for Impala by
1.8.6