# Generating White Noise with Specific Variance in MATLAB

Jan 23, 2024

In the field of signal processing and data analysis, white noise plays an important role as a tool to simulate random events, study system response to noise, and even improve systems by adding randomness. One of the key aspects of white noise is its variance, which represents the power of the noise. This article will guide you through the process of generating white noise with a specific variance in MATLAB, a powerful software for mathematical computing.

White noise is a random signal that has equal intensity at different frequencies within a specified bandwidth. It is characterized by two main properties: its mean (usually zero) and its variance (which indicates the signal's power). To generate a white noise signal with specific variance in MATLAB, follow these simple steps:

- Define the desired variance: The first step is to define the desired variance of the generated white noise signal. This value can be any positive number. For example, if you want a noise signal with a variance of 5, declare it like this:

```
desired_variance = 5;
```

- Generate random noise: Next, generate a random noise signal with Gaussian distribution, where the mean is zero and standard deviation is 1. The 'randn' function in MATLAB generates normally distributed random numbers. To create a vector with 'N' random values, use:

```
N = 1000; % Number of samples
random_noise = randn(1, N);
```

- Scale the noise to the desired variance: To adjust the generated noise to your desired variance, multiply it by the square root of the desired variance:

```
scaled_noise = sqrt(desired_variance) * random_noise;
```

By doing this, you have effectively generated white noise with a specific variance. You can plot the signal or use the 'var' function to check the variance of the generated noise:

```
noise_variance = var(scaled_noise);
disp(noise_variance); % Should display a value close to the desired_variance
```

In summary, generating white noise with specific variance in MATLAB is a simple three-step process. First, define the desired variance, then generate random noise with Gaussian distribution, and finally, scale the noise to the desired variance. This method is useful for simulating and analyzing system performance under noisy conditions and for testing various algorithms and filters.