How do I write pdf of random variable?
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi. I want to generate a set of 1000 uniform random numbers in the interval [0, l] using the MATLAB function rand(l, N). Plot the histogram and the probability distribution function for the sequence and the histogram may be determined by quantizing the interval in ten equal-width subintervals covering the range [0, l] and counting the numbers in each subinterval.
so,
N=1000;
A = rand(1,N);
histogram(A)
B=pdf(A,??);
I created a random variable. I created a histogram. But I don't know how to write probability density function. Can it be written manually? What should I do. I will be glad if you help me.
0 Commenti
Risposte (1)
DGM
il 10 Nov 2021
The PDF for uniform random numbers is just a simple piecewise-constant function.
Consider uniform random numbers with a lower bound of A and an upper bound of B; the central non-zero portion of the PDF has a value of 1/(B-A).
A = 2; % lower bound
B = 12; % upper bound
x = linspace(0,16,1000); % interval to evaluate PDF
p = ((x>=A) & (x<=B))/(B-A); % PDF
plot(x,p)
2 Commenti
DGM
il 10 Nov 2021
Modificato: DGM
il 10 Nov 2021
Since this is some sort of assignment, it all depends what you're assuming you know about the random "data". I assumed that we already knew A and B. In that case, the output of rand() is unnecessary except to do the histogram part of the task. In your case, A is 0 and B is 1.
If you assume that you don't know A and B, then you can approximate them by finding the min() and max() of the random data. Of course at that point, you're still assuming that you know that the distribution is uniform.
Vedere anche
Categorie
Scopri di più su Histograms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!