SedSat3 1.1.6
Sediment Source Apportionment Tool - Advanced statistical methods for environmental pollution research
Loading...
Searching...
No Matches
GADistribution.cpp
Go to the documentation of this file.
1// Distribution.cpp: implementation of the GADistribution class.
2//
4
5#include "GADistribution.h"
6#include "math.h"
7#include <stdlib.h>
8
10// Construction/Destruction
12
17
19{
20 n = nn;
21 e.resize(n);
22 s.resize(n);
23}
24
29
31{
32 n = C.n;
33 e.resize(n);
34 s.resize(n);
35 for (int i=0; i<n; i++)
36 {
37 e[i] = C.e[i];
38 s[i] = C.s[i];
39 }
40
41
42}
43
45{
46 n = C.n;
47 e.resize(n);
48 s.resize(n);
49 for (int i=0; i<n; i++)
50 {
51 e[i] = C.e[i];
52 s[i] = C.s[i];
53 }
54
55 return *this;
56
57}
58
60{
61 double x = GetRndUniF(0,1);
62 int ii = 0;
63 for (int i=0; i<n-1; i++)
64 {
65 if (x<e[i] && x>s[i])
66 ii = i;
67 }
68 return ii;
69
70}
71
72
73double GADistribution::GetRndUniF(double xmin, double xmax)
74{
75 double a = double(rand());
76 double k = double(RAND_MAX);
77 return a/k*(xmax-xmin) + xmin;
78}
GADistribution operator=(const GADistribution &C)
virtual ~GADistribution()
std::vector< double > e
std::vector< double > s
static double GetRndUniF(double xmin, double xmax)