# rescale: Rescale Mean And/Or Standard Deviation of a Vector In ibawds: Functions and Datasets for the Data Science Course at IBAW

## Description

Rescale Mean And/Or Standard Deviation of a Vector

## Usage

 `1` ```rescale(x, mu = mean(x), sigma = sd(x)) ```

## Arguments

 `x` numeric vector `mu` numeric value giving the desired mean `sigma` numeric value giving the desired standard deviation

## Details

By default, mean and standard deviation are not changed, i.e., `rescale(x)` is identical to `x`. Only if a value is specified for `mu` and/or `sigma` the mean and/or the standard deviation are rescaled.

## Value

a numeric vector with the same length as `x` with mean `mu` and standard deviation `sigma`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ```x <- runif(1000, 5, 8) # calling rescale without specifying mu and sigma doesn't change anything all.equal(x, rescale(x)) # change the mean without changing the standard deviation x1 <- rescale(x, mu = 3) all.equal(mean(x1), 3) all.equal(sd(x1), sd(x)) # rescale mean and standard deviation x2 <- rescale(x, mu = 3, sigma = 2) all.equal(mean(x2), 3) all.equal(sd(x2), 2) ```

ibawds documentation built on May 29, 2021, 5:06 p.m.