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// SedSAT3 – Sediment Source Assessment Tool, version 3
2// U.S. Geological Survey. See LICENSE.md and DISCLAIMER.md in the repository root.
3
4// Distribution.cpp: implementation of the GADistribution class.
5//
7
8#include "GADistribution.h"
9#include "randomstream.h"
10#include "math.h"
11#include <stdlib.h>
12
14// Construction/Destruction
16
21
23{
24 n = nn;
25 e.resize(n);
26 s.resize(n);
27}
28
33
35{
36 n = C.n;
37 e.resize(n);
38 s.resize(n);
39 for (int i=0; i<n; i++)
40 {
41 e[i] = C.e[i];
42 s[i] = C.s[i];
43 }
44
45
46}
47
49{
50 n = C.n;
51 e.resize(n);
52 s.resize(n);
53 for (int i=0; i<n; i++)
54 {
55 e[i] = C.e[i];
56 s[i] = C.s[i];
57 }
58
59 return *this;
60
61}
62
64{
65 double x = GetRndUniF(0,1);
66 int ii = 0;
67 for (int i=0; i<n-1; i++)
68 {
69 if (x<e[i] && x>s[i])
70 ii = i;
71 }
72 return ii;
73
74}
75
76
77double GADistribution::GetRndUniF(double xmin, double xmax)
78{
79 return ThreadRandomStream().Uniform()*(xmax-xmin) + xmin;
80}
GADistribution operator=(const GADistribution &C)
virtual ~GADistribution()
std::vector< double > e
std::vector< double > s
static double GetRndUniF(double xmin, double xmax)
double Uniform()
Uniform on [0, 1), with 53 random bits.
RandomStream & ThreadRandomStream()