statistics.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_STATISTICS_H
21 #define LIBMESH_STATISTICS_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/id_types.h"
26 
27 // C++ includes
28 #include <vector>
29 #include <cstdlib> // *must* precede <cmath> for proper std:abs() on PGI, Sun Studio CC
30 #include <cmath>
31 
32 namespace libMesh
33 {
34 
74 // ------------------------------------------------------------
75 // StatisticsVector class definition
76 template <typename T>
77 class StatisticsVector : public std::vector<T>
78 {
79  public:
80 
84  explicit
85  StatisticsVector(dof_id_type i=0) : std::vector<T> (i) {}
86 
90  StatisticsVector(dof_id_type i, T val) : std::vector<T> (i,val) {}
91 
95  virtual ~StatisticsVector () {}
96 
97 
101  virtual Real l2_norm() const;
102 
106  virtual T minimum() const;
107 
111  virtual T maximum() const;
112 
118  virtual Real mean() const;
119 
128  virtual Real median();
129 
135  virtual Real median() const;
136 
145  virtual Real variance() const
146  { return this->variance(this->mean()); }
147 
158  virtual Real variance(const Real known_mean) const;
159 
165  virtual Real stddev() const
166  { return std::sqrt(this->variance()); }
167 
174  virtual Real stddev(const Real known_mean) const
175  { return std::sqrt(this->variance(known_mean)); }
176 
181  void normalize();
182 
192  virtual void histogram (std::vector<dof_id_type>& bin_members,
193  unsigned int n_bins=10);
194 
202  void plot_histogram(const processor_id_type my_procid,
203  const std::string& filename,
204  unsigned int n_bins);
205 
209  virtual void histogram (std::vector<dof_id_type>& bin_members,
210  unsigned int n_bins=10) const;
211 
217  virtual std::vector<dof_id_type> cut_below(Real cut) const;
218 
226  virtual std::vector<dof_id_type> cut_above(Real cut) const;
227 
228 
229  private:
230 
231 };
232 
233 } // namespace libMesh
234 
235 #endif // LIBMESH_STATISTICS_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo