Schiros78
Schiros78

Reputation: 23

How to calculate the mode of a negative binomial distribution in MatLab

I'm completing a statistics project now, and I have to compare some basic analytical values of different distributions alongside the raw data set. I was able to calculate the mode of the raw data and a Normal Distribution set. The mode function in MatLab only allows doubles as an input while the negative binomial distribution is set as a distribution within the code.

NegBinomMode = mode(NegBinom);

This results in :

Error in processData (line 95)
NegBinomMode = mode(NegBinom);

Process data is just the name of my function, NegBinom is my variable which has been set to the negative binomial fit.

MatLab does give p and r values for the distribution but, when used within given negative binomial equations for mean, median, and mode, no answers seem to match.

Upvotes: 2

Views: 621

Answers (1)

zlon
zlon

Reputation: 834

As I understand your variable is a distribution object. You may think about it as an implementation or representation of god-given distribution. MATLAB functions lime mean,median,std,mode gives you an estimation of corresponding parameters. In case You know the distribution-it is synonymous to have a distribution object-you don't need estimation. You have 2 possibilities: find analytical solution- equation which defines mode via parameters of your distribution object,or simulate sample from you distribution object and calculate estimated parameters.

Upvotes: 0

Related Questions