Skip to content

Commit e7bc7d6

Browse files
fix(readme): add c implementation for @stdlib/stats/base/dists/laplace/logcdf
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 3419ece commit e7bc7d6

File tree

1 file changed

+86
-0
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/laplace/logcdf

1 file changed

+86
-0
lines changed

lib/node_modules/@stdlib/stats/base/dists/laplace/logcdf/README.md

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

146146
<!-- /.examples -->
147147

148+
<!-- C interface documentation. -->
149+
150+
* * *
151+
152+
<section class="c">
153+
154+
## C APIs
155+
156+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
157+
158+
<section class="intro">
159+
160+
</section>
161+
162+
<!-- /.intro -->
163+
164+
<!-- C usage documentation. -->
165+
166+
<section class="usage">
167+
168+
### Usage
169+
170+
```c
171+
#include "stdlib/stats/base/dists/laplace/logcdf.h"
172+
```
173+
174+
#### stdlib_base_dists_laplace_logcdf( x, mu, b )
175+
176+
Evaluates the logarithm of the cumulative distribution function (CDF) for a Laplace distribution with location parameter `mu` and scale parameter `b` at value `x`.
177+
178+
```c
179+
double out = stdlib_base_dists_laplace_logcdf( 2.0, 0.0, 1.0 );
180+
// returns ~-0.07
181+
```
182+
183+
The function accepts the following arguments:
184+
185+
- **x**: `[in] double` input value.
186+
- **mu**: `[in] double` location parameter.
187+
- **b**: `[in] double` rate parameter.
188+
189+
```c
190+
double stdlib_base_dists_laplace_logcdf( const double x, const double mu, const double b );
191+
```
192+
193+
</section>
194+
<!-- /.usage -->
195+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
196+
<section class="notes">
197+
</section>
198+
<!-- /.notes -->
199+
<!-- C API usage examples. -->
200+
<section class="examples">
201+
### Examples
202+
```c
203+
#include "stdlib/stats/base/dists/laplace/logcdf.h"
204+
#include <stdlib.h>
205+
#include <stdio.h>
206+
static double random_uniform( const double min, const double max ) {
207+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
208+
return min + ( v*(max-min) );
209+
}
210+
int main( void ) {
211+
double mu;
212+
double b;
213+
double x;
214+
double y;
215+
int i;
216+
for ( i = 0; i < 25; i++ ) {
217+
mu = random_uniform( -5.0, 5.0 );
218+
b = random_uniform( 0.0, 20.0 );
219+
x = random_uniform( 0.0, 20.0 );
220+
y = stdlib_base_dists_laplace_logcdf( x, mu, b );
221+
printf( "x: %lf, µ: %lf, b: %lf, logcdf(X;x,µ,b): %lf\n", x, mu, b, y );
222+
}
223+
}
224+
```
225+
226+
</section>
227+
228+
<!-- /.examples -->
229+
230+
</section>
231+
232+
<!-- /.c -->
233+
148234
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
149235

150236
<section class="related">

0 commit comments

Comments
 (0)