From: Argon on 10 Aug 2010 14:13 Dear All, I have some data vectors x and y, and using these data I need to fit the distribution y=N(0,a+b*x), where N is the normal distribution (i.e. zero mean, standard deviation linearly dependent on x). Anyone has any idea on how to do it in Matlab (how to find the values of a and b and possibly their distributions as well)? Help is appreciated.
From: Rogelio on 10 Aug 2010 14:26 "Argon " <kineros(a)yahoo.it> wrote in message <i3s4rg$3sa$1(a)fred.mathworks.com>... > Dear All, > > I have some data vectors x and y, and using these data I need to fit the distribution y=N(0,a+b*x), where N is the normal distribution (i.e. zero mean, standard deviation linearly dependent on x). > Anyone has any idea on how to do it in Matlab (how to find the values of a and b and possibly their distributions as well)? > > Help is appreciated. you can do maximum likelihood estimation. program the loglikelihood of the normal distribtion and specify the variance of it as a in your case, i.e. a function of x. Then a and b are your parameters to be found. You would like to use fminunc to minimize the minus loglikelihood, which is equivalent to maximize the log likelihood. a and b are coefficients so they are non stochastic.
From: Peter Perkins on 10 Aug 2010 16:41 On 8/10/2010 2:13 PM, Argon wrote: > Dear All, > > I have some data vectors x and y, and using these data I need to fit the > distribution y=N(0,a+b*x), where N is the normal distribution (i.e. zero > mean, standard deviation linearly dependent on x). > Anyone has any idea on how to do it in Matlab (how to find the values of > a and b and possibly their distributions as well)? If you have access to the Statistics Toolbox, you can use MLE. That function is usually used to fit a univariate distribution with no covariates, but this is one of the cases where you can trick it into fitting a distribution with covariates, by using an anonymous function. a = 1.23; b = 2.34; x = rand(1000,1); y = normrnd(0,a+b*x,size(x)); mypdf = @(y,a,b) normpdf(y,0,a+b*x); [paramEsts,paramCIs] = ... mle(y,'pdf',mypdf,'start',[1 1],'lowerbound',[0 0]) Hope this helps.
From: Argon on 10 Aug 2010 17:04 Peter Perkins <Peter.Perkins(a)MathRemoveThisWorks.com> wrote in message <i3sdhf$mqc$1(a)fred.mathworks.com>... > On 8/10/2010 2:13 PM, Argon wrote: > > Dear All, > > > > I have some data vectors x and y, and using these data I need to fit the > > distribution y=N(0,a+b*x), where N is the normal distribution (i.e. zero > > mean, standard deviation linearly dependent on x). > > Anyone has any idea on how to do it in Matlab (how to find the values of > > a and b and possibly their distributions as well)? > > If you have access to the Statistics Toolbox, you can use MLE. That > function is usually used to fit a univariate distribution with no > covariates, but this is one of the cases where you can trick it into > fitting a distribution with covariates, by using an anonymous function. > > a = 1.23; > b = 2.34; > x = rand(1000,1); > y = normrnd(0,a+b*x,size(x)); > > mypdf = @(y,a,b) normpdf(y,0,a+b*x); > [paramEsts,paramCIs] = ... > mle(y,'pdf',mypdf,'start',[1 1],'lowerbound',[0 0]) > > Hope this helps. Immense thanks.
|
Pages: 1 Prev: Preventing textscan from choking on irrelevant input Next: Cell2mat issues |