ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
histgram.cpp
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  */
11 #include <fvar.hpp>
12 
17 ivector histogram(double min, double max, int nbin, const dvector& v)
18 {
19  ivector tmp(1,nbin);
20  int mmin=v.indexmin();
21  int mmax=v.indexmax();
22  tmp.initialize();
23  double delta=double(max-min)/nbin;
24  for (int i=mmin;i<=mmax;i++)
25  {
26  int j= int((v(i)-min)/delta)+1;
27  if (j<1) j=1;
28  if (j>nbin) j=nbin;
29  tmp(j)+=1;
30  }
31  return tmp;
32 }
Vector of double precision numbers.
Definition: dvector.h:50
int indexmin() const
Get minimum valid index.
Definition: dvector.h:199
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
#define min(a, b)
Definition: cbivnorm.cpp:188
int indexmax() const
Get maximum valid index.
Definition: dvector.h:204
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
ivector histogram(double min, double max, int nbin, const dvector &input)
Description not yet available.
Definition: histgram.cpp:17
void initialize(void)
Description not yet available.
Definition: ivec2.cpp:17
#define max(a, b)
Definition: cbivnorm.cpp:189