Skip to content

Commit 7ff30a3

Browse files
committed
fix(logpdf): fix README C section structure to match stdlib conventions
Signed-off-by: Kamal Singh Rautela <e22cseu1624@bennett.edu.in>
1 parent da83153 commit 7ff30a3

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

  • lib/node_modules/@stdlib/stats/base/dists/lognormal/logpdf

lib/node_modules/@stdlib/stats/base/dists/lognormal/logpdf/README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,24 @@ logEachMap( 'x: %0.4f, µ: %0.4f, σ: %0.4f, ln(f(x;µ,σ)): %0.4f', x, mu, sigm
134134

135135
<!-- /.examples -->
136136

137-
<!-- C usage documentation. -->
137+
<!-- C interface documentation. -->
138+
139+
* * *
138140

139141
<section class="c">
140142

143+
## C APIs
144+
145+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
146+
147+
<section class="intro">
148+
149+
</section>
150+
151+
<!-- /.intro -->
152+
153+
<!-- C usage documentation. -->
154+
141155
<section class="usage">
142156

143157
### Usage
@@ -177,23 +191,36 @@ double stdlib_base_dists_lognormal_logpdf( const double x, const double mu, cons
177191
178192
<!-- /.notes -->
179193
194+
<!-- C API usage examples. -->
195+
180196
<section class="examples">
181197
182198
### Examples
183199
184200
```c
185201
#include "stdlib/stats/base/dists/lognormal/logpdf.h"
202+
#include <stdlib.h>
186203
#include <stdio.h>
187204
205+
static double random_uniform( const double min, const double max ) {
206+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
207+
return min + ( v*(max-min) );
208+
}
209+
188210
int main( void ) {
211+
double x;
212+
double mu;
213+
double sigma;
189214
double y;
190215
int i;
191216
192217
for ( i = 0; i < 25; i++ ) {
193-
y = stdlib_base_dists_lognormal_logpdf( (double)i, 0.0, 1.0 );
194-
printf( "x: %d, logpdf: %lf\n", i, y );
218+
x = random_uniform( 0.0, 100.0 );
219+
mu = random_uniform( -10.0, 10.0 );
220+
sigma = random_uniform( 0.1, 10.0 );
221+
y = stdlib_base_dists_lognormal_logpdf( x, mu, sigma );
222+
printf( "x: %lf, mu: %lf, sigma: %lf, ln(f(x;mu,sigma)): %lf\n", x, mu, sigma, y );
195223
}
196-
return 0;
197224
}
198225
```
199226

0 commit comments

Comments
 (0)