Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!o6g2000vbz.googlegroups.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Numerical Integration of Frechet: Precision problem
Date: Wed, 22 Feb 2012 23:35:13 -0800 (PST)
Organization: http://groups.google.com
Lines: 45
Message-ID: <2cb6e221-6635-494a-baa1-11d271aeffdb@o6g2000vbz.googlegroups.com>
References: <ji30kb$lri$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 192.102.151.35
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1329982513 4539 127.0.0.1 (23 Feb 2012 07:35:13 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 23 Feb 2012 07:35:13 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: o6g2000vbz.googlegroups.com; posting-host=192.102.151.35; posting-account=X3eThQoAAACh5vOSip_rNRzKAq7k0jPW
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ARLUEHNKC
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
 Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR
 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:758665

On 22 Feb., 16:12, "steingre " <wal...@steingress.com> wrote:
> Hi,
>
> I try to numerical integrate a Frechet distribution and have the following problem of precision. In particular when choosing a very low show parameter close to 1. If I chose k>2 then the precision problem disappears.
>
> I appreciate any help!
>
> Here is an example of calculating the mean:
>
> % Define number of points;
> Num=10000;
> for i=1:Num
>       y(i,1) = (i)*1000/Num;
> end
>
> % Shape parameter of the revenue distribution
> k=1.19;
>
> % Scale parameter
> s=1/10;
>
> % Random variable
> x=y;
>
> % PDF of Frechet
> pdf=s.*k.*(x.*s).^(-(1+k)).*exp(-(x.*s).^(-(k)));
> trapz(x,pdf)
>
> % Empircial mean of Frechet
> z=x.*pdf;
> trapz(x,z)
>
> % Actual mean of Frechet
> mean=1./s.*gamma(1-1./k)

If - as in your case - the function you want to integrate is
explicitely known,
don't use trapz, but MATLAB's quadgk. It distributes the x-mesh
adaptively
such that the error of integration is below a specified tolerance.

Best wishes
Torsten.