Weighted probability density function plot?

4 visualizaciones (últimos 30 días)
Hanna
Hanna el 2 de Mayo de 2012
Hey! Im new to matlab, so sorry in advance if my question is rudimentary.
I have a large dataset with columns "CO2 emission per kg" and "number of kg produced at location"
I want a pdf plot of the emissions per kg, but I would like it to be weighted, so that the emissions at locations with a high production will be weighted more heavily.
Is there any easy way to do this? It seems that neither pdf or cdf plots allow weighting?
Cheers

Respuestas (3)

Tom Lane
Tom Lane el 2 de Mayo de 2012
If you are content with a kernel smooth density estimate of the pdf, the "ksdensity" function accepts a 'weights' argument.

Hanna
Hanna el 2 de Mayo de 2012
I would like to fit the results to a lognormal distribution. Is it possible to do this if i use the "ksdensity" function?
The only way i can think of to get it the way i initially wanted is to make a matrix that repeats the "CO2 emissions" value for as many times as the weights "number of kg" indicate, and THEN use pdf plot. That seems like a hassle, and im not sure how i would go about to do it..
Thanks for helping out :)

Tom Lane
Tom Lane el 2 de Mayo de 2012
Check out the "lognfit" function with its FREQ argument. Also the "mle" function with its 'frequency' argument. These can estimate the parameters of the distribution based on weighted data. You can supply those parameters to the "pdf" function.

Community Treasure Hunt

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

Start Hunting!

Translated by