FORCES
FORtran lib for Comp. Env. Sys.
|
R-central moment. More...
Public Member Functions | |
real(sp) function | central_moment_sp (x, r, mask) |
real(dp) function | central_moment_dp (x, r, mask) |
R-central moment.
Calculates the central moment of a vector, i.e. the r-central moment of a series of numbers:
\[ \mu_r = \sum_i\frac{(x_i-\bar x)^r}{N} \]
Note that the variance is the second central moment: variance(x) = central_moment(x,2)
If an optinal mask is given, the average is only over those locations that correspond to true values in the mask. x can be single or double precision. The result will have the same numerical precision.
Example
vec = (/ 1., 2, 3., 4., 5., 6. /) m = central_moment(vec, 2, mask=(vec >= 0.)) --> m = 2.91666
See also example in pf_tests directory.
Literature
[in] | real(sp/dp) :: dat(:) | 1D-array with input numbers. |
[in] | integer(i4) :: r | Order of the central moment, i.e. r=2 is variance. |
[in] | logical, optional :: mask(:) | 1D-array of logical values with size(dat). If present, only those locations in dat corresponding to the true values in mask are used. |
real(sp/dp) :: central_moment | R-th central moment of elements in dat . |
Definition at line 162 of file mo_moment.f90.
real(dp) function mo_moment::central_moment::central_moment_dp | ( | real(dp), dimension(:), intent(in) | x, |
integer(i4), intent(in) | r, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 734 of file mo_moment.f90.
real(sp) function mo_moment::central_moment::central_moment_sp | ( | real(sp), dimension(:), intent(in) | x, |
integer(i4), intent(in) | r, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 773 of file mo_moment.f90.