boost_distributions 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE +28 -0
- data/README.md +119 -0
- data/Rakefile +83 -0
- data/boost_distributions.gemspec +67 -0
- data/ext/boost_distributions/BoostDistributions/BoostDistributions_wrap.cxx +43096 -0
- data/ext/boost_distributions/extconf.rb +69 -0
- data/ext/ninja-scan-light/tool/swig/BoostDistributions.i +420 -0
- data/ext/ninja-scan-light/tool/swig/extconf.rb +5 -0
- data/ext/ninja-scan-light/tool/swig/makefile +53 -0
- data/lib/boost_distributions/version.rb +5 -0
- data/lib/boost_distributions.rb +10 -0
- data/sig/boost_distributions.rbs +4 -0
- metadata +106 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "mkmf"
|
|
4
|
+
cflags = " -Wall"
|
|
5
|
+
$CFLAGS += cflags
|
|
6
|
+
$CPPFLAGS += cflags if RUBY_VERSION >= "2.0.0"
|
|
7
|
+
$LOCAL_LIBS += " -lstdc++ "
|
|
8
|
+
|
|
9
|
+
IO_TARGETS = [
|
|
10
|
+
[Kernel, :instance_eval],
|
|
11
|
+
[(class << File; self; end), :class_eval], # https://github.com/ruby/ruby/commit/19beb028
|
|
12
|
+
]
|
|
13
|
+
def IO_TARGETS.mod(&b)
|
|
14
|
+
self.each{|class_, func| class_.send(func, &b)}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
IO_TARGETS.mod{
|
|
18
|
+
alias_method(:open_orig, :open)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Dir::glob(File::join(File::dirname(__FILE__), "*/")).each{|dir|
|
|
22
|
+
mod_name = File::basename(dir)
|
|
23
|
+
|
|
24
|
+
dst = File::join(Dir.getwd, mod_name)
|
|
25
|
+
FileUtils::mkdir_p(dst) if dir != dst
|
|
26
|
+
|
|
27
|
+
$stderr.puts "For #{mod_name} ..."
|
|
28
|
+
|
|
29
|
+
# @see https://stackoverflow.com/a/35842162/15992898
|
|
30
|
+
$srcs = Dir::glob(File::join(dir, '*.cxx')).collect{|path|
|
|
31
|
+
File::join(mod_name, File::basename(path))
|
|
32
|
+
}
|
|
33
|
+
$objs = $srcs.collect{|path|
|
|
34
|
+
path.sub(/\.[^\.]+$/, '.o')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
IO_TARGETS.mod{
|
|
38
|
+
# rename Makefile to Makefile.#{mod_name}
|
|
39
|
+
define_method(:open){|*args, &b|
|
|
40
|
+
args[0] += ".#{mod_name}" if (args[0] && (args[0] == "Makefile"))
|
|
41
|
+
open_orig(*args, &b)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
create_makefile("boost_distributions/#{mod_name}")
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
IO_TARGETS.mod{
|
|
48
|
+
alias_method(:open, :open_orig)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# manual generation of top-level Makefile
|
|
52
|
+
# @see https://yorickpeterse.com/articles/hacking-extconf-rb/
|
|
53
|
+
open("Makefile", 'w'){|io|
|
|
54
|
+
# @see https://stackoverflow.com/a/17845120/15992898
|
|
55
|
+
io.write(<<-__TOPLEVEL_MAKEFILE__)
|
|
56
|
+
TOPTARGETS := all clean distclean realclean install site-install
|
|
57
|
+
|
|
58
|
+
SUBMFS := $(wildcard Makefile.*)
|
|
59
|
+
|
|
60
|
+
$(TOPTARGETS): $(SUBMFS)
|
|
61
|
+
$(SUBMFS):
|
|
62
|
+
#{"\t"}$(MAKE) -f $@ $(MAKECMDGOALS)
|
|
63
|
+
|
|
64
|
+
.PHONY: $(TOPTARGETS) $(SUBMFS)
|
|
65
|
+
__TOPLEVEL_MAKEFILE__
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
require 'fileutils'
|
|
69
|
+
FileUtils::touch("boost_distributions.so") # dummy
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file SWIG interface file for boost::math::distributions
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
%module BoostDistributions
|
|
7
|
+
|
|
8
|
+
%include std_common.i
|
|
9
|
+
%include std_except.i
|
|
10
|
+
|
|
11
|
+
%{
|
|
12
|
+
#include <sstream>
|
|
13
|
+
#include <stdexcept>
|
|
14
|
+
|
|
15
|
+
#include <boost/version.hpp>
|
|
16
|
+
#define BOOST_VERSION_LESS_THAN(ver) (BOOST_VERSION < ver)
|
|
17
|
+
|
|
18
|
+
#include <boost/math/distributions.hpp>
|
|
19
|
+
namespace boost { namespace math {
|
|
20
|
+
template <int RequiredVersion, bool check_passed = !BOOST_VERSION_LESS_THAN(RequiredVersion)>
|
|
21
|
+
struct distribution_shim_t {
|
|
22
|
+
#define GEN_FUNC(func_name) \
|
|
23
|
+
template <class DistT, class ValueT> \
|
|
24
|
+
inline static typename DistT::value_type func_name(const DistT &dist, const ValueT &x){ \
|
|
25
|
+
return boost::math::func_name(dist, x); \
|
|
26
|
+
}
|
|
27
|
+
GEN_FUNC(pdf);
|
|
28
|
+
GEN_FUNC(hazard);
|
|
29
|
+
GEN_FUNC(chf);
|
|
30
|
+
#undef GEN_FUNC
|
|
31
|
+
#define GEN_FUNC(func_name) \
|
|
32
|
+
template <class DistT, class ValueT> \
|
|
33
|
+
inline static typename DistT::value_type func_name( \
|
|
34
|
+
const DistT &dist, const ValueT &x, const bool &is_complement = false){ \
|
|
35
|
+
return is_complement \
|
|
36
|
+
? boost::math::func_name(complement(dist, x)) \
|
|
37
|
+
: boost::math::func_name(dist, x); \
|
|
38
|
+
}
|
|
39
|
+
GEN_FUNC(cdf);
|
|
40
|
+
GEN_FUNC(quantile);
|
|
41
|
+
#undef GEN_FUNC
|
|
42
|
+
#define GEN_FUNC(func_name) \
|
|
43
|
+
template <class DistT> \
|
|
44
|
+
inline static typename DistT::value_type func_name(const DistT &dist){ \
|
|
45
|
+
return boost::math::func_name(dist); \
|
|
46
|
+
}
|
|
47
|
+
GEN_FUNC(mean);
|
|
48
|
+
GEN_FUNC(median);
|
|
49
|
+
GEN_FUNC(mode);
|
|
50
|
+
GEN_FUNC(standard_deviation);
|
|
51
|
+
GEN_FUNC(variance);
|
|
52
|
+
GEN_FUNC(skewness);
|
|
53
|
+
GEN_FUNC(kurtosis);
|
|
54
|
+
GEN_FUNC(kurtosis_excess);
|
|
55
|
+
#undef GEN_FUNC
|
|
56
|
+
#define GEN_FUNC(func_name) \
|
|
57
|
+
template <class DistT> \
|
|
58
|
+
inline static std::pair<typename DistT::value_type, typename DistT::value_type> \
|
|
59
|
+
func_name(const DistT &dist){ \
|
|
60
|
+
return boost::math::func_name(dist); \
|
|
61
|
+
}
|
|
62
|
+
GEN_FUNC(range);
|
|
63
|
+
GEN_FUNC(support);
|
|
64
|
+
#undef GEN_FUNC
|
|
65
|
+
};
|
|
66
|
+
template <int RequiredVersion>
|
|
67
|
+
struct distribution_shim_t<RequiredVersion, false> { // dummy
|
|
68
|
+
static const std::string err_msg(){
|
|
69
|
+
std::stringstream ss;
|
|
70
|
+
ss << "BOOST_VERSION(" << BOOST_VERSION
|
|
71
|
+
<< ") should be >= " << RequiredVersion;
|
|
72
|
+
return ss.str();
|
|
73
|
+
}
|
|
74
|
+
#define GEN_FUNC(func_name) \
|
|
75
|
+
template <class DistT, class ValueT> \
|
|
76
|
+
inline static typename DistT::value_type func_name(const DistT &dist, const ValueT &x){ \
|
|
77
|
+
throw std::logic_error(err_msg()); \
|
|
78
|
+
}
|
|
79
|
+
GEN_FUNC(pdf);
|
|
80
|
+
GEN_FUNC(hazard);
|
|
81
|
+
GEN_FUNC(chf);
|
|
82
|
+
#undef GEN_FUNC
|
|
83
|
+
#define GEN_FUNC(func_name) \
|
|
84
|
+
template <class DistT, class ValueT> \
|
|
85
|
+
inline static typename DistT::value_type func_name( \
|
|
86
|
+
const DistT &dist, const ValueT &x, const bool &is_complement = false){ \
|
|
87
|
+
throw std::logic_error(err_msg()); \
|
|
88
|
+
}
|
|
89
|
+
GEN_FUNC(cdf);
|
|
90
|
+
GEN_FUNC(quantile);
|
|
91
|
+
#undef GEN_FUNC
|
|
92
|
+
#define GEN_FUNC(func_name) \
|
|
93
|
+
template <class DistT> \
|
|
94
|
+
inline static typename DistT::value_type func_name(const DistT &dist){ \
|
|
95
|
+
throw std::logic_error(err_msg()); \
|
|
96
|
+
}
|
|
97
|
+
GEN_FUNC(mean);
|
|
98
|
+
GEN_FUNC(median);
|
|
99
|
+
GEN_FUNC(mode);
|
|
100
|
+
GEN_FUNC(standard_deviation);
|
|
101
|
+
GEN_FUNC(variance);
|
|
102
|
+
GEN_FUNC(skewness);
|
|
103
|
+
GEN_FUNC(kurtosis);
|
|
104
|
+
GEN_FUNC(kurtosis_excess);
|
|
105
|
+
#undef GEN_FUNC
|
|
106
|
+
#define GEN_FUNC(func_name) \
|
|
107
|
+
template <class DistT> \
|
|
108
|
+
inline static std::pair<typename DistT::value_type, typename DistT::value_type> \
|
|
109
|
+
func_name(const DistT &dist){ \
|
|
110
|
+
throw std::logic_error(err_msg()); \
|
|
111
|
+
}
|
|
112
|
+
GEN_FUNC(range);
|
|
113
|
+
GEN_FUNC(support);
|
|
114
|
+
#undef GEN_FUNC
|
|
115
|
+
};
|
|
116
|
+
template <class RealType, int RequiredVersion>
|
|
117
|
+
struct distribution_dummy_t {
|
|
118
|
+
typedef RealType value_type;
|
|
119
|
+
static const std::string err_msg(){
|
|
120
|
+
return distribution_shim_t<RequiredVersion, false>::err_msg();
|
|
121
|
+
}
|
|
122
|
+
distribution_dummy_t(){throw std::logic_error(err_msg());}
|
|
123
|
+
|
|
124
|
+
// static/member functions
|
|
125
|
+
#define GEN_FUNC_m(ret_type, fun_name) \
|
|
126
|
+
ret_type fun_name(...) const {throw std::logic_error(err_msg());}
|
|
127
|
+
#define GEN_FUNC_s(ret_type, fun_name) \
|
|
128
|
+
static ret_type fun_name(...){throw std::logic_error(err_msg());}
|
|
129
|
+
|
|
130
|
+
GEN_FUNC_m(RealType, x_max); // arcsine
|
|
131
|
+
GEN_FUNC_m(RealType, x_min); // arcsine
|
|
132
|
+
GEN_FUNC_m(RealType, success_fraction);
|
|
133
|
+
// bernoulli, binomial, geometric, negative_binomial
|
|
134
|
+
GEN_FUNC_m(RealType, alpha); // beta, non_central_beta
|
|
135
|
+
GEN_FUNC_m(RealType, beta); // beta, non_central_beta
|
|
136
|
+
GEN_FUNC_s(RealType, find_alpha); // beta
|
|
137
|
+
GEN_FUNC_s(RealType, find_beta); // beta
|
|
138
|
+
GEN_FUNC_s(RealType, find_lower_bound_on_p);
|
|
139
|
+
// binomial, geometric, negative_binomial
|
|
140
|
+
GEN_FUNC_s(RealType, find_maximum_number_of_trials);
|
|
141
|
+
// binomial, geometric, negative_binomial
|
|
142
|
+
GEN_FUNC_s(RealType, find_minimum_number_of_trials);
|
|
143
|
+
// binomial, geometric, negative_binomial
|
|
144
|
+
GEN_FUNC_s(RealType, find_upper_bound_on_p);
|
|
145
|
+
// binomial, geometric, negative_binomial
|
|
146
|
+
GEN_FUNC_m(RealType, trails); // binomial
|
|
147
|
+
GEN_FUNC_m(RealType, location);
|
|
148
|
+
// cauchy, extreme_value, inverse_gaussian,
|
|
149
|
+
// laplace, logistic, lognormal, normal, skew_normal
|
|
150
|
+
GEN_FUNC_m(RealType, scale);
|
|
151
|
+
// cauchy, extreme_value, gamma, inverse_chi_squared,
|
|
152
|
+
// inverse_gamma, inverse_gaussian, laplace, logistic,
|
|
153
|
+
// lognormal, normal, pareto, skew_normal, weibull
|
|
154
|
+
GEN_FUNC_s(RealType, find_degrees_of_freedom);
|
|
155
|
+
// chi_squared, non_central_chi_squared, students_t
|
|
156
|
+
GEN_FUNC_m(RealType, degrees_of_freedom);
|
|
157
|
+
// chi_squared, inverse_chi_squared, non_central_chi_squared,
|
|
158
|
+
// non_central_t, students_t
|
|
159
|
+
GEN_FUNC_m(RealType, lambda); // exponential
|
|
160
|
+
GEN_FUNC_m(RealType, degrees_of_freedom1); // fisher_f, non_central_f
|
|
161
|
+
GEN_FUNC_m(RealType, degrees_of_freedom2); // fisher_f, non_central_f
|
|
162
|
+
GEN_FUNC_m(RealType, shape);
|
|
163
|
+
// gamma, inverse_gamma, inverse_gaussian, pareto,
|
|
164
|
+
// skew_normal, weibull
|
|
165
|
+
GEN_FUNC_m(RealType, successes); // geometric, negative_binomial
|
|
166
|
+
GEN_FUNC_m(std::vector<RealType>, probabilities); // hyperexponential
|
|
167
|
+
GEN_FUNC_m(std::vector<RealType>, rates); // hyperexponential
|
|
168
|
+
GEN_FUNC_m(std::size_t, num_phases); // hyperexponential
|
|
169
|
+
GEN_FUNC_m(bool, check_params); // hypergeometric
|
|
170
|
+
GEN_FUNC_m(bool, check_x); // hypergeometric
|
|
171
|
+
GEN_FUNC_m(unsigned, defective); // hypergeometric
|
|
172
|
+
GEN_FUNC_m(unsigned, sample_count); // hypergeometric
|
|
173
|
+
GEN_FUNC_m(unsigned, total); // hypergeometric
|
|
174
|
+
GEN_FUNC_m(RealType, mean); // inverse_gaussian, poisson
|
|
175
|
+
GEN_FUNC_m(RealType, number_of_observations); // kolmogorov_smirnov
|
|
176
|
+
GEN_FUNC_m(RealType, non_centrality);
|
|
177
|
+
// non_central_beta, non_central_chi_squared, non_central_f,
|
|
178
|
+
// non_central_t
|
|
179
|
+
GEN_FUNC_s(RealType, find_non_centrality);
|
|
180
|
+
// non_central_chi_squared
|
|
181
|
+
GEN_FUNC_m(RealType, standard_deviation); // normal
|
|
182
|
+
GEN_FUNC_m(RealType, sigma); // rayleigh
|
|
183
|
+
GEN_FUNC_m(RealType, lower); // triangular, uniform
|
|
184
|
+
GEN_FUNC_m(RealType, mode); // triangular
|
|
185
|
+
GEN_FUNC_m(RealType, upper); // triangular, uniform
|
|
186
|
+
|
|
187
|
+
#undef GEN_FUNC_s
|
|
188
|
+
#undef GEN_FUNC_m
|
|
189
|
+
};
|
|
190
|
+
} }
|
|
191
|
+
using namespace boost::math;
|
|
192
|
+
%}
|
|
193
|
+
%include boost/version.hpp
|
|
194
|
+
|
|
195
|
+
%define INSTANTIATE(dist_name, type, class_name, min_ver)
|
|
196
|
+
%{
|
|
197
|
+
#if BOOST_VERSION_LESS_THAN(min_ver)
|
|
198
|
+
namespace boost{ namespace math{
|
|
199
|
+
template <class RealType = double, class Policy = policies::policy<> >
|
|
200
|
+
struct dist_name ## _distribution : public distribution_dummy_t<RealType, min_ver> { // dummy
|
|
201
|
+
dist_name ## _distribution(...) : distribution_dummy_t<RealType, min_ver>() {}
|
|
202
|
+
};
|
|
203
|
+
} }
|
|
204
|
+
#endif
|
|
205
|
+
%}
|
|
206
|
+
#if BOOST_VERSION >= min_ver
|
|
207
|
+
%include boost/math/distributions/ ## dist_name ## .hpp
|
|
208
|
+
#else
|
|
209
|
+
namespace boost{ namespace math{
|
|
210
|
+
template <class RealType = double, class Policy = policies::policy<> >
|
|
211
|
+
struct dist_name ## _distribution { // dummy
|
|
212
|
+
typedef RealType value_type;
|
|
213
|
+
dist_name ## _distribution();
|
|
214
|
+
};
|
|
215
|
+
} }
|
|
216
|
+
#endif
|
|
217
|
+
%typemap(out, fragment=SWIG_Traits_frag(type)) std::pair<type, type> {
|
|
218
|
+
%append_output(swig::from($1.first));
|
|
219
|
+
%append_output(swig::from($1.second));
|
|
220
|
+
}
|
|
221
|
+
%extend boost::math::dist_name ## _distribution {
|
|
222
|
+
%catches(std::logic_error) dist_name ## _distribution; // for ctor
|
|
223
|
+
%catches(std::logic_error, std::runtime_error); // for the following member functions
|
|
224
|
+
#define shim_t boost::math::distribution_shim_t<min_ver>
|
|
225
|
+
value_type pdf(const value_type &x) const {
|
|
226
|
+
return shim_t::pdf(*$self, x);
|
|
227
|
+
}
|
|
228
|
+
value_type cdf(const value_type &x, const bool &is_complement = false) const {
|
|
229
|
+
return shim_t::cdf(*$self, x, is_complement);
|
|
230
|
+
}
|
|
231
|
+
value_type quantile(const value_type &p, const bool &is_complement = false) const {
|
|
232
|
+
return shim_t::quantile(*$self, p, is_complement);
|
|
233
|
+
}
|
|
234
|
+
value_type hazard(const value_type &x) const {
|
|
235
|
+
return shim_t::hazard(*$self, x);
|
|
236
|
+
}
|
|
237
|
+
value_type chf(const value_type &x) const {
|
|
238
|
+
return shim_t::chf(*$self, x);
|
|
239
|
+
}
|
|
240
|
+
value_type mean() const {return shim_t::mean(*$self);}
|
|
241
|
+
value_type median() const {return shim_t::median(*$self);}
|
|
242
|
+
value_type mode() const {return shim_t::mode(*$self);}
|
|
243
|
+
value_type standard_deviation() const {return shim_t::standard_deviation(*$self);}
|
|
244
|
+
value_type variance() const {return shim_t::variance(*$self);}
|
|
245
|
+
value_type skewness() const {return shim_t::skewness(*$self);}
|
|
246
|
+
value_type kurtosis() const {return shim_t::kurtosis(*$self);}
|
|
247
|
+
value_type kurtosis_excess() const {return shim_t::kurtosis_excess(*$self);}
|
|
248
|
+
std::pair<value_type, value_type> range() const {return shim_t::range(*$self);}
|
|
249
|
+
std::pair<value_type, value_type> support() const {return shim_t::support(*$self);}
|
|
250
|
+
#undef shim_t
|
|
251
|
+
};
|
|
252
|
+
%template(class_name) boost::math:: ## dist_name ## _distribution<type, policies::policy<> >;
|
|
253
|
+
%enddef
|
|
254
|
+
|
|
255
|
+
%extend boost::math::cauchy_distribution {
|
|
256
|
+
%ignore mean;
|
|
257
|
+
%ignore standard_deviation;
|
|
258
|
+
%ignore variance;
|
|
259
|
+
%ignore skewness;
|
|
260
|
+
%ignore kurtosis;
|
|
261
|
+
%ignore kurtosis_excess;
|
|
262
|
+
};
|
|
263
|
+
%extend boost::math::non_central_beta_distribution {
|
|
264
|
+
%ignore skewness;
|
|
265
|
+
%ignore kurtosis;
|
|
266
|
+
%ignore kurtosis_excess;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// workaround for hyperexponential having RealT template parameter instead of RealType
|
|
270
|
+
%extend boost::math::hyperexponential_distribution {
|
|
271
|
+
%ignore hyperexponential_distribution(std::initializer_list<RealT>, std::initializer_list<RealT>);
|
|
272
|
+
%ignore hyperexponential_distribution(std::initializer_list<RealT>);
|
|
273
|
+
%typemap(out, fragment=SWIG_Traits_frag(RealT)) std::vector<RealT> {
|
|
274
|
+
for(typename $1_type::const_iterator it($1.begin()), it_end($1.end());
|
|
275
|
+
it != it_end; ++it){
|
|
276
|
+
%append_output(swig::from(*it));
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
%typemap(in, fragment=SWIG_Traits_frag(RealT)) const std::vector<RealT> & (std::vector<RealT> temp) {
|
|
280
|
+
#if defined(SWIGRUBY)
|
|
281
|
+
if(RB_TYPE_P($input, T_ARRAY)){
|
|
282
|
+
RealT v;
|
|
283
|
+
for(unsigned int i(0), i_end((unsigned int)RARRAY_LEN($input)); i < i_end; ++i){
|
|
284
|
+
VALUE val(RARRAY_AREF($input, i));
|
|
285
|
+
if(!SWIG_IsOK(swig::asval(val, &v))){break;}
|
|
286
|
+
temp.push_back(v);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
#endif
|
|
290
|
+
$1 = &temp;
|
|
291
|
+
}
|
|
292
|
+
#if BOOST_VERSION >= 105700
|
|
293
|
+
hyperexponential_distribution(
|
|
294
|
+
const std::vector<RealT> &prob, const std::vector<RealT> &range){
|
|
295
|
+
return new hyperexponential_distribution(
|
|
296
|
+
prob.begin(), prob.end(), range.begin(), range.end());
|
|
297
|
+
}
|
|
298
|
+
hyperexponential_distribution(
|
|
299
|
+
const std::vector<RealT> &range){
|
|
300
|
+
return new hyperexponential_distribution(range.begin(), range.end());
|
|
301
|
+
}
|
|
302
|
+
#endif
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// workaround for swig parse error of hyperexponential::is_iterator (>=1.77.0)
|
|
306
|
+
#if BOOST_VERSION >= 107700
|
|
307
|
+
namespace boost{ namespace math{
|
|
308
|
+
template <typename RealT = double, typename PolicyT = policies::policy<> >
|
|
309
|
+
class hyperexponential_distribution { /* extracted from ver 1.81.0 */
|
|
310
|
+
public:
|
|
311
|
+
typedef RealT value_type;
|
|
312
|
+
typedef PolicyT policy_type;
|
|
313
|
+
|
|
314
|
+
hyperexponential_distribution();
|
|
315
|
+
|
|
316
|
+
// Four arg constructor: no ambiguity here, the arguments must be two pairs of iterators:
|
|
317
|
+
template <typename ProbIterT, typename RateIterT>
|
|
318
|
+
hyperexponential_distribution(
|
|
319
|
+
ProbIterT prob_first, ProbIterT prob_last,
|
|
320
|
+
RateIterT rate_first, RateIterT rate_last);
|
|
321
|
+
|
|
322
|
+
// Two arg constructor from 2 ranges, we SFINAE this out of existence if
|
|
323
|
+
// either argument type is incrementable as in that case the type is
|
|
324
|
+
// probably an iterator:
|
|
325
|
+
template <
|
|
326
|
+
typename ProbRangeT, typename RateRangeT,
|
|
327
|
+
typename std::enable_if<!is_iterator<ProbRangeT>::value &&
|
|
328
|
+
!is_iterator<RateRangeT>::value, bool>::type = true>
|
|
329
|
+
hyperexponential_distribution(
|
|
330
|
+
ProbRangeT const& prob_range, RateRangeT const& rate_range);
|
|
331
|
+
|
|
332
|
+
// Two arg constructor for a pair of iterators: we SFINAE this out of
|
|
333
|
+
// existence if neither argument types are incrementable.
|
|
334
|
+
// Note that we allow different argument types here to allow for
|
|
335
|
+
// construction from an array plus a pointer into that array.
|
|
336
|
+
template <
|
|
337
|
+
typename RateIterT, typename RateIterT2,
|
|
338
|
+
typename std::enable_if<
|
|
339
|
+
is_iterator<RateIterT>::value || is_iterator<RateIterT2>::value, bool>::type = true>
|
|
340
|
+
hyperexponential_distribution(
|
|
341
|
+
RateIterT const& rate_first, RateIterT2 const& rate_last);
|
|
342
|
+
|
|
343
|
+
// Initializer list constructor: allows for construction from array literals:
|
|
344
|
+
hyperexponential_distribution(std::initializer_list<RealT> l1, std::initializer_list<RealT> l2);
|
|
345
|
+
|
|
346
|
+
hyperexponential_distribution(std::initializer_list<RealT> l1);
|
|
347
|
+
|
|
348
|
+
// Single argument constructor: argument must be a range.
|
|
349
|
+
template <typename RateRangeT>
|
|
350
|
+
hyperexponential_distribution(RateRangeT const& rate_range);
|
|
351
|
+
|
|
352
|
+
std::vector<RealT> probabilities() const;
|
|
353
|
+
std::vector<RealT> rates() const;
|
|
354
|
+
std::size_t num_phases() const;
|
|
355
|
+
};
|
|
356
|
+
} }
|
|
357
|
+
#define BOOST_MATH_DISTRIBUTIONS_HYPEREXPONENTIAL_HPP
|
|
358
|
+
#endif
|
|
359
|
+
|
|
360
|
+
%define CTACH_LOGIC_ERROR(dist_name, func_name)
|
|
361
|
+
%extend boost::math::dist_name ## _distribution {
|
|
362
|
+
%catches(std::logic_error) func_name;
|
|
363
|
+
};
|
|
364
|
+
%enddef
|
|
365
|
+
|
|
366
|
+
%define CTACH_LOGIC_ERROR_FOR_FIND_METHODS(dist_name)
|
|
367
|
+
CTACH_LOGIC_ERROR(dist_name, find_lower_bound_on_p);
|
|
368
|
+
CTACH_LOGIC_ERROR(dist_name, find_upper_bound_on_p);
|
|
369
|
+
CTACH_LOGIC_ERROR(dist_name, find_minimum_number_of_trials);
|
|
370
|
+
CTACH_LOGIC_ERROR(dist_name, find_maximum_number_of_trials);
|
|
371
|
+
%enddef
|
|
372
|
+
CTACH_LOGIC_ERROR_FOR_FIND_METHODS(binomial);
|
|
373
|
+
CTACH_LOGIC_ERROR_FOR_FIND_METHODS(geometric);
|
|
374
|
+
CTACH_LOGIC_ERROR_FOR_FIND_METHODS(negative_binomial);
|
|
375
|
+
#undef CTACH_LOGIC_ERROR_FOR_FIND_METHODS
|
|
376
|
+
|
|
377
|
+
CTACH_LOGIC_ERROR(chi_squared, find_degrees_of_freedom);
|
|
378
|
+
CTACH_LOGIC_ERROR(non_central_chi_squared, find_degrees_of_freedom);
|
|
379
|
+
CTACH_LOGIC_ERROR(students_t, find_degrees_of_freedom);
|
|
380
|
+
|
|
381
|
+
#undef CTACH_LOGIC_ERROR
|
|
382
|
+
|
|
383
|
+
%feature("autodoc", "1");
|
|
384
|
+
|
|
385
|
+
INSTANTIATE(arcsine, double, Arcsine, 105800);
|
|
386
|
+
INSTANTIATE(bernoulli, double, Bernoulli, 103500);
|
|
387
|
+
INSTANTIATE(beta, double, Beta, 103500);
|
|
388
|
+
INSTANTIATE(binomial, double, Binomial, 103500);
|
|
389
|
+
INSTANTIATE(cauchy, double, Cauchy, 103500);
|
|
390
|
+
INSTANTIATE(chi_squared, double, ChiSquared, 103500);
|
|
391
|
+
INSTANTIATE(exponential, double, Exponential, 103500);
|
|
392
|
+
INSTANTIATE(extreme_value, double, ExtremeValue, 103500);
|
|
393
|
+
INSTANTIATE(fisher_f, double, FisherF, 103500);
|
|
394
|
+
INSTANTIATE(gamma, double, Gamma, 103500);
|
|
395
|
+
INSTANTIATE(geometric, double, Geometric, 104600);
|
|
396
|
+
INSTANTIATE(hyperexponential, double, Hyperexponential, 105700);
|
|
397
|
+
INSTANTIATE(hypergeometric, double, Hypergeometric, 104000);
|
|
398
|
+
INSTANTIATE(inverse_chi_squared, double, InverseChiSquared, 104500);
|
|
399
|
+
INSTANTIATE(inverse_gamma, double, InverseGamma, 104500);
|
|
400
|
+
INSTANTIATE(inverse_gaussian, double, InverseGaussian, 104600);
|
|
401
|
+
INSTANTIATE(kolmogorov_smirnov, double, KolmogorovSmirnov, 107500);
|
|
402
|
+
INSTANTIATE(laplace, double, Laplace, 104000);
|
|
403
|
+
INSTANTIATE(logistic, double, Logistic, 104000);
|
|
404
|
+
INSTANTIATE(lognormal, double, Lognormal, 103500);
|
|
405
|
+
INSTANTIATE(negative_binomial, double, NegativeBinomial, 103500);
|
|
406
|
+
INSTANTIATE(non_central_beta, double, NonCentralBeta, 103600);
|
|
407
|
+
INSTANTIATE(non_central_chi_squared, double, NonCentralChiSquared, 103600);
|
|
408
|
+
INSTANTIATE(non_central_f, double, NonCentralF, 103600);
|
|
409
|
+
INSTANTIATE(non_central_t, double, NonCentralT, 103600);
|
|
410
|
+
INSTANTIATE(normal, double, Normal, 103500);
|
|
411
|
+
INSTANTIATE(pareto, double, Pareto, 103500);
|
|
412
|
+
INSTANTIATE(poisson, double, Poisson, 103500);
|
|
413
|
+
INSTANTIATE(rayleigh, double, Rayleigh, 103500);
|
|
414
|
+
INSTANTIATE(skew_normal, double, SkewNormal, 105000);
|
|
415
|
+
INSTANTIATE(students_t, double, StudentsT, 103500);
|
|
416
|
+
INSTANTIATE(triangular, double, Triangular, 103500);
|
|
417
|
+
INSTANTIATE(uniform, double, Uniform, 103500);
|
|
418
|
+
INSTANTIATE(weibull, double, Weibull, 103500);
|
|
419
|
+
|
|
420
|
+
#undef INSTANTIATE
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
SWIG = swig
|
|
2
|
+
SWIGFLAGS = -c++ -ruby $(shell if [ -n "$$MSYSTEM" ]; then echo -D__MINGW__; fi)
|
|
3
|
+
INCLUDES = -I../
|
|
4
|
+
BUILD_DIR = build_SWIG
|
|
5
|
+
|
|
6
|
+
RUBY = ruby
|
|
7
|
+
RUBY_CONF = extconf.rb
|
|
8
|
+
|
|
9
|
+
SRCS = $(shell ls *.i)
|
|
10
|
+
|
|
11
|
+
PACKAGES = $(SRCS:.i=.so)
|
|
12
|
+
|
|
13
|
+
all : $(BUILD_DIR) depend $(PACKAGES)
|
|
14
|
+
|
|
15
|
+
depend : INCLUDES+=-I$(shell echo $${MSYSTEM_PREFIX:-/usr})/include/
|
|
16
|
+
|
|
17
|
+
# �w�b�_�[�t�@�C���̈ˑ��W
|
|
18
|
+
depend : $(SRCS)
|
|
19
|
+
if [ -f $(BUILD_DIR)/depend.inc ]; then rm -f $(BUILD_DIR)/depend.inc; fi
|
|
20
|
+
for i in $^; do\
|
|
21
|
+
$(SWIG) $(SWIGFLAGS) $(INCLUDES) -MM -MP $$i | sed -e 's/[^\.]*\.cxx/$$\(BUILD_DIR\)\/&/g' >> $(BUILD_DIR)/depend.inc;\
|
|
22
|
+
done
|
|
23
|
+
|
|
24
|
+
-include $(BUILD_DIR)/depend.inc
|
|
25
|
+
|
|
26
|
+
$(PACKAGES) : $(patsubst %,$(BUILD_DIR)/%,$(PACKAGES))
|
|
27
|
+
|
|
28
|
+
$(BUILD_DIR)/BoostDistributions_wrap.cxx : INCLUDES+=-I$(shell echo $${MSYSTEM_PREFIX:-/usr})/include/
|
|
29
|
+
|
|
30
|
+
$(BUILD_DIR)/%_wrap.cxx : %.i
|
|
31
|
+
$(SWIG) $(SWIGFLAGS) $(INCLUDES) -o $@ $<
|
|
32
|
+
|
|
33
|
+
$(BUILD_DIR)/%.so : PACKAGE = $(shell echo $@ | sed -e 's/^$(BUILD_DIR)\/\([^\.]*\)\.so/\1/g')
|
|
34
|
+
$(BUILD_DIR)/%.so : $(BUILD_DIR)/%_wrap.cxx $(RUBY_CONF)
|
|
35
|
+
echo "building $(PACKAGE) ..."
|
|
36
|
+
if ! [ -d $(BUILD_DIR)/$(PACKAGE) ]; then mkdir $(BUILD_DIR)/$(PACKAGE); fi
|
|
37
|
+
cp $(RUBY_CONF) $(BUILD_DIR)/$(PACKAGE)/
|
|
38
|
+
cp $(BUILD_DIR)/$(PACKAGE)_wrap.cxx $(BUILD_DIR)/$(PACKAGE)/
|
|
39
|
+
cd $(BUILD_DIR)/$(PACKAGE); \
|
|
40
|
+
echo 'create_makefile("$(PACKAGE)")' >> $(RUBY_CONF); \
|
|
41
|
+
$(RUBY) $(RUBY_CONF); \
|
|
42
|
+
make; \
|
|
43
|
+
cp *.so ../
|
|
44
|
+
|
|
45
|
+
$(BUILD_DIR) :
|
|
46
|
+
mkdir $@
|
|
47
|
+
|
|
48
|
+
clean :
|
|
49
|
+
rm -rf $(BUILD_DIR)/*
|
|
50
|
+
|
|
51
|
+
run : all
|
|
52
|
+
|
|
53
|
+
.PHONY : clean all depend
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: boost_distributions
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- fenrir(M.Naruoka)
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-06-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '13.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '13.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake-compiler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: This is a Ruby gem to calculate statistical properties of various distributions
|
|
56
|
+
by using boost::math::distributions.
|
|
57
|
+
email:
|
|
58
|
+
- fenrir.naru@gmail.com
|
|
59
|
+
executables: []
|
|
60
|
+
extensions:
|
|
61
|
+
- ext/boost_distributions/extconf.rb
|
|
62
|
+
extra_rdoc_files: []
|
|
63
|
+
files:
|
|
64
|
+
- ".rspec"
|
|
65
|
+
- CHANGELOG.md
|
|
66
|
+
- CODE_OF_CONDUCT.md
|
|
67
|
+
- Gemfile
|
|
68
|
+
- LICENSE
|
|
69
|
+
- README.md
|
|
70
|
+
- Rakefile
|
|
71
|
+
- boost_distributions.gemspec
|
|
72
|
+
- ext/boost_distributions/BoostDistributions/BoostDistributions_wrap.cxx
|
|
73
|
+
- ext/boost_distributions/extconf.rb
|
|
74
|
+
- ext/ninja-scan-light/tool/swig/BoostDistributions.i
|
|
75
|
+
- ext/ninja-scan-light/tool/swig/extconf.rb
|
|
76
|
+
- ext/ninja-scan-light/tool/swig/makefile
|
|
77
|
+
- lib/boost_distributions.rb
|
|
78
|
+
- lib/boost_distributions/version.rb
|
|
79
|
+
- sig/boost_distributions.rbs
|
|
80
|
+
homepage: https://github.com/fenrir-naru/ruby-boost_distributions
|
|
81
|
+
licenses: []
|
|
82
|
+
metadata:
|
|
83
|
+
homepage_uri: https://github.com/fenrir-naru/ruby-boost_distributions
|
|
84
|
+
source_code_uri: https://github.com/fenrir-naru/ruby-boost_distributions
|
|
85
|
+
changelog_uri: https://github.com/fenrir-naru/ruby-boost_distributions/blob/main/CHANGELOG.md
|
|
86
|
+
post_install_message:
|
|
87
|
+
rdoc_options:
|
|
88
|
+
- "--exclude=ext/ninja-scan-light"
|
|
89
|
+
require_paths:
|
|
90
|
+
- lib
|
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: 2.6.0
|
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0'
|
|
101
|
+
requirements: []
|
|
102
|
+
rubygems_version: 3.3.5
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: Interface to boost::math::distributions
|
|
106
|
+
test_files: []
|