Uniformly distributed random variables

3 ビュー (過去 30 日間)
Anand Kumar
Anand Kumar 2021 年 4 月 5 日
コメント済み: Anand Kumar 2021 年 4 月 5 日
Iam stuck in a part of the following question-
Plot the distribution of two resistors in a parallel connection assuming that they each have measured values, which vary uniformly about their nominal values by ±5%
I have approached this problem in the following way -
x = zeros(10000,1) ;
R1 = rand(1,1) ;
R2 = rand(1,1) ;
for i = 1:10000
x(i,1) = (R1*R2)/(R1+R2) ;
RIght now I dont have the idea about how to adjust the nominal values in the rand function . Please help :)
  1 件のコメント
the cyclist
the cyclist 2021 年 4 月 5 日
I edited your code using the CODE button in the toolbar, and run it, show in your plot.



Chad Greene
Chad Greene 2021 年 4 月 5 日
Ah, this is a fun question, because the concept it's getting at is quite common across science and engineering.
The process of manufacturing resistors isn't perfect, so a 100 Ohm resistor might actually have a value anywhere between 95 and 105 Ohms. To make a uniform distribution of values between 95 and 105 Ohms, you could use the rand function, which creates values between 0 and 1. This means you'll want to multiply rand by 2 times the full spread, and center it so half the values are less than zero and half the values are greater than zero.
percent_error = 5;
NominalResistance = 100;
ErrorDistribution = 2*(percent_error/100)*NominalResistance*(rand(1000,1)-0.5);
R = NominalResistance + ErrorDistribution;
  2 件のコメント
Anand Kumar
Anand Kumar 2021 年 4 月 5 日
Thanks Chad for the explanation.


その他の回答 (2 件)

David Hill
David Hill 2021 年 4 月 5 日
  2 件のコメント
Anand Kumar
Anand Kumar 2021 年 4 月 5 日
Thank you David. @the cyclist Thanks for your advice , I won't copy.


the cyclist
the cyclist 2021 年 4 月 5 日
The main reason your output looks like this is that you are only generating ONE random value for each resistor -- and then recalculating x over and over again, with those values.
So, you need to change your code so that you generate a new random value for each value of x. (Check out the documentation on rand to see how to generate many values at once.)
You can generate a uniform random value with mean m and width w by doing
m = 37;
w = 2;
R1 = m + w*(rand(1,1) - 0.5)
R1 = 37.8963
  1 件のコメント
Anand Kumar
Anand Kumar 2021 年 4 月 5 日
Yes I got the point . Thank you for the explanation :)


Community Treasure Hunt

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

Start Hunting!

Translated by