Effacer les filtres
Effacer les filtres

How do I create a distribution from an equation?

3 vues (au cours des 30 derniers jours)
Tom
Tom le 24 Jan 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 commentaire
Matt Fig
Matt Fig le 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?

Connectez-vous pour commenter.

Réponses (3)

Walter Roberson
Walter Roberson le 24 Jan 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 le 24 Jan 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 commentaires
Tom
Tom le 24 Jan 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 le 24 Jan 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.

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 24 Jan 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.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by