MATLAB Answers


How can I combine probability distribution objects?

Asked by Jo Williams on 3 Dec 2015
Latest activity Answered by Arnab Sen
on 31 Dec 2015
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

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.

1 Answer

Answer by 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:


Sign in to comment.