negloglik

Negative loglikelihood of probability distribution

Syntax

``nll = negloglik(pd)``

Description

example

````nll = negloglik(pd)` returns the value of the negative loglikelihood function for the data used to fit the probability distribution `pd`.```

Examples

collapse all

`load carsmall`

Create a Weibull distribution object by fitting it to the mile per gallon (`MPG`) data.

`pd = fitdist(MPG,'Weibull')`
```pd = WeibullDistribution Weibull distribution A = 26.5079 [24.8333, 28.2954] B = 3.27193 [2.79441, 3.83104] ```

Compute the negative log likelihood for the fitted Weibull distribution.

`wnll = negloglik(pd)`
```wnll = 327.4942 ```

Load the sample data. Fit a kernel distribution to the miles per gallon (`MPG`) data.

```load carsmall; pd = fitdist(MPG,'Kernel')```
```pd = KernelDistribution Kernel = normal Bandwidth = 4.11428 Support = unbounded ```

Compute the negative loglikelihood.

`nll = negloglik(pd)`
```nll = 327.3139 ```

collapse all

Output Arguments

collapse all

Negative loglikelihood value for the data used to fit the distribution, returned as a numeric value.

Extended Capabilities

Introduced in R2013a