@stdlib/stats-base-dists-logistic-logcdf 0.2.2 → 0.3.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.
- package/NOTICE +1 -1
- package/README.md +112 -18
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/docs/types/index.d.ts +6 -6
- package/include/stdlib/stats/base/dists/logistic/logcdf.h +38 -0
- package/lib/index.js +1 -1
- package/lib/native.js +64 -0
- package/manifest.json +86 -0
- package/package.json +8 -3
- package/src/addon.c +23 -0
- package/src/main.c +70 -0
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -155,21 +155,111 @@ y = mylogcdf( 8.0 );
|
|
|
155
155
|
<!-- eslint no-undef: "error" -->
|
|
156
156
|
|
|
157
157
|
```javascript
|
|
158
|
-
var
|
|
158
|
+
var uniform = require( '@stdlib/random-array-uniform' );
|
|
159
|
+
var logEachMap = require( '@stdlib/console-log-each-map' );
|
|
159
160
|
var logcdf = require( '@stdlib/stats-base-dists-logistic-logcdf' );
|
|
160
161
|
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
var opts = {
|
|
163
|
+
'dtype': 'float64'
|
|
164
|
+
};
|
|
165
|
+
var x = uniform( 10, 0.0, 10.0, opts );
|
|
166
|
+
var mu = uniform( 10, 0.0, 10.0, opts );
|
|
167
|
+
var s = uniform( 10, 0.0, 10.0, opts );
|
|
168
|
+
|
|
169
|
+
logEachMap( 'x: %0.4f, µ: %0.4f, s: %0.4f, ln(F(x;µ,s)): %0.4f', x, mu, s, logcdf );
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
</section>
|
|
173
|
+
|
|
174
|
+
<!-- /.examples -->
|
|
175
|
+
|
|
176
|
+
<!-- C interface documentation. -->
|
|
177
|
+
|
|
178
|
+
* * *
|
|
179
|
+
|
|
180
|
+
<section class="c">
|
|
181
|
+
|
|
182
|
+
## C APIs
|
|
183
|
+
|
|
184
|
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
185
|
+
|
|
186
|
+
<section class="intro">
|
|
187
|
+
|
|
188
|
+
</section>
|
|
189
|
+
|
|
190
|
+
<!-- /.intro -->
|
|
191
|
+
|
|
192
|
+
<!-- C usage documentation. -->
|
|
193
|
+
|
|
194
|
+
<section class="usage">
|
|
195
|
+
|
|
196
|
+
### Usage
|
|
197
|
+
|
|
198
|
+
```c
|
|
199
|
+
#include "stdlib/stats/base/dists/logistic/logcdf.h"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### stdlib_base_dists_logistic_logcdf( x, mu, s )
|
|
203
|
+
|
|
204
|
+
Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.
|
|
205
|
+
|
|
206
|
+
```c
|
|
207
|
+
double out = stdlib_base_dists_logistic_logcdf( 2.0, 0.0, 1.0 );
|
|
208
|
+
// returns ~-0.127
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The function accepts the following arguments:
|
|
212
|
+
|
|
213
|
+
- **x**: `[in] double` input parameter.
|
|
214
|
+
- **mu**: `[in] double` location parameter.
|
|
215
|
+
- **s**: `[in] double` scale parameter.
|
|
216
|
+
|
|
217
|
+
```c
|
|
218
|
+
double stdlib_base_dists_logistic_logcdf( const double x, const double mu, const double s );
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
</section>
|
|
222
|
+
|
|
223
|
+
<!-- /.usage -->
|
|
224
|
+
|
|
225
|
+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
226
|
+
|
|
227
|
+
<section class="notes">
|
|
228
|
+
|
|
229
|
+
</section>
|
|
230
|
+
|
|
231
|
+
<!-- /.notes -->
|
|
232
|
+
|
|
233
|
+
<!-- C API usage examples. -->
|
|
234
|
+
|
|
235
|
+
<section class="examples">
|
|
236
|
+
|
|
237
|
+
### Examples
|
|
238
|
+
|
|
239
|
+
```c
|
|
240
|
+
#include "stdlib/stats/base/dists/logistic/logcdf.h"
|
|
241
|
+
#include <stdlib.h>
|
|
242
|
+
#include <stdio.h>
|
|
243
|
+
|
|
244
|
+
static double random_uniform( const double min, const double max ) {
|
|
245
|
+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
|
|
246
|
+
return min + ( v*(max-min) );
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
int main( void ) {
|
|
250
|
+
double mu;
|
|
251
|
+
double s;
|
|
252
|
+
double x;
|
|
253
|
+
double y;
|
|
254
|
+
int i;
|
|
255
|
+
|
|
256
|
+
for ( i = 0; i < 25; i++ ) {
|
|
257
|
+
mu = random_uniform( -5.0, 5.0 );
|
|
258
|
+
s = random_uniform( 0.0, 20.0 );
|
|
259
|
+
x = random_uniform( -10.0, 10.0 );
|
|
260
|
+
y = stdlib_base_dists_logistic_logcdf( x, mu, s );
|
|
261
|
+
printf( "x: %lf, µ: %lf, s: %lf, ln(F(x;µ,s)): %lf\n", x, mu, s, y );
|
|
262
|
+
}
|
|
173
263
|
}
|
|
174
264
|
```
|
|
175
265
|
|
|
@@ -177,6 +267,10 @@ for ( i = 0; i < 10; i++ ) {
|
|
|
177
267
|
|
|
178
268
|
<!-- /.examples -->
|
|
179
269
|
|
|
270
|
+
</section>
|
|
271
|
+
|
|
272
|
+
<!-- /.c -->
|
|
273
|
+
|
|
180
274
|
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
181
275
|
|
|
182
276
|
<section class="related">
|
|
@@ -206,7 +300,7 @@ For more information on the project, filing bug reports and feature requests, an
|
|
|
206
300
|
|
|
207
301
|
## Copyright
|
|
208
302
|
|
|
209
|
-
Copyright © 2016-
|
|
303
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
210
304
|
|
|
211
305
|
</section>
|
|
212
306
|
|
|
@@ -219,8 +313,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
219
313
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-base-dists-logistic-logcdf.svg
|
|
220
314
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-base-dists-logistic-logcdf
|
|
221
315
|
|
|
222
|
-
[test-image]: https://github.com/stdlib-js/stats-base-dists-logistic-logcdf/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
223
|
-
[test-url]: https://github.com/stdlib-js/stats-base-dists-logistic-logcdf/actions/workflows/test.yml?query=branch:v0.
|
|
316
|
+
[test-image]: https://github.com/stdlib-js/stats-base-dists-logistic-logcdf/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
317
|
+
[test-url]: https://github.com/stdlib-js/stats-base-dists-logistic-logcdf/actions/workflows/test.yml?query=branch:v0.3.0
|
|
224
318
|
|
|
225
319
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-base-dists-logistic-logcdf/main.svg
|
|
226
320
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-base-dists-logistic-logcdf?branch=main
|
|
@@ -232,8 +326,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
232
326
|
|
|
233
327
|
-->
|
|
234
328
|
|
|
235
|
-
[chat-image]: https://img.shields.io/
|
|
236
|
-
[chat-url]: https://
|
|
329
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
330
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
237
331
|
|
|
238
332
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
239
333
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="../docs/types/index.d.ts" />
|
|
2
|
-
import
|
|
3
|
-
export =
|
|
2
|
+
import logcdf from '../docs/types/index';
|
|
3
|
+
export = logcdf;
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/log1pexp.js", "../lib/main.js", "../lib/factory.js", "../lib/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of the [StatsFuns.jl]{@link https://github.com/JuliaStats/StatsFuns.jl/blob/master/src/basicfuns.jl} Julia package. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (c) 2015: Dahua Lin.\n*\n* Permission is hereby granted, free of charge, to any person obtaining\n* a copy of this software and associated documentation files (the\n* \"Software\"), to deal in the Software without restriction, including\n* without limitation the rights to use, copy, modify, merge, publish,\n* distribute, sublicense, and/or sell copies of the Software, and to\n* permit persons to whom the Software is furnished to do so, subject to\n* the following conditions:\n*\n* The above copyright notice and this permission notice shall be\n* included in all copies or substantial portions of the Software.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nvar log1p = require( '@stdlib/math-base-special-log1p' );\nvar exp = require( '@stdlib/math-base-special-exp' );\n\n\n// MAIN //\n\n/**\n* Compute ln( 1 + exp(x) ) without overflow.\n*\n* @private\n* @param {number} x - input value\n* @returns {number} function value\n*/\nfunction log1pexp( x ) {\n\tif ( x <= 18.0 ) {\n\t\treturn log1p( exp(x) );\n\t}\n\tif ( x > 33.3 ) {\n\t\treturn x;\n\t}\n\t// Case: 18.0 < x <= 33.3\n\treturn x + exp( -x );\n}\n\n\n// EXPORTS //\n\nmodule.exports = log1pexp;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\nvar log1pexp = require( './log1pexp.js' );\n\n\n// MAIN //\n\n/**\n* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.\n*\n* @param {number} x - input value\n* @param {number} mu - location parameter\n* @param {NonNegativeNumber} s - scale parameter\n* @returns {number} evaluated logCDF\n*\n* @example\n* var y = logcdf( 2.0, 0.0, 1.0 );\n* // returns ~-0.127\n*\n* @example\n* var y = logcdf( 5.0, 10.0, 3.0 );\n* // returns ~-1.84\n*\n* @example\n* var y = logcdf( 2.0, 0.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 2, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( NaN, 0.0, 1.0 );\n* // returns NaN\n*/\nfunction logcdf( x, mu, s ) {\n\tvar z;\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( mu ) ||\n\t\tisnan( s ) ||\n\t\ts < 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( s === 0.0 ) {\n\t\treturn ( x < mu ) ? NINF : 0.0;\n\t}\n\tz = ( x - mu ) / s;\n\treturn -log1pexp( -z );\n}\n\n\n// EXPORTS //\n\nmodule.exports = logcdf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar degenerate = require( '@stdlib/stats-base-dists-degenerate-logcdf' ).factory;\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar log1pexp = require( './log1pexp.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s`.\n*\n* @param {number} mu - location parameter\n* @param {NonNegativeNumber} s - scale parameter\n* @returns {Function} logCDF\n*\n* @example\n* var logcdf = factory( 3.0, 1.5 );\n*\n* var y = logcdf( 1.0 );\n* // returns ~-1.567\n*\n* y = logcdf( 4.0 );\n* // returns ~-0.414\n*/\nfunction factory( mu, s ) {\n\tif ( isnan( mu ) || isnan( s ) || s < 0.0 ) {\n\t\treturn constantFunction( NaN );\n\t}\n\tif ( s === 0.0 ) {\n\t\treturn degenerate( mu );\n\t}\n\treturn logcdf;\n\n\t/**\n\t* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {number} evaluated logCDF\n\t*\n\t* @example\n\t* var y = logcdf( 2.0 );\n\t* // returns <number>\n\t*/\n\tfunction logcdf( x ) {\n\t\tvar z;\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tz = ( x - mu ) / s;\n\t\treturn -log1pexp( -z );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Logistic distribution logarithm of cumulative distribution function (CDF).\n*\n* @module @stdlib/stats-base-dists-logistic-logcdf\n*\n* @example\n* var logcdf = require( '@stdlib/stats-base-dists-logistic-logcdf' );\n*\n* var y = logcdf( 2.0, 0.0, 1.0 );\n* // returns ~-0.127\n*\n* var mylogcdf = logcdf.factory( 3.0, 1.5 );\n*\n* var y = mylogcdf( 1.0 );\n* // returns ~-1.
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of the [StatsFuns.jl]{@link https://github.com/JuliaStats/StatsFuns.jl/blob/master/src/basicfuns.jl} Julia package. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (c) 2015: Dahua Lin.\n*\n* Permission is hereby granted, free of charge, to any person obtaining\n* a copy of this software and associated documentation files (the\n* \"Software\"), to deal in the Software without restriction, including\n* without limitation the rights to use, copy, modify, merge, publish,\n* distribute, sublicense, and/or sell copies of the Software, and to\n* permit persons to whom the Software is furnished to do so, subject to\n* the following conditions:\n*\n* The above copyright notice and this permission notice shall be\n* included in all copies or substantial portions of the Software.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nvar log1p = require( '@stdlib/math-base-special-log1p' );\nvar exp = require( '@stdlib/math-base-special-exp' );\n\n\n// MAIN //\n\n/**\n* Compute ln( 1 + exp(x) ) without overflow.\n*\n* @private\n* @param {number} x - input value\n* @returns {number} function value\n*/\nfunction log1pexp( x ) {\n\tif ( x <= 18.0 ) {\n\t\treturn log1p( exp(x) );\n\t}\n\tif ( x > 33.3 ) {\n\t\treturn x;\n\t}\n\t// Case: 18.0 < x <= 33.3\n\treturn x + exp( -x );\n}\n\n\n// EXPORTS //\n\nmodule.exports = log1pexp;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar NINF = require( '@stdlib/constants-float64-ninf' );\nvar log1pexp = require( './log1pexp.js' );\n\n\n// MAIN //\n\n/**\n* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.\n*\n* @param {number} x - input value\n* @param {number} mu - location parameter\n* @param {NonNegativeNumber} s - scale parameter\n* @returns {number} evaluated logCDF\n*\n* @example\n* var y = logcdf( 2.0, 0.0, 1.0 );\n* // returns ~-0.127\n*\n* @example\n* var y = logcdf( 5.0, 10.0, 3.0 );\n* // returns ~-1.84\n*\n* @example\n* var y = logcdf( 2.0, 0.0, NaN );\n* // returns NaN\n*\n* @example\n* var y = logcdf( 2, NaN, 1.0 );\n* // returns NaN\n*\n* @example\n* var y = logcdf( NaN, 0.0, 1.0 );\n* // returns NaN\n*/\nfunction logcdf( x, mu, s ) {\n\tvar z;\n\tif (\n\t\tisnan( x ) ||\n\t\tisnan( mu ) ||\n\t\tisnan( s ) ||\n\t\ts < 0.0\n\t) {\n\t\treturn NaN;\n\t}\n\tif ( s === 0.0 ) {\n\t\treturn ( x < mu ) ? NINF : 0.0;\n\t}\n\tz = ( x - mu ) / s;\n\treturn -log1pexp( -z );\n}\n\n\n// EXPORTS //\n\nmodule.exports = logcdf;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar constantFunction = require( '@stdlib/utils-constant-function' );\nvar degenerate = require( '@stdlib/stats-base-dists-degenerate-logcdf' ).factory;\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar log1pexp = require( './log1pexp.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for evaluating the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s`.\n*\n* @param {number} mu - location parameter\n* @param {NonNegativeNumber} s - scale parameter\n* @returns {Function} logCDF\n*\n* @example\n* var logcdf = factory( 3.0, 1.5 );\n*\n* var y = logcdf( 1.0 );\n* // returns ~-1.567\n*\n* y = logcdf( 4.0 );\n* // returns ~-0.414\n*/\nfunction factory( mu, s ) {\n\tif ( isnan( mu ) || isnan( s ) || s < 0.0 ) {\n\t\treturn constantFunction( NaN );\n\t}\n\tif ( s === 0.0 ) {\n\t\treturn degenerate( mu );\n\t}\n\treturn logcdf;\n\n\t/**\n\t* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution.\n\t*\n\t* @private\n\t* @param {number} x - input value\n\t* @returns {number} evaluated logCDF\n\t*\n\t* @example\n\t* var y = logcdf( 2.0 );\n\t* // returns <number>\n\t*/\n\tfunction logcdf( x ) {\n\t\tvar z;\n\t\tif ( isnan( x ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tz = ( x - mu ) / s;\n\t\treturn -log1pexp( -z );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Logistic distribution logarithm of cumulative distribution function (CDF).\n*\n* @module @stdlib/stats-base-dists-logistic-logcdf\n*\n* @example\n* var logcdf = require( '@stdlib/stats-base-dists-logistic-logcdf' );\n*\n* var y = logcdf( 2.0, 0.0, 1.0 );\n* // returns ~-0.127\n*\n* var mylogcdf = logcdf.factory( 3.0, 1.5 );\n*\n* var y = mylogcdf( 1.0 );\n* // returns ~-1.567\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
5
|
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAkDA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAM,QAAS,+BAAgC,EAYnD,SAASC,EAAUC,EAAI,CACtB,OAAKA,GAAK,GACFH,EAAOC,EAAIE,CAAC,CAAE,EAEjBA,EAAI,KACDA,EAGDA,EAAIF,EAAK,CAACE,CAAE,CACpB,CAKAJ,EAAO,QAAUG,IC7EjB,IAAAE,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,iCAAkC,EACnDC,EAAO,QAAS,gCAAiC,EACjDC,EAAW,IAiCf,SAASC,EAAQC,EAAGC,EAAIC,EAAI,CAC3B,IAAIC,EACJ,OACCP,EAAOI,CAAE,GACTJ,EAAOK,CAAG,GACVL,EAAOM,CAAE,GACTA,EAAI,EAEG,IAEHA,IAAM,EACDF,EAAIC,EAAOJ,EAAO,GAE5BM,GAAMH,EAAIC,GAAOC,EACV,CAACJ,EAAU,CAACK,CAAE,EACtB,CAKAR,EAAO,QAAUI,IC7EjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,iCAAkC,EAC9DC,EAAa,QAAS,4CAA6C,EAAE,QACrEC,EAAQ,QAAS,iCAAkC,EACnDC,EAAW,IAqBf,SAASC,EAASC,EAAIC,EAAI,CACzB,GAAKJ,EAAOG,CAAG,GAAKH,EAAOI,CAAE,GAAKA,EAAI,EACrC,OAAON,EAAkB,GAAI,EAE9B,GAAKM,IAAM,EACV,OAAOL,EAAYI,CAAG,EAEvB,OAAOE,EAaP,SAASA,EAAQC,EAAI,CACpB,IAAIC,EACJ,OAAKP,EAAOM,CAAE,EACN,KAERC,GAAMD,EAAIH,GAAOC,EACV,CAACH,EAAU,CAACM,CAAE,EACtB,CACD,CAKAV,EAAO,QAAUK,ICxCjB,IAAIM,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
|
|
6
6
|
"names": ["require_log1pexp", "__commonJSMin", "exports", "module", "log1p", "exp", "log1pexp", "x", "require_main", "__commonJSMin", "exports", "module", "isnan", "NINF", "log1pexp", "logcdf", "x", "mu", "s", "z", "require_factory", "__commonJSMin", "exports", "module", "constantFunction", "degenerate", "isnan", "log1pexp", "factory", "mu", "s", "logcdf", "x", "z", "setReadOnly", "main", "factory"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -93,21 +93,21 @@ interface LogCDF {
|
|
|
93
93
|
*
|
|
94
94
|
* @example
|
|
95
95
|
* var y = logcdf( 10.0, 0.0, 3.0 );
|
|
96
|
-
* // returns ~-0.
|
|
96
|
+
* // returns ~-0.035
|
|
97
97
|
*
|
|
98
98
|
* y = logcdf( 0.0, 0.0, 3.0 );
|
|
99
|
-
* // returns ~-
|
|
99
|
+
* // returns ~-0.693
|
|
100
100
|
*
|
|
101
101
|
* var mylogcdf = logcdf.factory( 2.0, 3.0 );
|
|
102
102
|
* y = mylogcdf( 10.0 );
|
|
103
|
-
* // returns ~-0.
|
|
103
|
+
* // returns ~-0.067
|
|
104
104
|
*
|
|
105
105
|
* y = mylogcdf( 2.0 );
|
|
106
|
-
* // returns ~-
|
|
106
|
+
* // returns ~-0.693
|
|
107
107
|
*/
|
|
108
|
-
declare var
|
|
108
|
+
declare var logcdf: LogCDF;
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
// EXPORTS //
|
|
112
112
|
|
|
113
|
-
export =
|
|
113
|
+
export = logcdf;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef STDLIB_STATS_BASE_DISTS_LOGISTIC_LOGCDF_H
|
|
20
|
+
#define STDLIB_STATS_BASE_DISTS_LOGISTIC_LOGCDF_H
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
24
|
+
*/
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.
|
|
31
|
+
*/
|
|
32
|
+
double stdlib_base_dists_logistic_logcdf( const double x, const double mu, const double s );
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // !STDLIB_STATS_BASE_DISTS_LOGISTIC_LOGCDF_H
|
package/lib/index.js
CHANGED
package/lib/native.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var addon = require( './../src/addon.node' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param {number} x - input value
|
|
33
|
+
* @param {number} mu - location parameter
|
|
34
|
+
* @param {NonNegativeNumber} s - scale parameter
|
|
35
|
+
* @returns {number} evaluated logCDF
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var y = logcdf( 2.0, 0.0, 1.0 );
|
|
39
|
+
* // returns ~-0.127
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var y = logcdf( 5.0, 10.0, 3.0 );
|
|
43
|
+
* // returns ~-1.84
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* var y = logcdf( 2.0, 0.0, NaN );
|
|
47
|
+
* // returns NaN
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* var y = logcdf( 2, NaN, 1.0 );
|
|
51
|
+
* // returns NaN
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var y = logcdf( NaN, 0.0, 1.0 );
|
|
55
|
+
* // returns NaN
|
|
56
|
+
*/
|
|
57
|
+
function logcdf( x, mu, s ) {
|
|
58
|
+
return addon( x, mu, s );
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
// EXPORTS //
|
|
63
|
+
|
|
64
|
+
module.exports = logcdf;
|
package/manifest.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"options": {
|
|
3
|
+
"task": "build",
|
|
4
|
+
"wasm": false
|
|
5
|
+
},
|
|
6
|
+
"fields": [
|
|
7
|
+
{
|
|
8
|
+
"field": "src",
|
|
9
|
+
"resolve": true,
|
|
10
|
+
"relative": true
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"field": "include",
|
|
14
|
+
"resolve": true,
|
|
15
|
+
"relative": true
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"field": "libraries",
|
|
19
|
+
"resolve": false,
|
|
20
|
+
"relative": false
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"field": "libpath",
|
|
24
|
+
"resolve": true,
|
|
25
|
+
"relative": false
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"confs": [
|
|
29
|
+
{
|
|
30
|
+
"task": "build",
|
|
31
|
+
"wasm": false,
|
|
32
|
+
"src": [
|
|
33
|
+
"./src/main.c"
|
|
34
|
+
],
|
|
35
|
+
"include": [
|
|
36
|
+
"./include"
|
|
37
|
+
],
|
|
38
|
+
"libraries": [],
|
|
39
|
+
"libpath": [],
|
|
40
|
+
"dependencies": [
|
|
41
|
+
"@stdlib/math-base-napi-ternary",
|
|
42
|
+
"@stdlib/math-base-assert-is-nan",
|
|
43
|
+
"@stdlib/math-base-special-log1p",
|
|
44
|
+
"@stdlib/math-base-special-exp",
|
|
45
|
+
"@stdlib/constants-float64-ninf"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"task": "benchmark",
|
|
50
|
+
"wasm": false,
|
|
51
|
+
"src": [
|
|
52
|
+
"./src/main.c"
|
|
53
|
+
],
|
|
54
|
+
"include": [
|
|
55
|
+
"./include"
|
|
56
|
+
],
|
|
57
|
+
"libraries": [],
|
|
58
|
+
"libpath": [],
|
|
59
|
+
"dependencies": [
|
|
60
|
+
"@stdlib/math-base-assert-is-nan",
|
|
61
|
+
"@stdlib/math-base-special-log1p",
|
|
62
|
+
"@stdlib/math-base-special-exp",
|
|
63
|
+
"@stdlib/constants-float64-eps",
|
|
64
|
+
"@stdlib/constants-float64-ninf"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"task": "examples",
|
|
69
|
+
"wasm": false,
|
|
70
|
+
"src": [
|
|
71
|
+
"./src/main.c"
|
|
72
|
+
],
|
|
73
|
+
"include": [
|
|
74
|
+
"./include"
|
|
75
|
+
],
|
|
76
|
+
"libraries": [],
|
|
77
|
+
"libpath": [],
|
|
78
|
+
"dependencies": [
|
|
79
|
+
"@stdlib/math-base-assert-is-nan",
|
|
80
|
+
"@stdlib/math-base-special-log1p",
|
|
81
|
+
"@stdlib/math-base-special-exp",
|
|
82
|
+
"@stdlib/constants-float64-ninf"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-base-dists-logistic-logcdf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Logistic distribution logarithm of cumulative distribution function (CDF).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
16
|
"main": "./lib",
|
|
17
|
+
"gypfile": false,
|
|
17
18
|
"directories": {
|
|
18
19
|
"doc": "./docs",
|
|
20
|
+
"include": "./include",
|
|
19
21
|
"lib": "./lib",
|
|
22
|
+
"src": "./src",
|
|
20
23
|
"dist": "./dist"
|
|
21
24
|
},
|
|
22
25
|
"types": "./docs/types",
|
|
@@ -32,11 +35,13 @@
|
|
|
32
35
|
"dependencies": {
|
|
33
36
|
"@stdlib/constants-float64-ninf": "^0.2.2",
|
|
34
37
|
"@stdlib/math-base-assert-is-nan": "^0.2.2",
|
|
38
|
+
"@stdlib/math-base-napi-ternary": "^0.3.1",
|
|
35
39
|
"@stdlib/math-base-special-exp": "^0.2.4",
|
|
36
40
|
"@stdlib/math-base-special-log1p": "^0.2.3",
|
|
37
|
-
"@stdlib/stats-base-dists-degenerate-logcdf": "^0.
|
|
41
|
+
"@stdlib/stats-base-dists-degenerate-logcdf": "^0.3.0",
|
|
38
42
|
"@stdlib/utils-constant-function": "^0.2.2",
|
|
39
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2"
|
|
43
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
|
|
44
|
+
"@stdlib/utils-library-manifest": "^0.2.3"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {},
|
|
42
47
|
"engines": {
|
package/src/addon.c
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#include "stdlib/stats/base/dists/logistic/logcdf.h"
|
|
20
|
+
#include "stdlib/math/base/napi/ternary.h"
|
|
21
|
+
|
|
22
|
+
// cppcheck-suppress shadowFunction
|
|
23
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_logistic_logcdf )
|
package/src/main.c
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#include "stdlib/stats/base/dists/logistic/logcdf.h"
|
|
20
|
+
#include "stdlib/math/base/assert/is_nan.h"
|
|
21
|
+
#include "stdlib/constants/float64/ninf.h"
|
|
22
|
+
#include "stdlib/math/base/special/log1p.h"
|
|
23
|
+
#include "stdlib/math/base/special/exp.h"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Computes `log(1 + exp(x))` in a numerically stable manner.
|
|
27
|
+
*
|
|
28
|
+
* @param x input value
|
|
29
|
+
* @return log(1 + exp(x))
|
|
30
|
+
*/
|
|
31
|
+
static double log1pexp( const double x ) {
|
|
32
|
+
if ( x <= 18.0 ) {
|
|
33
|
+
return stdlib_base_log1p( stdlib_base_exp( x ) );
|
|
34
|
+
}
|
|
35
|
+
if ( x > 33.3 ) {
|
|
36
|
+
return x;
|
|
37
|
+
}
|
|
38
|
+
// Case: 18.0 < z <= 33.3
|
|
39
|
+
return x + stdlib_base_exp( -x );
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Evaluates the logarithm of the cumulative distribution function (CDF) for a logistic distribution with location parameter `mu` and scale parameter `s` at a value `x`.
|
|
44
|
+
*
|
|
45
|
+
* @param x input value
|
|
46
|
+
* @param mu location parameter
|
|
47
|
+
* @param s scale parameter
|
|
48
|
+
* @return evaluated logCDF
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* double y = stdlib_base_dists_logistic_logcdf( 2.0, 0.0, 1.0 );
|
|
52
|
+
* // returns ~-0.127
|
|
53
|
+
*/
|
|
54
|
+
double stdlib_base_dists_logistic_logcdf( const double x, const double mu, const double s ) {
|
|
55
|
+
double z;
|
|
56
|
+
if (
|
|
57
|
+
stdlib_base_is_nan( x ) ||
|
|
58
|
+
stdlib_base_is_nan( mu ) ||
|
|
59
|
+
stdlib_base_is_nan( s ) ||
|
|
60
|
+
s < 0.0
|
|
61
|
+
) {
|
|
62
|
+
return 0.0 / 0.0; // NaN
|
|
63
|
+
}
|
|
64
|
+
if ( s == 0.0 ) {
|
|
65
|
+
return ( x < mu ) ? STDLIB_CONSTANT_FLOAT64_NINF : 0.0;
|
|
66
|
+
}
|
|
67
|
+
z = ( x - mu ) / s;
|
|
68
|
+
return -log1pexp( -z );
|
|
69
|
+
}
|
|
70
|
+
|