# wnoise

Noisy wavelet test data

## Syntax

``x = wnoise(fun,n)``
``[x,xn] = wnoise(fun,n,sqrtsnr)``
``[x,xn] = wnoise(___,init)``

## Description

````x = wnoise(fun,n)` returns values `x` of the test signal `fun` evaluated at 2n linearly spaced points from 0 to 1.```

example

````[x,xn] = wnoise(fun,n,sqrtsnr)` returns `x` rescaled such that the standard deviation of x is `sqrtsnr`. `xn` is `x` corrupted by additive Gaussian white noise N(0,1) and has a signal-to-noise ratio (SNR) of `sqrtsnr`2.```
````[x,xn] = wnoise(___,init)` sets the generator seed to `init` before generating additive Gaussian white noise N(0,1).```

## Examples

collapse all

There are six test signals. Generate and plot ${2}^{10}$ samples of the third test signal, `heavy sine`.

```loc = linspace(0,1,2^10); x = wnoise(3,10); plot(loc,x) title('Heavy Sine')```

Generate and plot ${2}^{10}$ samples of the `doppler` test signal and a noisy version of `doppler` with a square root of the signal-to-noise ratio equal to 7.

```[x,noisyx] = wnoise('doppler',10,7); tiledlayout(2,1) nexttile plot(loc,x) title('Clean Doppler') ylim([-15 15]) nexttile plot(loc,noisyx) title('Noisy Doppler') ylim([-15 15])```

Plot all the test functions.

```testFunctions = {'Blocks','Bumps','Heavy Sine', ... 'Doppler','Quadchirp','Mishmash'}; tiledlayout(3,2) for i=1:6 x = wnoise(lower(testFunctions{i}),10); nexttile plot(loc,x) title(testFunctions{i}) end```

## Input Arguments

collapse all

Wavelet test function, specified as one of the values listed here. The six test functions are due to Donoho and Johnstone [1], [2].

• 1 or `'blocks'`

• 2 or `'bumps'`

• 3 or `'heavy sine'`

• 4 or `'doppler'`

• 5 or `'quadchirp'`

• 6 or `'mishmash'`

Exponent used to determine the number of linearly spaced points from 0 to 1 to evaluate the test function, specified as a positive integer. The number of linearly spaced points is 2n.

Square root of SNR, specified by a positive real number. The test values `x` are rescaled such that the standard deviation of `x` is `sqrtsnr`. `xn` is equal to `x` corrupted by additive Gaussian white noise N(0,1) and has an SNR of `sqrtsnr`2.

Seed used to initialize the random number generator, specified as a nonnegative integer. `init` is used to generate additive Gaussian white noise.

Example: `[a,b] = wnoise(4,10,7,2055415866);` returns a noisy version of the fourth test signal using the seed ```init = 2055415866```.

## Output Arguments

collapse all

Test signal, returned as a real-valued vector of length 2`n`. `x` are the values of the test function specified by `fun` evaluated at the 2`n` evenly spaced points from 0 to 1. If `sqrtsnr` is set, the standard deviation of `x` is `sqrtsnr`.

Noisy test signal, returned as a real-valued vector of length 2`n`. `xn` is `x` corrupted by additive Gaussian white noise N(0,1) and has an SNR of `sqrtsnr`2.

## References

[1] Donoho, David L, and Iain M Johnstone. “Ideal Spatial Adaptation by Wavelet Shrinkage.” Biometrika 81, no. 3 (September 1, 1994): 425–55. https://doi.org/10.1093/biomet/81.3.425.

[2] Donoho, David L., and Iain M. Johnstone. “Adapting to Unknown Smoothness via Wavelet Shrinkage.” Journal of the American Statistical Association 90, no. 432 (December 1995): 1200–1224. https://doi.org/10.1080/01621459.1995.10476626.

## Version History

Introduced before R2006a