File: stats.cpp

package info (click to toggle)
rcpp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,480 kB
  • sloc: cpp: 27,436; ansic: 7,778; sh: 53; makefile: 2
file content (255 lines) | stat: -rw-r--r-- 7,874 bytes parent folder | download | duplicates (8)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//
// stats.cpp: Rcpp R/C++ interface class library -- stats unit tests
//
// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
// Rcpp is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Rcpp 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 Rcpp.  If not, see <http://www.gnu.org/licenses/>.

#include <Rcpp.h>
using namespace Rcpp ;

// [[Rcpp::export]]
List runit_dbeta(NumericVector xx, double aa, double bb){
    return List::create(
        _["NoLog"] = dbeta( xx, aa, bb),
        _["Log"]	 = dbeta( xx, aa, bb, true )
    );
}

// [[Rcpp::export]]
List runit_dbinom( IntegerVector xx ){
    return List::create(
        _["false"] = dbinom( xx, 10, .5),
        _["true"]	 = dbinom( xx, 10, .5, true )
    );
}

// [[Rcpp::export]]
List runit_dunif( NumericVector xx){
    return List::create(
        _["NoLog_noMin_noMax"] = dunif( xx ),
        _["NoLog_noMax"] = dunif( xx, 0.0 ),
        _["NoLog"] = dunif( xx, 0.0 , 1.0 ),
        _["Log"]	= dunif( xx, 0.0, 1.0 , true ),
        _["Log_noMax"]	= dunif( xx, 0.0, true )
        //,_["Log_noMin_noMax"]	= dunif( xx, true )
    );
}

// [[Rcpp::export]]
List runit_dgamma( NumericVector xx ){
    return List::create(
        _["NoLog"] = dgamma( xx, 1.0, 1.0),
        _["Log"]	 = dgamma( xx, 1.0, 1.0, true ),
        _["Log_noRate"]	 = dgamma( xx, 1.0, true )
        );
}

// [[Rcpp::export]]
List runit_dpois( IntegerVector xx ){
    return List::create(
        _["false"] = dpois( xx, .5 ),
        _["true"]	 = dpois( xx, .5 , true)
        );
}

// [[Rcpp::export]]
List runit_dnorm( NumericVector xx ){
    return List::create(
        _["false_noMean_noSd"] = dnorm( xx ),
        _["false_noSd"] = dnorm( xx, 0.0  ),
        _["false"] = dnorm( xx, 0.0, 1.0 ),
        _["true"]	 = dnorm( xx, 0.0, 1.0, true ),
        _["true_noSd"]	 = dnorm( xx, 0.0, true ),
        _["true_noMean_noSd"]	 = dnorm( xx, true )
        );
}

// [[Rcpp::export]]
List runit_dt( NumericVector xx){
    return List::create(
        _["false"] = dt( xx, 5),
        _["true"]	 = dt( xx, 5, true ));
}

// [[Rcpp::export]]
List runit_pbeta( NumericVector xx, double aa, double bb ){
    return List::create(
        _["lowerNoLog"] = pbeta( xx, aa, bb),
        _["lowerLog"]	  = pbeta( xx, aa, bb, true, true),
        _["upperNoLog"] = pbeta( xx, aa, bb, false),
        _["upperLog"]	  = pbeta( xx, aa, bb, false, true)
    );
}

// [[Rcpp::export]]
List runit_pbinom( NumericVector xx, int n, double p){
    return List::create(
        _["lowerNoLog"] = pbinom(xx, n, p ),
        _["lowerLog"]	  = pbinom(xx, n, p, true, true ),
        _["upperNoLog"] = pbinom(xx, n, p, false ),
        _["upperLog"]	  = pbinom(xx, n, p, false, true )
    );
}

// [[Rcpp::export]]
List runit_pcauchy( NumericVector xx, double loc, double scl){
    return List::create(
        _["lowerNoLog"] = pcauchy(xx, loc, scl ),
        _["lowerLog"]	  = pcauchy(xx, loc, scl, true, true ),
        _["upperNoLog"] = pcauchy(xx, loc, scl, false ),
        _["upperLog"]	  = pcauchy(xx, loc, scl, false, true )
    );
}

// [[Rcpp::export]]
List runit_punif( NumericVector xx ){
    return List::create(
        _["lowerNoLog"] = punif( xx, 0.0, 1.0 ),
        _["lowerLog"]   = punif( xx, 0.0, 1.0, true, true ),
        _["upperNoLog"] = punif( xx, 0.0, 1.0, false ),
        _["upperLog"]   = punif( xx, 0.0, 1.0, false, true )
    );
}

// [[Rcpp::export]]
List runit_pgamma( NumericVector xx ){
    return List::create(
        _["lowerNoLog"] = pgamma( xx, 2.0, 1.0 ),
        _["lowerLog"]	  = pgamma( xx, 2.0, 1.0, true, true ),
        _["upperNoLog"] = pgamma( xx, 2.0, 1.0, false ),
        _["upperLog"]	  = pgamma( xx, 2.0, 1.0, false, true )
        );
}

// [[Rcpp::export]]
List runit_pnf( NumericVector xx ){
    return List::create(
        _["lowerNoLog"] = pnf( xx, 6.0, 8.0, 2.5, true ),
        _["lowerLog"]	  = pnf( xx, 6.0, 8.0, 2.5, true, true ),
        _["upperNoLog"] = pnf( xx, 6.0, 8.0, 2.5, false ),
        _["upperLog"]	  = pnf( xx, 6.0, 8.0, 2.5, false, true )
        );
}

// [[Rcpp::export]]
List runit_pf( NumericVector xx ){
    return List::create(
        _["lowerNoLog"] = pf( xx, 6.0, 8.0 ),
        _["lowerLog"]	  = pf( xx, 6.0, 8.0, true, true ),
        _["upperNoLog"] = pf( xx, 6.0, 8.0, false ),
        _["upperLog"]	  = pf( xx, 6.0, 8.0, false, true )
    );
}

// [[Rcpp::export]]
List runit_pnchisq( NumericVector xx ){
    return List::create(
        _["lowerNoLog"] = pnchisq( xx, 6.0, 2.5, true ),
        _["lowerLog"]	  = pnchisq( xx, 6.0, 2.5, true, true ),
        _["upperNoLog"] = pnchisq( xx, 6.0, 2.5, false ),
        _["upperLog"]	  = pnchisq( xx, 6.0, 2.5, false, true )
        );
}

// [[Rcpp::export]]
List runit_pchisq( NumericVector xx){
    return List::create(
        _["lowerNoLog"] = pchisq( xx, 6.0 ),
        _["lowerLog"]	  = pchisq( xx, 6.0, true, true ),
        _["upperNoLog"] = pchisq( xx, 6.0, false ),
        _["upperLog"]	  = pchisq( xx, 6.0, false, true )
    );
}

// [[Rcpp::export]]
List runit_pnorm( NumericVector xx ){
    return List::create(
        _["lowerNoLog"] = pnorm( xx, 0.0, 1.0 ),
        _["lowerLog"]	  = pnorm( xx, 0.0, 1.0, true, true ),
        _["upperNoLog"] = pnorm( xx, 0.0, 1.0, false ),
        _["upperLog"]	  = pnorm( xx, 0.0, 1.0, false, true )
        );
}

// [[Rcpp::export]]
List runit_ppois( NumericVector xx){
    return List::create(
        _["lowerNoLog"] = ppois( xx, 0.5 ),
        _["lowerLog"]	  = ppois( xx, 0.5, true, true ),
        _["upperNoLog"] = ppois( xx, 0.5, false ),
        _["upperLog"]	  = ppois( xx, 0.5, false, true )
        );
}

// [[Rcpp::export]]
List runit_pt(NumericVector xx){
    return List::create(_["lowerNoLog"] = pt( xx, 5 /*true,    false*/),
			_["lowerLog"]   = pt( xx, 5,  true,    true),
			_["upperNoLog"] = pt( xx, 5,  false /*,false*/),
			_["upperLog"]   = pt( xx, 5,  false,   true)    );
}

// [[Rcpp::export]]
List runit_pnt(NumericVector xx){
    return List::create(_["lowerNoLog"] = pnt( xx, 5, 7  /*true,    false*/),
			_["lowerLog"]   = pnt( xx, 5, 7,   true,    true),
			_["upperNoLog"] = pnt( xx, 5, 7,   false /*,false*/),
			_["upperLog"]   = pnt( xx, 5, 7,   false,   true)    );
}

// [[Rcpp::export]]
List runit_qbinom_prob( NumericVector xx, int n, double p){
    return List::create(
        _["lower"] = qbinom( xx, n, p ),
        _["upper"] = qbinom( xx, n, p, false)
        );
}

// [[Rcpp::export]]
List runit_qunif_prob( NumericVector xx ){
    return List::create(
        _["lower"] = qunif( xx, 0.0, 1.0 ),
        _["upper"] = qunif( xx, 0.0, 1.0, false)
        );
}

// [[Rcpp::export]]
List runit_qnorm_prob( NumericVector xx ){
    return List::create(
        _["lower"] = qnorm( xx, 0.0, 1.0 ),
        _["upper"] = qnorm( xx, 0.0, 1.0, false));
}

// [[Rcpp::export]]
List runit_qnorm_log( NumericVector xx ){
    return List::create(
        _["lower"] = qnorm( xx, 0.0, 1.0, true, true),
        _["upper"] = qnorm( xx, 0.0, 1.0, false, true));
}

// [[Rcpp::export]]
List runit_qpois_prob( NumericVector xx ){
    return List::create(
        _["lower"] = qpois( xx, 0.5 ),
        _["upper"] = qpois( xx, 0.5, false));
}

// [[Rcpp::export]]
NumericVector runit_qt( NumericVector xx, double d, bool lt, bool lg ){
    return qt( xx, d, lt, lg);
}