Could you please help me with this assignment The purpose of

Could you please help me with this assignment?

The purpose of this assignment is to simulate the transmission and reception of a text message
(i.e., character string) over a noisy communications channel. Suppose we wish to transmit the
string “Hello.” We can translate this string into a bit stream as shown below:
String: H e l l o . \\0 (note: the last character \\0 is the null terminator character)
ASCII: 72 101 108 108 111 46 0
Binary: 01001000 01100101 01101100 01101100 01101111 00101110
00000000
Notice how this string can be expressed as 8 x 7 = 56 bits. Suppose we transmit each of these
bits as voltages on an electrical signal (for simplicity, +1.0 V for binary 1 and 0.0 V for binary 0).
We can simulate noise by encoding these bits in a double array of length 56 and then adding
noise samples to the 1.0 and 0.0 values that will initially be loaded into the array. With a small
amount of noise (low SNR), the values in this array for the first character “H” may be:
0.0143, 0.9985, -0.00124, 0.1076, 1.00325, 0.00173, 0.0563, 0.00474
With low noise, it is clear that the voltages “near” 0 represent binary 0 and the voltages “near” 1
represent binary 1. As a general rule, a receiver will take any voltages less than 0.5 and treat
them as binary 0 and any voltages greater than or equal to 0.5 and treat them as binary 1.

Problem 2 Write a function double add noise (double signal double SNR, int size) that accepts a signal of binary voltages (as a double array), a signal-to-noise ratio, and the size of the input array. The output should be a new array containing noisy signal samples Recall that the average power (per sample) of a discrete signal (array in this case) xInl is given as: N-1 signal N Also, recall that signal-to-noise ratio is defined as: signal SNR 510 G2 here o (sigma) is the noise standard deviation (per sample)

Solution

#include<stdio.h>
#include<math.h>
#include<stdlib.h>

double guassian_noise(double mu, double sigma)
{
static double U, V;
static int sample = 0;
double X; // this will be the outputted random guassian number

if(sample == 0)
{
U = ((double) rand())/RAND_MAX;
V = ((double) rand())/RAND_MAX;
X = sqrt(-2*log(U))*cos(2*M_PI*V);
}
else
{
X = sqrt(-2*log(U))*sin(2*M_PI*V);
}

sample = (sample+1)%2;
return sigma*X + mu;
}

double compute_sigma(double *signal, double snr, int size)
{
double p = 0;

int i;

for(i = 0; i < size; i++)
{
p += signal[i]*signal[i];
}

p = p/size;

snr = snr*(0.1);
double sigma = sqrt((p/pow(10, snr)));
return sigma;
}

double* add_noise(double *signal, double snr, int size)
{
int i = 0;
double sigma = compute_sigma(signal, snr, size);
for(i = 0; i < size; i++)
{
double noise = guassian_noise(0, sigma);
signal[i] += noise;
}
return signal;
}

int main()
{
double signal[] = {1,1,1,1,1,1,1,1,1,0};
add_noise(signal, 2, 10);

int i = 0;

for(i = 0; i < 10; i++)
{
printf(\"%f\ \", signal[i]);
}

return 0;
}

/*

In driver program please set appropriate value of snr and array

*/

Could you please help me with this assignment? The purpose of this assignment is to simulate the transmission and reception of a text message (i.e., character s
Could you please help me with this assignment? The purpose of this assignment is to simulate the transmission and reception of a text message (i.e., character s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site