Project

General

Profile

Statistics
| Branch: | Revision:

root / src / scave / stddev.h @ a3be1d55

History | View | Annotate | Download (2.02 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  STDDEV.H - part of
3
//                  OMNeT++/OMNEST
4
//           Discrete System Simulation in C++
5
//
6
//  Author: Tamas Borbely
7
//
8
//=========================================================================
9
10
/*--------------------------------------------------------------*
11
  Copyright (C) 1992-2008 Andras Varga
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

14
  This file is distributed WITHOUT ANY WARRANTY. See the file
15
  `license' for details on this and other legal matters.
16
*--------------------------------------------------------------*/
17
18
#ifndef _STDDEV_H_
19
#define _STDDEV_H_
20
21
#include "commonnodes.h"
22
#include "xyarray.h"
23
24
NAMESPACE_BEGIN
25
26
27
/**
28
 * Calculates min, max, mean, stddev.
29
 */
30
class SCAVE_API StddevNode : public SingleSinkNode
31
{
32
    protected:
33
         long num_vals;
34
         double min_vals, max_vals;
35
         double sum_vals, sqrsum_vals;
36
37
    protected:
38
        virtual void collect(double val);
39
40
    public:
41
        StddevNode();
42
        virtual ~StddevNode();
43
        virtual bool isReady() const;
44
        virtual void process();
45
        virtual bool isFinished() const;
46
47
        virtual long getCount() const     {return num_vals;}
48
        virtual double getSum() const     {return sum_vals;}
49
        virtual double getSqrSum() const  {return sqrsum_vals;}
50
        virtual double getMin() const     {return min_vals;}
51
        virtual double getMax() const     {return max_vals;}
52
        virtual double getMean() const    {return num_vals ? sum_vals/num_vals : 0.0;}
53
        virtual double getStddev() const;
54
        virtual double getVariance() const;
55
};
56
57
58
class SCAVE_API StddevNodeType : public SingleSinkNodeType
59
{
60
    public:
61
        virtual const char *getName() const {return "stddev";}
62
        virtual const char *getDescription() const;
63
        virtual bool isHidden() const {return true;}
64
        virtual void getAttributes(StringMap& attrs) const;
65
        virtual Node *create(DataflowManager *mgr, StringMap& attrs) const;
66
};
67
68
NAMESPACE_END
69
70
71
#endif
72