how do I generate 100000 bits of ones and zeros with norm distribution mean=5 and standard deviation of 3? I have tried thismu = 5; sigm= 3; x2 = -20:0.1:20; y2 = normrnd(10

1 view (last 30 days)
I'm trying to generate 100000 bits for ones and 100000 bit for zeros . basically 5 should represent by 1 and -5 by a zero. This is what i have tried
sigma=3, mean=5
x=-20:0.1:20;
y=normpdf(100000, mu sigma)
plot(x,y)
I have tried the zero(100000,-20,20)
the plot plot are looks likethe normal distribution
The y axis range from 0 to 4000 in increments of 500
  2 Comments
gerald bamundaga
gerald bamundaga on 20 Apr 2022
I need to compute the bit error rate of a channel where zero has a mean -5 and sigma of 3 and one has mean of 5 and sigma of 3. the probability of one is 50%. compute the bit error rate using simulation of10000 ones and 10000 zeros. plot the pdf. Do it analytically using normcdf,erf or erfc.

Sign in to comment.

Answers (1)

Abhishek Chakram
Abhishek Chakram on 16 Nov 2023
Hi gerald,
It appears to me that you are trying to generate 100000 bits of ones and zeros with a norm distribution mean of 5 and standard deviation of 3. Here is an example code for achieving the same:
% Parameters
num_ones = 100000; % Number of ones
num_zeros = 100000; % Number of zeros
mean_one = 5; % Mean for one
mean_zero = -5; % Mean for zero
sigma = 3; % Standard deviation for both zero and one
% Generate random bits for ones and zeros
ones = (rand(1, num_ones) < 0.5) * (mean_one - mean_zero) + mean_zero;
zeros = (rand(1, num_zeros) < 0.5) * (mean_one - mean_zero) + mean_zero;
% Plot the PDF
x = -20:0.1:20; % Range of x values for PDF
pdf_one = normpdf(x, mean_one, sigma);
pdf_zero = normpdf(x, mean_zero, sigma);
figure;
hold on;
plot(x, pdf_one, 'r', 'LineWidth', 2);
plot(x, pdf_zero, 'b', 'LineWidth', 2);
xlabel('Symbol Value');
ylabel('Probability Density');
title('PDF of Zero and One Symbols');
legend('One', 'Zero');
grid on;
Best Regards,
Abhishek Chakram

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!