File: test-stats.cc

package info (click to toggle)
coot 1.1.18%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 219,964 kB
  • sloc: cpp: 495,934; python: 35,043; ansic: 26,143; lisp: 22,768; sh: 13,186; makefile: 2,746; awk: 441; xml: 245; csh: 14
file content (66 lines) | stat: -rw-r--r-- 1,981 bytes parent folder | download | duplicates (2)
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
/*
 * analysis/test-stats.cc
 *
 * Copyright 2019 by Medical Research Council
 * Author: Paul Emsley
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA
 */


#include <iostream>
#include "stats.hh"
#include "coot-utils/exp-fit.hh"

int main(int argc, char **argv) {

   int status = 0;

   if (true) {
      double A = 1.1;
      double B = 2.2;
      double C = 0.33;
      std::vector<std::pair<double, double> > data;
      unsigned int n = 20;
      for (unsigned int i=0; i<(n+1); i++) {
         double x = 0.1 * static_cast<double>(i);
         double y = A + B * std::exp(C * x);
         auto p = std::make_pair(x,y);
         data.push_back(p);
      }
      coot::exponential_fit_with_offset ef(data);
      for (unsigned int i=0; i<data.size(); i++) {
         const double &x = data[i].first;
         const double &y = data[i].second;
         double model_y = ef.at(x);
         std::cout << x << " " << y << " " << model_y << std::endl;
      }
   }

   if (false) {
      coot::stats::single s;
      s.add(1); s.add(2); s.add(3);
      s.add(4);
      s.add(5); s.add(6); s.add(7); s.add(8);
      s.add(9); s.add(10);

      std::pair<double, double> mi = s.median_and_iqr();

      std::cout << "median: " << mi.first << " irq " << mi.second << std::endl;
   }

   return status;
}