Can I create an array of probability distribution objects?
11 views (last 30 days)
Show older comments
I have n observations of a parameter, each with a mean and standard deviation, for which the maximum is 4000, minimum is 1400, and typical standard devs are of order 20 (the data are ages of geological events in millions of years). I want to model each as a normal deviate, for which I could use the probability distribution object. But, I want to take all n distributions and sum them in bins of size b (million years) to give a "meta-" distribution. I could use a loop and step through each of the n observations, summing as I go. But is there a vectorized version of the process? It doesn't seem that pdos allow easy vectorization.
Thanks in advance.
2 Comments
dpb
on 29 May 2018
Well, haven't tried much but doc says you can fit multiple distributions of the same family to the sample data with grouping variables.
Do you have a priori estimates for the parameters or are you also estimating those; wasn't sure what n above referred to, precisely?
Answers (1)
dpb
on 30 May 2018
I've got a lot else going on but caught just a few minutes last night -- haven't ever used the newer distribution objects much so had to do a little digging. The idea of grouping variables seemed reasonable approach excepting only implemented with fitdist which doesn't accept distribution parameters, only sample observations from which to estimate population statistics. But, you can make makedist create an array of objects with a little work--
>> pd = arrayfun(@(m,s) makedist('Normal','mu',m,'sigma',s),bif_data(:,1),bif_data(:,2));
>> pd
pd =
3x1 NormalDistribution array
>>
Let's see if we got what we think we want...
>> arrayfun(@disp,pd)
Normal distribution
mu = 3800
sigma = 20
Normal distribution
mu = 3600
sigma = 10
Normal distribution
mu = 3000
sigma = 40
>>
So, in fact, you could generate an array of the N distributions this way. I'm guessing following the lead of using arrayfun above to process would let you remove the explicit looping constructs; whether it would be any faster in the end I don't know but perhaps slightly less coding.
I haven't had time to play extensively, I note that each distribution will be some standardized z points; perhaps there's a way to make use of that to simplify further, not sure whether it would reduce the total computations or just swap one representation for another at this point.
Hopefully that will get you started; I've got another engagement again at the moment; will try to look in later on...
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!