ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
This module contains classes and procedures for computing the first moment (i.e., the statistical mean) of random weighted samples. More...
Data Types | |
interface | getMean |
Generate and return the (weighted) mean of an input sample of nsam observations with ndim = 1 or 2 attributes, optionally weighted by the input weight .More... | |
interface | getMeanMerged |
Generate and return the (weighted) merged mean of a sample resulting from the merger of two separate (weighted) samples \(A\) and \(B\). More... | |
interface | setMean |
Return the (weighted) mean of a pair of time series or of an input sample of nsam observations with ndim = 1 or 2 attributes, optionally weighted by the input weight , optionally also sum(weight) and optionally, sum(weight**2) .More... | |
interface | setMeanMerged |
Return the (weighted) merged mean of a sample resulting from the merger of two separate (weighted) samples \(A\) and \(B\). More... | |
Variables | |
character(*, SK), parameter | MODULE_NAME = "@pm_sampleMean" |
This module contains classes and procedures for computing the first moment (i.e., the statistical mean) of random weighted samples.
The mean of a weighted sample of \(N\) data points is computed by the following equation,
\begin{equation} \mu = \frac{\sum_{i = 1}^{N} w_i x_i}{\sum_{i = 1}^{N} w_i} \end{equation}
where \(w_i\) represents the weight of the \(i\)th sample.
Suppose the mean of an initial (potentially weighted) sample \(x_A\) of size \(N_A\) is computed to be \(\mu_A\).
Another (potentially weighted) sample \(x_B\) of size \(N_B\) is subsequently obtained with a different number observations and mean \(\mu_B\).
The mean of the two samples combined can be expressed in terms of the originally computed means,
\begin{equation} \large \mu = \frac { w_A \sum_{i = 1}^{N_A} w_{\up{A,i}} x_{\up{A,i}} + w_B \sum_{i = 1}^{N_B} w_{\up{B,i}} x_{\up{B,i}} }{ w_A + w_B } \end{equation}
where \(\large w_A = \sum_{i = 1}^{N_A} w_{\up{A,i}}\) and \(\large w_B = \sum_{i = 1}^{N_B} w_{\up{B,i}}\) are sums of the weights of the corresponding samples.
For equally-weighted samples, the corresponding weights \(w_{\up{A,i}}\) or \(w_{\up{B,i}}\) or both are all unity such that \(N_A = w_A\) or \(N_B = w_B\) or both holds.
weight
arguments of type integer
or real
of various kinds, such extensions do not add any benefits beyond making the interface more flexible for the end user.integer
is multiplied with a real
, the integer value must be first converted to real
of the same kind as the real value, then multiplied.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
character(*, SK), parameter pm_sampleMean::MODULE_NAME = "@pm_sampleMean" |
Definition at line 110 of file pm_sampleMean.F90.