This file is indexed.

/usr/share/octave/packages/statistics-1.3.0/gamfit.m is in octave-statistics 1.3.0-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Author: Martijn van Oosterhout <kleptog@svana.org>
## This program is granted to the public domain.

## -*- texinfo -*-
## @deftypefn {Function File} {@var{MLE} =} gamfit (@var{data})
## Calculate gamma distribution parameters.
##
## Find the maximum likelihood estimators (@var{mle}s) of the Gamma distribution
## of @var{data}.  @var{MLE} is a two element vector with shape parameter
## @var{A} and scale @var{B}.
##
## @seealso{gampdf, gaminv, gamrnd, gamlike}
## @end deftypefn

## This function works by minimizing the value of gamlike for the vector R.
## Just about any minimization function will work, all it has to do a
## minimize for one variable. Although the gamma distribution has two
## parameters, their product is the mean of the data. so a helper function
## for the search takes one parameter, calculates the other and then returns
## the value of gamlike.

## FIXME is this still true???
## Note: Octave uses the inverse scale parameter, which is the opposite of
## Matlab. To work for Matlab, value of b needs to be inverted in a few
## places (marked with **)

function res = gamfit(R)

  if (nargin != 1)
    print_usage;
  endif

  avg = mean(R);

  # This can be just about any search function. I choose this because it
  # seemed to be the only one that might work in this situaition...
  a=nmsmax( @gamfit_search, 1, [], [], avg, R );

  b=a/avg;      # **

  res=[a 1/b];
endfunction

# Helper function so we only have to minimize for one variable. Also to
# inverting the output of gamlike, incase the optimisation function wants to
# maximize rather than minimize.
function res = gamfit_search( a, avg, R )
  b=a/avg;      # **
  res = -gamlike([a 1/b], R);
endfunction