No BSD License  

Highlights from
DistributionFit

2.0

2.0 | 1 rating Rate this file 14 Downloads (last 30 days) File Size: 11.08 KB File ID: #10501
image thumbnail

DistributionFit

by J. David Cogdell

 

23 Mar 2006 (Updated 23 Mar 2006)

Fits normal, lognormal, and weibull distributions to data

| Watch this File

File Information
Description

%function [pdffit,offset,A,B,resnorm,mode,medpdf,ndata,h] = distributionfit(data,distribution,nbins,figureWH)
%PURPOSE jdc rev. 23-Mar-06
% Fit one of three probability distributions (normal, lognormal, weibull)
% to input data vector. If the distribution is specified as 'best' the dis-
% tribution that best fits the data is selected automatically.
%INPUT
% If nargin==1, "distribution" is prompted for and entered interactively
%
% data - n x 1 or 1 x n input data vector
% distribution - probability distribution to fit to "data". Can
% be 'normal', 'lognormal', 'weibull', or 'best' ... default: 'best'
% nbins - number of bar-chart bins ................................... default: sqrt(length(data))
% figureWH - figure size [width height] (inches) ????... default: [4 3]
%OUTPUT
% pdffit - fitted probability density function - n x 2 matrix with column 1 the
% x-values, column 2 the y values
% offset - amount by which the data was offset for lognormal and weibull fits
% (to satisfy the positive-definite requirements for these distributions).
% Note: this is approximately equivalent to fitting a 3- rather than a 2-parameter
% distribution.
% A,B - distribution parameters - mu and sigma for normal and lognormal distributions,
% scale and shape parameters for weibull distribution
% resnorm - measure of goodness of fit: sum of squares of point-by-point differences
% between experimental and best-fit cumulative distribution function
% mode - 2-element vector: [distribution mode density at mode]
% medpdf - 2-element vector: [data median pdf density at median]
% h - handles to the bar chart and probability density curve
%
%TYPICAL FUNCTION CALLS (using random number vectors for input data)
% distributionfit(randn(10000,1));
% distributionfit(wblrnd(2,3,10000,1));
% distributionfit(wblrnd(2,3,10000,1),'weibull');
% distributionfit(lognrnd(1.5,.5,10000,1),'lognormal');
% distributionfit(lognrnd(1.5,.5,10000,1),'best');
%REFERENCE
% Statistics Toolbox Version 3.0.2, function HISTFIT.M
%REVISIONS
% 09jun05 Revised pdf plot to reflect input rather than zero-shifted data
% " Fixed some problems with lognormal distribution related to
% logarithms and exponents of very small numbers
% 10jun05 Added mode and median to arguments out
% 23mar06 Set xlim(2) to max(data)
% " Decreased text fontsize & fixed text placement problem

Required Products Statistics Toolbox
MATLAB release MATLAB 7.1.0 (R14SP3)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
05 Oct 2008 Ying Lin

??? Error using ==> extent at 9
EXTENT function is obsolete. Get the 'Extent' property of the text object instead.

Error in ==> DistributionFit2 at 181
ext = extent(trd);

20 Sep 2009 november

Hello,

I am trying to use distribution fit but i have the following:

Error in ==> distributionfit at 106
   offset = -min(data)+0.001*range(data);

Please help.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics J. David Cogdell 22 Oct 2008 08:19:52
probability J. David Cogdell 22 Oct 2008 08:19:52
probability distribution normal lognormal weibull J. David Cogdell 22 Oct 2008 08:19:52
statistics Florian 13 May 2011 10:43:12
probability Florian 13 May 2011 10:43:14

Contact us at files@mathworks.com