|
2 | 2 |
|
3 | 3 | @license Apache-2.0 |
4 | 4 |
|
5 | | -Copyright (c) 2018 The Stdlib Authors. |
| 5 | +Copyright (c) 2026 The Stdlib Authors. |
6 | 6 |
|
7 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | 8 | you may not use this file except in compliance with the License. |
@@ -160,6 +160,114 @@ logEachMap( 'x: %0.4f, α: %0.4f, β: %0.4f, F(x;α,β): %0.4f', x, alpha, beta, |
160 | 160 |
|
161 | 161 | <!-- /.examples --> |
162 | 162 |
|
| 163 | +<!-- C interface documentation. --> |
| 164 | + |
| 165 | +* * * |
| 166 | + |
| 167 | +<section class="c"> |
| 168 | + |
| 169 | +## C APIs |
| 170 | + |
| 171 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 172 | + |
| 173 | +<section class="intro"> |
| 174 | + |
| 175 | +</section> |
| 176 | + |
| 177 | +<!-- /.intro --> |
| 178 | + |
| 179 | +<!-- C usage documentation. --> |
| 180 | + |
| 181 | +<section class="usage"> |
| 182 | + |
| 183 | +### Usage |
| 184 | + |
| 185 | +```c |
| 186 | +#include "stdlib/stats/base/dists/beta/cdf.h" |
| 187 | +``` |
| 188 | + |
| 189 | +#### stdlib_base_dists_beta_cdf( x, alpha, beta ) |
| 190 | + |
| 191 | +Returns the [differential cdf][cdf] of a [beta][beta-distribution] distribution with parameters `alpha` (first shape parameter) and `beta` (second shape parameter). |
| 192 | + |
| 193 | +```c |
| 194 | +double y = stdlib_base_dists_beta_cdf( 0.5, 1.0, 1.0 ); |
| 195 | +// returns 0.5 |
| 196 | +``` |
| 197 | + |
| 198 | +The function accepts the following arguments: |
| 199 | + |
| 200 | +- **x**: `[in] double` input value. |
| 201 | +- **alpha**: `[in] double` first shape parameter. |
| 202 | +- **beta**: `[in] double` second shape parameter. |
| 203 | + |
| 204 | +```c |
| 205 | +double stdlib_base_dists_beta_cdf( const double x, const double alpha, const double beta ); |
| 206 | +``` |
| 207 | +
|
| 208 | +</section> |
| 209 | +
|
| 210 | +<!-- /.usage --> |
| 211 | +
|
| 212 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` |
| 213 | +element and another before the `/section` close. --> |
| 214 | +
|
| 215 | +<section class="notes"> |
| 216 | +
|
| 217 | +</section> |
| 218 | +
|
| 219 | +<!-- /.notes --> |
| 220 | +
|
| 221 | +<!-- C API usage examples. --> |
| 222 | +
|
| 223 | +<section class="examples"> |
| 224 | +
|
| 225 | +### Examples |
| 226 | +
|
| 227 | +```c |
| 228 | +#include "stdlib/stats/base/dists/beta/cdf.h" |
| 229 | +#include "stdlib/constants/float64/eps.h" |
| 230 | +#include <stdlib.h> |
| 231 | +#include <stdio.h> |
| 232 | +
|
| 233 | +static double random_uniform( const double min, const double max ) { |
| 234 | + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); |
| 235 | + return min + ( v*(max-min) ); |
| 236 | +} |
| 237 | +
|
| 238 | +int main( void ) { |
| 239 | + double alpha; |
| 240 | + double beta; |
| 241 | + double x; |
| 242 | + double y; |
| 243 | + int i; |
| 244 | +
|
| 245 | + for ( i = 0; i < 10; i++ ) { |
| 246 | + alpha = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 ); |
| 247 | + beta = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 ); |
| 248 | + x = random_uniform( 0.0, 1.0 ); |
| 249 | + y = stdlib_base_dists_beta_cdf( x, alpha, beta ); |
| 250 | + printf( "x: %lf, α: %lf, β: %lf, F(x;α,β): %lf\n", x, alpha, beta, y ); |
| 251 | + } |
| 252 | +} |
| 253 | +``` |
| 254 | + |
| 255 | +</section> |
| 256 | + |
| 257 | +<!-- /.examples --> |
| 258 | + |
| 259 | +</section> |
| 260 | + |
| 261 | +<!-- /.c --> |
| 262 | + |
| 263 | +<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 264 | + |
| 265 | +<section class="references"> |
| 266 | + |
| 267 | +</section> |
| 268 | + |
| 269 | +<!-- /.references --> |
| 270 | + |
163 | 271 | <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
164 | 272 |
|
165 | 273 | <section class="related"> |
|
0 commit comments