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 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Abhishek Chakram
2023-11-16
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!