| 1 | ;; Statistics of histograms. |
|---|
| 2 | ;; Liam Healy, Mon Jan 1 2007 - 16:13 |
|---|
| 3 | ;; Time-stamp: <2008-02-17 17:07:06EST statistics.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | (defmfun gsl-max-1 (histogram) |
|---|
| 9 | "gsl_histogram_max_val" |
|---|
| 10 | (((pointer histogram) :pointer)) |
|---|
| 11 | :c-return :double |
|---|
| 12 | :export nil |
|---|
| 13 | :index gsl-max |
|---|
| 14 | :documentation ; FDL |
|---|
| 15 | "The maximum value contained in the histogram bins.") |
|---|
| 16 | |
|---|
| 17 | (defmfun gsl-max-2 (histogram) |
|---|
| 18 | "gsl_histogram2d_max_val" |
|---|
| 19 | (((pointer histogram) :pointer)) |
|---|
| 20 | :c-return :double |
|---|
| 21 | :export nil |
|---|
| 22 | :index gsl-max |
|---|
| 23 | :documentation ; FDL |
|---|
| 24 | "The maximum value contained in the histogram bins.") |
|---|
| 25 | |
|---|
| 26 | (defmethod gsl-max ((histogram histogram)) |
|---|
| 27 | "The maximum value contained in the histogram bins." |
|---|
| 28 | (histo-1d2d histogram gsl-max)) |
|---|
| 29 | |
|---|
| 30 | (defmfun gsl-min-1 (histogram) |
|---|
| 31 | "gsl_histogram_min_val" |
|---|
| 32 | (((pointer histogram) :pointer)) |
|---|
| 33 | :c-return :double |
|---|
| 34 | :export nil |
|---|
| 35 | :index gsl-min |
|---|
| 36 | :documentation ; FDL |
|---|
| 37 | "The minimum value contained in the histogram bins.") |
|---|
| 38 | |
|---|
| 39 | (defmfun gsl-min-2 (histogram) |
|---|
| 40 | "gsl_histogram2d_min_val" |
|---|
| 41 | (((pointer histogram) :pointer)) |
|---|
| 42 | :c-return :double |
|---|
| 43 | :export nil |
|---|
| 44 | :index gsl-min |
|---|
| 45 | :documentation ; FDL |
|---|
| 46 | "The minimum value contained in the histogram bins.") |
|---|
| 47 | |
|---|
| 48 | (defmethod gsl-min ((histogram histogram)) ; FDL |
|---|
| 49 | "The minimum value contained in the histogram bins." |
|---|
| 50 | (histo-1d2d histogram gsl-min)) |
|---|
| 51 | |
|---|
| 52 | (defmfun gsl-max-index-1 (histogram) |
|---|
| 53 | "gsl_histogram_max_bin" |
|---|
| 54 | (((pointer histogram) :pointer)) |
|---|
| 55 | :c-return size |
|---|
| 56 | :export nil |
|---|
| 57 | :index gsl-max-index |
|---|
| 58 | :documentation ; FDL |
|---|
| 59 | "The index of the bin containing the maximum value. In the case |
|---|
| 60 | where several bins contain the same maximum value the smallest |
|---|
| 61 | index is returned.") |
|---|
| 62 | |
|---|
| 63 | (defmfun gsl-max-index-2 (histogram) |
|---|
| 64 | "gsl_histogram2d_max_bin" |
|---|
| 65 | (((pointer histogram) :pointer) |
|---|
| 66 | (xindex size) (yindex size)) |
|---|
| 67 | :c-return size |
|---|
| 68 | :export nil |
|---|
| 69 | :index gsl-max-index |
|---|
| 70 | :documentation ; FDL |
|---|
| 71 | "The indices of the bin containing the maximum value. In the case |
|---|
| 72 | where several bins contain the same maximum value the first bin |
|---|
| 73 | found is returned.") |
|---|
| 74 | |
|---|
| 75 | (defmethod gsl-max-index (histogram) |
|---|
| 76 | (histo-1d2d histogram gsl-max-index)) |
|---|
| 77 | |
|---|
| 78 | (defmfun gsl-min-index-1 (histogram) |
|---|
| 79 | "gsl_histogram_min_bin" |
|---|
| 80 | (((pointer histogram) :pointer)) |
|---|
| 81 | :c-return size |
|---|
| 82 | :export nil |
|---|
| 83 | :index gsl-min-index |
|---|
| 84 | :documentation ; FDL |
|---|
| 85 | "The index of the bin containing the minimum value. In the case |
|---|
| 86 | where several bins contain the same minimum value the smallest |
|---|
| 87 | index is returned.") |
|---|
| 88 | |
|---|
| 89 | (defmfun gsl-min-index-2 (histogram) |
|---|
| 90 | "gsl_histogram2d_min_bin" |
|---|
| 91 | (((pointer histogram) :pointer) |
|---|
| 92 | (xindex size) (yindex size)) |
|---|
| 93 | :c-return size |
|---|
| 94 | :export nil |
|---|
| 95 | :index gsl-min-index |
|---|
| 96 | :documentation ; FDL |
|---|
| 97 | "The indices of the bin containing the minimum value. In the case |
|---|
| 98 | where several bins contain the same minimum value the first bin |
|---|
| 99 | found is returned.") |
|---|
| 100 | |
|---|
| 101 | (defmethod gsl-min-index (histogram) |
|---|
| 102 | (histo-1d2d histogram gsl-min-index)) |
|---|
| 103 | |
|---|
| 104 | (defmfun mean-1 (histogram) |
|---|
| 105 | "gsl_histogram_mean" |
|---|
| 106 | (((pointer histogram) :pointer)) |
|---|
| 107 | :c-return :double |
|---|
| 108 | :export nil |
|---|
| 109 | :index mean |
|---|
| 110 | :documentation ; FDL |
|---|
| 111 | "The mean of the histogrammed variable, where the histogram is |
|---|
| 112 | regarded as a probability distribution. Negative bin values |
|---|
| 113 | are ignored for the purposes of this calculation. The |
|---|
| 114 | resolution of the result is limited by the bin width.") |
|---|
| 115 | |
|---|
| 116 | (defmfun mean-2x (histogram) |
|---|
| 117 | "gsl_histogram2d_xmean" |
|---|
| 118 | (((pointer histogram) :pointer)) |
|---|
| 119 | :c-return :double |
|---|
| 120 | :export nil |
|---|
| 121 | :index mean |
|---|
| 122 | :documentation ; FDL |
|---|
| 123 | "The mean of the histogrammed x variable, where the histogram |
|---|
| 124 | is regarded as a probability distribution. Negative bin values |
|---|
| 125 | are ignored for the purposes of this calculation.") |
|---|
| 126 | |
|---|
| 127 | (defmfun mean-2y (histogram) |
|---|
| 128 | "gsl_histogram2d_ymean" |
|---|
| 129 | (((pointer histogram) :pointer)) |
|---|
| 130 | :c-return :double |
|---|
| 131 | :export nil |
|---|
| 132 | :index mean |
|---|
| 133 | :documentation ; FDL |
|---|
| 134 | "The mean of the histogrammed y variable, where the histogram |
|---|
| 135 | is regarded as a probability distribution. Negative bin values |
|---|
| 136 | are ignored for the purposes of this calculation.") |
|---|
| 137 | |
|---|
| 138 | (defmethod mean ((histogram histogram)) ; FDL |
|---|
| 139 | "The mean of the histogrammed y variable, where the histogram |
|---|
| 140 | is regarded as a probability distribution. Negative bin values |
|---|
| 141 | are ignored for the purposes of this calculation. For 2d |
|---|
| 142 | histograms, the means are returned as multiple values." |
|---|
| 143 | (flet ((mean-2 (histogram) |
|---|
| 144 | (values (mean-2x histogram) (mean-2y histogram)))) |
|---|
| 145 | (histo-1d2d histogram mean ))) |
|---|
| 146 | |
|---|
| 147 | (defmfun sigma-1 (histogram) |
|---|
| 148 | "gsl_histogram_sigma" |
|---|
| 149 | (((pointer histogram) :pointer)) |
|---|
| 150 | :c-return :double |
|---|
| 151 | :export nil |
|---|
| 152 | :index sigma |
|---|
| 153 | :documentation ; FDL |
|---|
| 154 | "The standard deviation of the histogrammed variable, where the |
|---|
| 155 | histogram is regarded as a probability distribution. Negative |
|---|
| 156 | bin values are ignored for the purposes of this |
|---|
| 157 | calculation. The resolution of the result is limited by the bin |
|---|
| 158 | width.") |
|---|
| 159 | |
|---|
| 160 | (defmfun sigma-2x (histogram) |
|---|
| 161 | "gsl_histogram2d_xsigma" |
|---|
| 162 | (((pointer histogram) :pointer)) |
|---|
| 163 | :c-return :double |
|---|
| 164 | :export nil |
|---|
| 165 | :index sigma) |
|---|
| 166 | |
|---|
| 167 | (defmfun sigma-2y (histogram) |
|---|
| 168 | "gsl_histogram2d_ysigma" |
|---|
| 169 | (((pointer histogram) :pointer)) |
|---|
| 170 | :c-return :double |
|---|
| 171 | :export nil |
|---|
| 172 | :index sigma) |
|---|
| 173 | |
|---|
| 174 | (export 'sigma) |
|---|
| 175 | (defun sigma (histogram) |
|---|
| 176 | "The standard deviation of the histogrammed variable, where the |
|---|
| 177 | histogram is regarded as a probability distribution. Negative |
|---|
| 178 | bin values are ignored for the purposes of this |
|---|
| 179 | calculation. The resolution of the result is limited by the |
|---|
| 180 | bin width. For 2d histograms, the sigmas are returned as |
|---|
| 181 | multiple values." ; FDL |
|---|
| 182 | (flet ((sigma-2 (histogram) |
|---|
| 183 | (values (sigma-2x histogram) (sigma-2y histogram)))) |
|---|
| 184 | (histo-1d2d histogram sigma))) |
|---|
| 185 | |
|---|
| 186 | (defmfun histogram-covariance (histogram-2d) |
|---|
| 187 | "gsl_histogram2d_cov" |
|---|
| 188 | (((pointer histogram-2d) :pointer)) |
|---|
| 189 | :c-return :double |
|---|
| 190 | :documentation ; FDL |
|---|
| 191 | "The covariance of the histogrammed x and y variables, where |
|---|
| 192 | the histogram is regarded as a probability |
|---|
| 193 | distribution. Negative bin values are ignored for the purposes |
|---|
| 194 | of this calculation.") |
|---|
| 195 | |
|---|
| 196 | (defmfun sum-1 (histogram) |
|---|
| 197 | "gsl_histogram_sum" |
|---|
| 198 | (((pointer histogram) :pointer)) |
|---|
| 199 | :c-return :double |
|---|
| 200 | :export nil |
|---|
| 201 | :index sum |
|---|
| 202 | :documentation ; FDL |
|---|
| 203 | "The sum of all bin values. Negative bin values are included in |
|---|
| 204 | the sum.") |
|---|
| 205 | |
|---|
| 206 | (defmfun sum-2 (histogram) |
|---|
| 207 | "gsl_histogram2d_sum" |
|---|
| 208 | (((pointer histogram) :pointer)) |
|---|
| 209 | :c-return :double |
|---|
| 210 | :export nil |
|---|
| 211 | :index sum |
|---|
| 212 | :documentation ; FDL |
|---|
| 213 | "The sum of all bin values. Negative bin values are included in |
|---|
| 214 | the sum.") |
|---|
| 215 | |
|---|
| 216 | (export 'sum) |
|---|
| 217 | (defun sum (histogram) |
|---|
| 218 | ;; FDL |
|---|
| 219 | "The sum of all bin values. Negative bin values are included in |
|---|
| 220 | the sum." |
|---|
| 221 | (histo-1d2d histogram sum)) |
|---|