Skip to content

Commit 8a70a7b

Browse files
feat(add c implementation): add stats/base/dists/bernoulli/mode
1 parent cc6394d commit 8a70a7b

File tree

11 files changed

+106
-35
lines changed

11 files changed

+106
-35
lines changed

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,91 @@ for ( i = 0; i < 10; i++ ) {
137137

138138
<!-- /.references -->
139139

140+
<!-- C interface documentation. -->
141+
142+
* * *
143+
144+
<section class="c">
145+
146+
## C APIs
147+
148+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
149+
150+
<section class="intro">
151+
152+
</section>
153+
154+
<!-- /.intro -->
155+
156+
<!-- C usage documentation. -->
157+
158+
<section class="usage">
159+
160+
### Usage
161+
162+
```c
163+
#include "stdlib/stats/base/dists/bernoulli/mode.h"
164+
```
165+
166+
#### stdlib_base_dists_bernoulli_mode( p )
167+
168+
Returns the [mode][mode] of a [Bernoulli][bernoulli-distribution] distribution with success probability `p`.
169+
170+
```c
171+
double out = stdlib_base_dists_bernoulli_mode( 0.1 );
172+
// returns ~0.325
173+
```
174+
175+
The function accepts the following arguments:
176+
177+
- **p**: `[in] double` maximum support
178+
179+
```c
180+
double stdlib_base_dists_bernoulli_mode( const double p );
181+
```
182+
183+
</section>
184+
185+
<!-- /.usage -->
186+
187+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
188+
189+
<section class="notes">
190+
191+
</section>
192+
193+
<!-- /.notes -->
194+
195+
<!-- C API usage examples. -->
196+
197+
<section class="examples">
198+
199+
### Examples
200+
201+
```c
202+
#include "stdlib/stats/base/dists/bernoulli/mode.h"
203+
#include <stdlib.h>
204+
#include <stdio.h>
205+
int main( void ) {
206+
double p;
207+
double y;
208+
int i;
209+
for ( i = 0; i < 25; i++ ) {
210+
p = ( (double)rand() / (double)RAND_MAX );
211+
y = stdlib_base_dists_arcsine_mode( p );
212+
printf( "x: %lf, M(X;p): %lf\n", p, y );
213+
}
214+
}
215+
```
216+
217+
</section>
218+
219+
<!-- /.examples -->
220+
221+
</section>
222+
223+
<!-- /.c -->
224+
140225
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
141226

142227
<section class="related">

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/benchmark/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/benchmark/c/benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ int main( void ) {
130130
printf( "ok %d benchmark finished\n", i+1 );
131131
}
132132
print_summary( REPEATS, REPEATS );
133-
}
133+
}

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/examples/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,4 @@ run: $(c_targets)
143143
clean:
144144
$(QUIET) -rm -f *.o *.out
145145

146-
.PHONY: clean
146+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/examples/c/example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ int main( void ) {
2626
int i;
2727

2828
for ( i = 0; i < 25; i++ ) {
29-
p = ( (double)rand() / (double)RAND_MAX ) ;
29+
p = ( (double)rand() / (double)RAND_MAX );
3030
y = stdlib_base_dists_bernoulli_mode( p );
3131
printf( "x: %lf , H(X;p): %lf\n", p , y );
3232
}
33-
}
33+
}

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/lib/native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ function mode( p ) {
5858

5959
// EXPORTS //
6060

61-
module.exports = mode;
61+
module.exports = mode;

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/manifest.json

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@
3939
"libpath": [],
4040
"dependencies": [
4141
"@stdlib/math/base/napi/ternary",
42-
"@stdlib/math/base/assert/is-nan",
43-
"@stdlib/math/base/special/ln",
44-
"@stdlib/constants/float64/ln-pi",
45-
"@stdlib/constants/float64/ln-two",
46-
"@stdlib/constants/float64/ninf",
47-
"@stdlib/math/base/special/asin",
48-
"@stdlib/math/base/special/sqrt"
42+
"@stdlib/math/base/assert/is-nan"
4943
]
5044
},
5145
{
@@ -60,13 +54,7 @@
6054
"libraries": [],
6155
"libpath": [],
6256
"dependencies": [
63-
"@stdlib/math/base/assert/is-nan",
64-
"@stdlib/math/base/special/ln",
65-
"@stdlib/constants/float64/ln-pi",
66-
"@stdlib/constants/float64/ln-two",
67-
"@stdlib/constants/float64/ninf",
68-
"@stdlib/math/base/special/asin",
69-
"@stdlib/math/base/special/sqrt"
57+
"@stdlib/math/base/assert/is-nan"
7058
]
7159
},
7260
{
@@ -81,14 +69,9 @@
8169
"libraries": [],
8270
"libpath": [],
8371
"dependencies": [
84-
"@stdlib/math/base/assert/is-nan",
85-
"@stdlib/math/base/special/ln",
86-
"@stdlib/constants/float64/ln-pi",
87-
"@stdlib/constants/float64/ln-two",
88-
"@stdlib/constants/float64/ninf",
89-
"@stdlib/math/base/special/asin",
90-
"@stdlib/math/base/special/sqrt"
72+
"@stdlib/math/base/assert/is-nan"
9173
]
9274
}
9375
]
94-
}
76+
}
77+

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
}
1515
],
1616
"main": "./lib",
17+
"gypfile": true,
1718
"directories": {
1819
"benchmark": "./benchmark",
1920
"doc": "./docs",
2021
"example": "./examples",
22+
"include": "./include",
2123
"lib": "./lib",
24+
"src": "./src",
2225
"test": "./test"
2326
},
2427
"types": "./docs/types",

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ clean-addon:
6767
#/
6868
clean: clean-addon
6969

70-
.PHONY: clean
70+
.PHONY: clean

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mode/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @example
2929
* double y = stdlib_base_dists_bernoulli_mode( 0.1 );
3030
* // returns ~0
31+
*
3132
* @example
3233
* double y = stdlib_base_dists_bernoulli_mode( 0.5 );
3334
* // returns ~0
@@ -42,5 +43,4 @@ double stdlib_base_dists_bernoulli_mode( const double p ) {
4243
return 0.0 / 0.0;
4344
}
4445
return ( p <= 0.5 ) ? 0 : 1;
45-
46-
}
46+
}

0 commit comments

Comments
 (0)