| statVec | R Documentation |
Transforms an input vector into one with defined \mu and \sigma by using a scaled-and-shifted Z-transformation.
statVec(x, mean, sd)
x |
the input vector to be transformed. |
mean |
the desired mean of the created vector. |
sd |
the desired standard deviation of the created vector. |
Calculates the vector V by a Z-transformation of the input vector X and subsequent scaling by sd and shifting by mean:
V = \frac{X - \bar{X}}{s_X} \cdot \mathrm{sd} + \mathrm{mean}
Only location and scale are changed: the shape of the distribution of x (skewness, kurtosis) is preserved.
The mean and standard deviation of x are computed from its finite values, so that missing and infinite values remain as they are; x needs at least two finite values that are not all equal. This can be used, e.g., to create Monte Carlo samples of an input quantity with exactly the stated estimate and standard uncertainty for propagate with type = "sim".
A vector of the same length as x, with mean equal to mean and standard deviation equal to sd (of its non-missing values).
Andrej-Nikolai Spiess
## Create a vector of 10 values with mean = 5 and s.d. = 2.
x <- rnorm(10, 5, 2)
mean(x) ## => mean is not 5!
sd(x) ## => s.d. is not 2!
z <- statVec(x, 5, 2)
mean(z) ## => mean is 5!
sd(z) ## => s.d. is 2!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.