DUNE
Distributed and Unified Numerics Environment
dune-composites (2.5.1)
dune
composites
Setup
RandomFields
general.hh
1
#ifndef general_h
2
#define general_h
3
4
namespace
Dune{
5
namespace
Composites{
6
7
8
double
mean(std::vector<double>& Y){
10
double
Yhat = 0.0;
11
for
(
int
i = 0; i < Y.size(); i++){
12
Yhat += Y[i];
13
}
14
Yhat /= Y.size();
15
return
Yhat;
16
}
17
18
double
var(std::vector<double>& Y){
20
double
Yhat = mean(Y);
21
double
variance = 0.0;
22
int
N = Y.size();
23
24
for
(
int
i = 0; i < N; i++){
25
variance += (Y[i] - Yhat) * (Y[i] - Yhat);
26
}
27
variance /= (N - 1);
28
return
variance;
29
}
30
31
}
32
}
33
34
35
#endif
/* general_h */
|
Legal Statements / Impressum
| Hosted by
TU Dresden
&
Uni Heidelberg
| generated with Hugo v0.111.3 (Sep 5, 22:35, 2025)