This file is indexed.

/usr/share/octave/packages/statistics-1.3.0/tabulate.m is in octave-statistics 1.3.0-1.

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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
## Copyright (C) 2003 Alberto Terruzzi <t-albert@libero.it>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {@var{table} =} tabulate (@var{data}, @var{edges})
##
## Compute a frequency table.
##
## For vector data, the function counts the number of
## values in data that fall between the elements in the edges vector
## (which must contain monotonically non-decreasing values). @var{table} is a
## matrix.
## The first column of @var{table} is the number of bin, the second
## is the number of instances in each class (absolute frequency). The
## third column contains the percentage of each value (relative
## frequency) and the fourth column contains the cumulative frequency.
##
## If @var{edges} is missed the width of each class is unitary, if @var{edges}
## is a scalar then represent the number of classes, or you can define the
## width of each bin.
## @var{table}(@var{k}, 2) will count the value @var{data} (@var{i}) if 
## @var{edges} (@var{k}) <= @var{data} (@var{i}) < @var{edges} (@var{k}+1).
## The  last bin will count the value of @var{data} (@var{i}) if
## @var{edges}(@var{k}) <= @var{data} (@var{i}) <=  @var{edges} (@var{k}+1).  
## Values outside the values in @var{edges} are not counted.  Use -inf and inf
## in @var{edges} to include all values. 
## Tabulate with no output arguments returns a formatted table in the
## command window. 
##
## Example
##
## @example
## sphere_radius = [1:0.05:2.5];
## tabulate (sphere_radius)
## @end example
##
## Tabulate returns 2 bins, the first contains the sphere with radius
## between 1 and 2 mm excluded, and the second one contains the sphere with
## radius between 2 and 3 mm.
##
## @example
## tabulate (sphere_radius, 10)
## @end example
##
## Tabulate returns ten bins.
##
## @example
## tabulate (sphere_radius, [1, 1.5, 2, 2.5])
## @end example
##
## Tabulate returns three bins, the first contains the sphere with radius
## between 1 and 1.5 mm excluded, the second one contains the sphere with
## radius between 1.5 and 2 mm excluded, and the third contains the sphere with
## radius between 2 and 2.5 mm. 
##
## @example
## bar (table (:, 1), table (:, 2))
## @end example
##
## draw histogram.
##
## @seealso{bar, pareto}
## @end deftypefn

## Author: Alberto Terruzzi <t-albert@libero.it>
## Version: 1.0
## Created: 13 February 2003

function table = tabulate (varargin)

  if nargin < 1 || nargin > 2
    print_usage;
  endif

  data = varargin{1};
  if isvector (data) != 1
    error ("data must be a vector.");
  endif
  n = length(data);
  m = min(data);
  M = max(data);

  if nargin == 1 edges = 1:1:max(data)+1;
  else edges = varargin{2};
  end 

  if isscalar(edges)
    h=(M-m)/edges;
    edges = [m:h:M];
  end

  # number of classes
  bins=length(edges)-1;
  # initialize freqency table
  freqtable = zeros(bins,4);

  for k=1:1:bins;
    if k != bins
      freqtable(k,2)=length(find (data >= edges(k) & data < edges(k+1)));
    else
      freqtable(k,2)=length(find (data >= edges(k) & data <= edges(k+1)));
    end
    if k == 1 freqtable (k,4) = freqtable(k,2);
    else freqtable(k,4) = freqtable(k-1,4) + freqtable(k,2); 
    end
  end

  freqtable(:,1) = edges(1:end-1)(:);
  freqtable(:,3) = 100*freqtable(:,2)/n;

  if nargout == 0
    disp("     bin     Fa       Fr%        Fc");
    printf("%8g  %5d    %6.2f%%    %5d\n",freqtable');
  else table = freqtable;
  end

endfunction