Skip to content

Commit 20e2e01

Browse files
feat(add c implementation): add stats/base/dists/bernoulli/mean
1 parent 8c6ed94 commit 20e2e01

File tree

13 files changed

+109
-38
lines changed

13 files changed

+109
-38
lines changed

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,92 @@ for ( i = 0; i < 10; i++ ) {
130130

131131
<!-- /.references -->
132132

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

135221
<section class="related">

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/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/mean/benchmark/c/benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static double benchmark( void ) {
9898

9999
t = tic();
100100
for ( i = 0; i < ITERATIONS; i++ ) {
101-
p = ( (double)rand() / (double)RAND_MAX ) ;
101+
p = ( (double)rand() / (double)RAND_MAX );
102102
y = stdlib_base_dists_bernoulli_mean( p );
103103
if ( y != y ) {
104104
printf( "should not return NaN\n" );

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@
167167
], # end actions
168168
}, # end target copy_addon
169169
], # end targets
170-
}
170+
}

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/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/mean/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_mean( p );
3131
printf( "x: %lf , H(X;p): %lf\n", p , y );
3232
}
33-
}
33+
}

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/include.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
'<!@(node -e "var arr = require(\'@stdlib/utils/library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
5151
],
5252
}, # end variables
53-
}
53+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ function mean( p ) {
5454

5555
// EXPORTS //
5656

57-
module.exports = mean;
57+
module.exports = mean;

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,8 @@
3838
"libraries": [],
3939
"libpath": [],
4040
"dependencies": [
41-
"@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"
41+
"@stdlib/math/base/napi/unary",
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,13 +69,7 @@
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
]

lib/node_modules/@stdlib/stats/base/dists/bernoulli/mean/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",

0 commit comments

Comments
 (0)