datafu-pig/src/main/java/datafu/pig/stats/VAR.java [178:205]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        public Double exec(Tuple input) throws IOException {
            try {
                DataBag b = (DataBag)input.get(0);
                Tuple combined = combine(b);

                Double sum = (Double)combined.get(0);
                Double sumSquare = (Double)combined.get(1);
                if(sum == null) {
                    return null;
                }
                Long count = (Long)combined.get(2);

                Double var = null;
                
                if (count > 0) {
                    Double avg = new Double(sum / count);
                    Double avgSquare = new Double(sumSquare / count);
                    var = avgSquare - avg*avg;
                }
                return var;
            } catch (ExecException ee) {
                throw ee;
            } catch (Exception e) {
                int errCode = 2106;
                String msg = "Error while computing variance in " + this.getClass().getSimpleName();
                throw new ExecException(msg, errCode, PigException.BUG, e);
            }
        }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



datafu-pig/src/main/java/datafu/pig/stats/FloatVAR.java [163:190]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        public Double exec(Tuple input) throws IOException {
            try {
                DataBag b = (DataBag)input.get(0);
                Tuple combined = combine(b);

                Double sum = (Double)combined.get(0);
                Double sumSquare = (Double)combined.get(1);
                if(sum == null) {
                    return null;
                }
                Long count = (Long)combined.get(2);

                Double var = null;
                
                if (count > 0) {
                    Double avg = new Double(sum / count);
                    Double avgSquare = new Double(sumSquare / count);
                    var = avgSquare - avg*avg;
                }
                return var;
            } catch (ExecException ee) {
                throw ee;
            } catch (Exception e) {
                int errCode = 2106;
                String msg = "Error while computing variance in " + this.getClass().getSimpleName();
                throw new ExecException(msg, errCode, PigException.BUG, e);
            }
        }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



datafu-pig/src/main/java/datafu/pig/stats/DoubleVAR.java [161:188]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        public Double exec(Tuple input) throws IOException {
            try {
                DataBag b = (DataBag)input.get(0);
                Tuple combined = combine(b);

                Double sum = (Double)combined.get(0);
                Double sumSquare = (Double)combined.get(1);
                if(sum == null) {
                    return null;
                }
                Long count = (Long)combined.get(2);

                Double var = null;
                
                if (count > 0) {
                    Double avg = new Double(sum / count);
                    Double avgSquare = new Double(sumSquare / count);
                    var = avgSquare - avg*avg;
                }
                return var;
            } catch (ExecException ee) {
                throw ee;
            } catch (Exception e) {
                int errCode = 2106;
                String msg = "Error while computing variance in " + this.getClass().getSimpleName();
                throw new ExecException(msg, errCode, PigException.BUG, e);
            }
        }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



