statVec: Transform an input vector into one with defined mean and...

Description Usage Arguments Details Value Author(s) Examples

View source: R/statVec.R

Description

Transforms an input vector into one with defined μ and σ by using a scaled-and-shifted Z-transformation.

Usage

1

Arguments

x

the input vector to be transformed.

mean

the desired mean of the created vector.

sd

the desired standard deviation of the created vector.

Details

Calculates vector V using a Z-transformation of the input vector X and subsequent scaling by sd and shifting by mean:

V = \frac{X - μ_X}{σ_X} \cdot \rm{sd} + \rm{mean}

Value

A vector with defined μ and σ.

Author(s)

Andrej-Nikolai Spiess

Examples

1
2
3
4
5
6
7
8
## Create a 10-sized vector with mean = 10 and s.d. = 1.
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!

propagate documentation built on May 7, 2018, 1:03 a.m.