Skip to content

Commit 8d2201d

Browse files
committed
feat:C implementation of stats/base/dists/weibull/skewness
--- 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 8d0a428 commit 8d2201d

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/benchmark/c/benchmark.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2024 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/weibull/skewness.h"
20-
#include "stdlib/math/base/special/ceil.h"
2120
#include <stdlib.h>
2221
#include <stdio.h>
2322
#include <math.h>
@@ -94,29 +93,31 @@ static double random_uniform( const double min, const double max ) {
9493
*/
9594
static double benchmark( void ) {
9695
double elapsed;
97-
double x[ 100 ];
98-
double n[ 100 ];
99-
double skewness;
96+
double k[ 100 ];
97+
double lambda[ 100 ];
10098
double y;
10199
double t;
102100
int i;
103101

104-
// Generate random values for x, n, and skewness
102+
// Generate random values for k (shape) and lambda (scale)
105103
for ( i = 0; i < 100; i++ ) {
106-
x[ i ] = random_uniform( 0, 30.0 );
107-
n[ i ] = stdlib_base_ceil(random_uniform( 1, 30.0 ));
108-
skewness = random_uniform( -1.0, 1.0 );
104+
k[ i ] = random_uniform( 0.1, 10.0 ); // k > 0 to avoid NaN result
105+
lambda[ i ] = random_uniform( 0.1, 10.0 ); // lambda > 0 to avoid NaN result
109106
}
110107

111108
t = tic();
109+
// Benchmark loop
112110
for ( i = 0; i < ITERATIONS; i++ ) {
113-
y = stdlib_base_dists_weibull_skewness( x[ i%100 ], n[ i%100 ], skewness );
114-
if ( y != y ) { // Check if the result is NaN
111+
// Calculate skewness for the Weibull distribution
112+
y = stdlib_base_dists_weibull_skewness( k[ i % 100 ], lambda[ i % 100 ] );
113+
if ( y != y ) { // Check for NaN
115114
printf( "should not return NaN\n" );
116115
break;
117116
}
118117
}
119118
elapsed = tic() - t;
119+
120+
// Final NaN check
120121
if ( y != y ) {
121122
printf( "should not return NaN\n" );
122123
}

lib/node_modules/@stdlib/stats/base/dists/weibull/skewness/lib/native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var addon = require( './../src/addon.node' );
6161
* // returns NaN (invalid parameter n)
6262
*/
6363
function skewness( k, lambda ) {
64-
return addon( k, lambda );
64+
return addon( k, lambda );
6565
}
6666

6767

0 commit comments

Comments
 (0)