This file is indexed.

/usr/include/odindata/statistics.h is in libodin-dev 1.8.8-2ubuntu1.

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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/***************************************************************************
                          statistics.h  -  description
                             -------------------
    begin                : Fri Apr 6 2001
    copyright            : (C) 2000-2014 by Thies Jochimsen
    email                : thies@jochimsen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef STATISTICS_H
#define STATISTICS_H

#include<odindata/data.h>
#include<odindata/utils.h>


/**
  * @addtogroup odindata
  * @{
  */

///////////////////////////////////////////////////////////

/**
  * Results of a statistical analysis
  *
  */
struct statisticResult {

/**
  * The minimum value
  */
  double min;

/**
  * The minimum value
  */
  double max;

/**
  * The mean value
  */
  double mean;

/**
  * The standard deviation
  */
  double stdev;

/**
  * The standard deviation of the mean value
  */
  double meandev;

/**
  *  Prints statistics to ostream
  */
  friend STD_ostream& operator << (STD_ostream& s, statisticResult stats);

};


///////////////////////////////////////////////////////////

/**
  * Returns a statistical description of 'ensemble'. If mask is non-zero,
  * only values with mask!=0 are considered.
  *
  */
template<typename T, int N_rank>
statisticResult statistics(const Array<T,N_rank>& ensemble, const Array<T,N_rank>* mask=0) {
  Log<OdinData> odinlog("","statistics");
  statisticResult result;

  result.min=0.0;
  result.max=0.0;
  result.mean=0.0;
  result.stdev=0.0;
  result.meandev=0.0;


  if(mask && !same_shape(ensemble,*mask)) {
    ODINLOG(odinlog,errorLog) << "size mismatch (ensemble.shape()=" << ensemble.shape() << ") != (mask.shape()=" << mask->shape() << ")" << STD_endl;
    return result;
  }


  int n=ensemble.numElements();

  Data<T,N_rank> ensemble_copy(ensemble);

  int nvals=0;
  TinyVector<int,N_rank> index;
  for(int i=0; i<n; i++) {
    index=ensemble_copy.create_index(i);
    bool include=true;
    if(mask && (*mask)(index)==0.0) include=false;
    if(include) {
      float val=ensemble(index);
      result.mean+=val;
      nvals++;
      if(i==0) {
        result.min=result.max=val;
      } else {
        if(val<result.min) result.min=val;
        if(val>result.max) result.max=val;
      }
    }
  }
  result.mean=secureDivision(result.mean,double(nvals));

  nvals=0;
  for(int i=0; i<n; i++) {
    index=ensemble_copy.create_index(i);
    bool include=true;
    if(mask && (*mask)(index)==0.0) include=false;
    if(include) {
      double diff=result.mean-ensemble(index);
      result.stdev+=diff*diff;
      nvals++;
    }
  }
  if(nvals>1) result.stdev=sqrt(result.stdev/double(nvals-1));
  else result.stdev=0.0;

  result.meandev=result.stdev/sqrt(double(nvals));

  return result;
}

///////////////////////////////////////////////////////////

/**
  * Returns the median of 'ensemble'.
  *
  */
template<typename T, int N_rank>
T median(const Array<T,N_rank>& ensemble, const Array<T,N_rank>* mask=0) {
  T result(0);
  Data<T,N_rank> ensemble_copy(ensemble);
  STD_list<T> vallist;
  int n=ensemble_copy.numElements();
  if(!n) return result;
  TinyVector<int,N_rank> index;
  for(int i=0; i<n; i++) {
    index=ensemble_copy.create_index(i);
    bool include=true;
    if(mask && (*mask)(index)==0.0) include=false;
    if(include) vallist.push_back(ensemble_copy(index));
  }
  vallist.sort();

  STD_vector<T> vec(list2vector(vallist));

  if(n%2) {
    result=vec[(n-1)/2]; // odd number of elements
  } else {
    result=0.5*(vec[n/2]+vec[n/2-1]); // even number of elements
  }

  return result;
}

///////////////////////////////////////////////////////////

/**
  * Returns the weighted mean of 'ensemble' using 'weight'
  * for the weighting.
  *
  */
template<typename T, int N_rank>
T weightmean(const Array<T,N_rank>& ensemble, const Array<float,N_rank>& weight) {
  Log<OdinData> odinlog("","weightmean");
  T result;
  result=0; // double-stage init for TinyVector

  Data<T,N_rank> ensemble_copy(ensemble);

  if(ensemble.shape()!=weight.shape()) {
    ODINLOG(odinlog,errorLog) << "size mismatch (ensemble.shape()=" << ensemble.shape() << ") != (weight.shape()=" << weight.shape() << ")" << STD_endl;
    return result;
  }

  float weightsum=0.0;
  TinyVector<int,N_rank> index;
  for(int i=0; i<ensemble_copy.numElements(); i++) {
    index=ensemble_copy.create_index(i);
    float w=fabs(weight(index));
    result+=w*ensemble_copy(index);
    weightsum+=w;
  }
  if(weightsum) result/=weightsum;

  return result;
}


/** @}
  */

#endif