How can I combine probability distribution objects?

20 views (last 30 days)
Are there operators probability distribution objects? For example,
>>load hospital
>>xA = hospital.Weight;
>>pdA = fitdist(xA,'Normal')
Suppose I have a similar second record
where there are k times as many patients. Then I could write
>>pdboth = fitdist([xA;xB],'Normal');
but if I've only got the pd and weighting - or want to do some other weighting - I'd like to do something like
>>pdboth = pdA + k*pdB;
Does this sort of operator exist, or do I need to convert to a pdf and then fit a new distribution?
  1 Comment
Tom Lane
Tom Lane on 13 Dec 2015
What are you expecting from the addition? Are you looking for a mixture of Gaussians (perhaps a bimodal distribution with one peak from each distribution)?

Sign in to comment.

Answers (1)

Arnab Sen
Arnab Sen on 31 Dec 2015
I understand that you would like to achieve pooled weighted distribution of two distributions. There is no in-built functions in MATLAB to achieve this goal. However, it is possible to calculate it manually.
Consider following MATLAB code snippet for illustration:
%Calculate mean and standard deviation programmatically
In simple words we are calculating 'pdboth' as the distribution of xC=[xA;xB;xB;...ktimes]. You can also simply create a vector 'xC' as above and compute 'pdboth'.
For more details of the calculation as shown in the code, refer to the following link:

Community Treasure Hunt

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

Start Hunting!