No BSD License  

Highlights from
DistributionFit

4.0

4.0 | 6 ratings Rate this file 10 Downloads (last 30 days) File Size: 8.66 KB File ID: #7801
image thumbnail

DistributionFit

by J. David Cogdell

 

06 Jun 2005 (Updated 08 Jun 2005)

Fits normal, lognormal, and weibull distributions to data.

| Watch this File

File Information
Description

function [pdffit,offset,A,B,resnorm,h] = distributionfit(data,distribution,nbins)

PURPOSE jdc rev. 06-jun-05
Fit one of three probability distributions (normal, lognormal, weibull) to input data vector. If the distribution is specified as 'best' the distribution 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))

%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 or weibull fits (to satisfy the positive-definite requirements for these distributions).

Note: this is roughly 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
h - handles to the bar chart and probability density curve

TYPICAL FUNCTION CALLS
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');
distributionfit(lognrnd(1.5,.5,10000,1),'lognormal');

REFERENCE
Statistics Toolbox Version 3.0.2, function HISTFIT.M

Required Products Statistics Toolbox
MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements -
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
18 Sep 2005 mirza kamaludeen  
19 Sep 2005 C P

Exactly what I needed!!!

05 Jun 2006 Alex Skvortsov

very good & usefull, example where you can lean a lot,

28 Apr 2007 Michael Draugelis  
26 Nov 2007 Dan Dwyer

I didn't have the stats pak, but I was able to get plots of my data - which was all I actually needed.

10 Dec 2007 Imen Ayachi

No comment

06 Oct 2009 Erdal Bizkevelci  
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 07:50:08
probability J. David Cogdell 22 Oct 2008 07:50:08
distribution J. David Cogdell 22 Oct 2008 07:50:08
fits J. David Cogdell 22 Oct 2008 07:50:08
function J. David Cogdell 22 Oct 2008 07:50:08

Contact us at files@mathworks.com