Azzera filtri
Azzera filtri

How do I create a distribution from an equation?

3 visualizzazioni (ultimi 30 giorni)
Tom
Tom il 24 Gen 2012
I have this code
t = linspace(0,0.01,1000);
f = 220;
x = 4-cos(2*pi*f.*t);
and I need to create a distribution to then use to get the pdf and cdf.
There are so many different types of distribution and I don't know which one to use. Can anyone help?
  1 Commento
Matt Fig
Matt Fig il 2 Nov 2012
I have this code
t = linspace(0,0.01,1000); f = 220; x = 4-cos(2*pi*f.*t);
and I need to create a distribution to then use to get the pdf and cdf.
There are so many different types of distribution and I don't know which one to use. Can anyone help?

Accedi per commentare.

Risposte (3)

Walter Roberson
Walter Roberson il 24 Gen 2012
A distribution in which sense? plot(t,x) makes it clear that the x values are not randomly distributed. pdf / cdf are probability terms, but nothing in your output is random: given the t one can calculate the exact value of x.

Walter Roberson
Walter Roberson il 24 Gen 2012
That is not a valid pdf: the integral of p over -2 to +2 works out as 1-(2*I)*ln(2+3^(1/2))/Pi, which is about 1 - 0.8384014364i and can also be written 2*arcsin(2)/Pi
The integral of a pdf over the entire range must be 1, which is another way of saying that the cdf must be 0 at the left boundary and 1 at the right boundary.
  2 Commenti
Tom
Tom il 24 Gen 2012
Thanks - I'm just not sure which one is not a valid pdf - is it the top or bottom code?
Walter Roberson
Walter Roberson il 24 Gen 2012
Your top one, which defines p=1./(pi*sqrt(A^2-x.^2)), since you indicated that was what you calculated mathematically.
Your top one has no obvious relationship to 220 Hz, by the way. And no obvious relationship to the 4-cos(2*pi*f.*t) of your bottom code.
Your top one increases towards -2 and +2, which is usually not a good sign as PDFs go. It isn't impossible, but it is relatively uncommon, as it _hints_ that the function would continue on indefinitely to the sides if it were allowed to, whereas ideally the user would like to be sure that the function vanishes to either side.

Accedi per commentare.


Walter Roberson
Walter Roberson il 24 Gen 2012
How about this:
Suppose you have a real-valued function y = f(x) over then interval [A, B]. If f(x) is continuous, then there is a (possibly infinite) minimum, ymin, on f(x) over [A,B], and a (possibly infinite) maximum, ymax, over [A,B].
Now consider a random variable X over the interval [A,B] (e.g. uniform random if [A,B] is bounded, and normal distribution only if [A,B] is [-inf,inf]). Even though for any given x in [A,B], f(x) has a fixed value, it is fair to ask, "If I select randomly from the interval [A,B], what distribution of values f(x) will I get?". The random sampling f(X) over [A,B] leads to the question of what the CDF is for P(ymin <= f(X)) -- of course 0 for f(X) being ymin and being 1 for f(X) being ymax.
The CDF is going to depend upon the choice of random distributions used to select over [A,B].
I would need to think more about the mathematics of calculating the PDF.
Note: your function p=1./(pi*sqrt(A^2-x.^2)) is not solely real-valued over [-2,2]. There are probably analogs in the complex plane, but I am not qualified to deal with the complex mathematics.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by