Can I create an array of probability distribution objects?

11 ビュー (過去 30 日間)
Larry
Larry 2018 年 5 月 29 日
回答済み: dpb 2018 年 5 月 30 日
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 件のコメント
dpb
dpb 2018 年 5 月 29 日
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?
Larry
Larry 2018 年 5 月 29 日
Thanks for your reply. Each of the 55 observations is the radiometrically determined age of a 55 different examples of a class of rock; the standard deviation is a measure of the "best-guess" 95% CI for the age, including both systematic and random errors of the age. Both I accept as accurate. Perhaps the code I wrote would help; I give it below, with a small subset of the data to indicate array structure and to demonstrate the "age spectrum" I want to create.
bif_data=[3800, 20;3600, 10; 3000, 40];
age_max=4000; %/millions of years
age_min=0; %/millions of years
bin_width=20; %/millions of years
age_array=age_min:bin_width:age_max;%provides "edges" of bins
prob_array=zeros(1,length(age_array)-1);
num_data=length(bif_data);
for indx=1:num_data
pd = makedist('Normal','mu',bif_data(indx,1),'sigma',bif_data(indx,2));
temp= diff(cdf(pd,age_array));
prob_array=prob_array+temp;
end
prob_array=prob_array/sum(prob_array);
figure
stairs(age_array(2:end), prob_array)
title( bin_width)

サインインしてコメントする。

回答 (1 件)

dpb
dpb 2018 年 5 月 30 日
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...

製品

Community Treasure Hunt

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

Start Hunting!

Translated by