From bd1f5de46e1f757b5d4b0d803781a386afc7ec10 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Wed, 11 Dec 2024 21:31:51 +0530 Subject: [PATCH 01/14] feat: add skewness --- .../base/dists/bernoulli/skewness/LICENSE | 213 ++++++++++++++++++ .../base/dists/bernoulli/skewness/README.md | 90 +++++++- .../skewness/benchmark/benchmark.native.js | 60 +++++ .../bernoulli/skewness/benchmark/c/Makefile | 146 ++++++++++++ .../skewness/benchmark/c/benchmark.c | 133 +++++++++++ .../base/dists/bernoulli/skewness/binding.gyp | 170 ++++++++++++++ .../bernoulli/skewness/examples/c/Makefile | 146 ++++++++++++ .../bernoulli/skewness/examples/c/example.c | 33 +++ .../dists/bernoulli/skewness/include.gypi | 53 +++++ .../stats/base/dists/bernoulli/skewness.h | 38 ++++ .../dists/bernoulli/skewness/lib/native.js | 61 +++++ .../dists/bernoulli/skewness/manifest.json | 88 ++++++++ .../dists/bernoulli/skewness/package.json | 3 + .../dists/bernoulli/skewness/src/Makefile | 146 ++++++++++++ .../base/dists/bernoulli/skewness/src/addon.c | 23 ++ .../base/dists/bernoulli/skewness/src/main.c | 58 +++++ .../bernoulli/skewness/test/test.native.js | 112 +++++++++ 17 files changed, 1572 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE new file mode 100644 index 000000000000..a805c2f4a606 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE @@ -0,0 +1,213 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +DEPENDENCIES & ATTRIBUTION + +The library links against the following external libraries or contains +implementations from the following external libraries, which have their own +licenses: + +* Go + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md index fc0e7c2e750c..f58239cfdc19 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -122,6 +122,94 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/bernoulli/skewness.h" +``` + +#### stdlib_base_dists_bernoulli_skewness( P ) + +Returns the skewness of a Bernoulli distribution for probability 'p' + +```c +double y = stdlib_base_dists_bernoulli_skewness( 0.1 ); +// returns ~2.667 + +y = stdlib_base_dists_bernoulli_skewness( 0.5 ); +// returns ~0.0 +``` + +The function accepts the following arguments: + +- **y**: `[in] double` - `y` probability + +```c +double stdlib_base_dists_bernoulli_skewness( const double p ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/bernoulli/skewness.h" +#include +#include + +int main( void ) { + double p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + p = ( (double)rand() / (double)RAND_MAX ) ; + y = stdlib_base_dists_bernoulli_skewness( p ); + printf( "x: %lf , H(X;p): %lf\n", p , y ); + } +} +``` + +
+ + + +
+
diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js new file mode 100644 index 000000000000..5179f4af6c4b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var skewness = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( skewness instanceof Error ) +}; + + +// MAIN // + +bench( pkg, opts, function benchmark( b ) { + var p; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + p = randu(); + y = skewness( p ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c new file mode 100644 index 000000000000..b61ef8fe4092 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c @@ -0,0 +1,133 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/bernoulli/skewness.h" +#include +#include +#include +#include +#include + +#define NAME "bernoulli-skewness" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double p; + double y; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + p = ( (double)rand() / (double)RAND_MAX ) ; + y = stdlib_base_dists_bernoulli_skewness( p ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c new file mode 100644 index 000000000000..78933ad3ce99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/bernoulli/skewness.h" +#include +#include + +int main( void ) { + double p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + p = ( (double)rand() / (double)RAND_MAX ) ; + y = stdlib_base_dists_bernoulli_skewness( p ); + printf( "x: %lf , H(X;p): %lf\n", p , y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' 1.0 + ) { + return 0.0 / 0.0; + } + if ( p == 0.0 ) { + return STDLIB_CONSTANT_FLOAT64_PINF; + } + if ( p == 1.0 ) { + return STDLIB_CONSTANT_FLOAT64_NINF; + } + return ( 1.0 - ( 2.0*p ) ) / sqrt( p * ( 1.0-p ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js new file mode 100644 index 000000000000..19a8da90d682 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js @@ -0,0 +1,112 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var skewness = require( './../lib' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// VARIABLES // + +var skewness = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( skewness instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof skewness, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for `p`, the function returns `NaN`', opts, function test( t ) { + var v = skewness( NaN ); + t.equal( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'if provided `0` for `p`, the function returns `+infinity`', opts, function test( t ) { + var v = skewness( 0.0 ); + t.strictEqual( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'if provided `1` for `p`, the function returns `-infinity`', opts, function test( t ) { + var v = skewness( 1.0 ); + t.strictEqual( v, NINF, 'returns -infinity' ); + t.end(); +}); + +tape( 'if provided a success probability `p` outside of `[0,1]`, the function returns `NaN`', opts, function test( t ) { + var v; + + v = skewness( -1.0 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = skewness( 1.5 ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = skewness( NINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + + v = skewness( PINF ); + t.equal( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns the skewness of a Bernoulli distribution', opts, function test( t ) { + var expected; + var delta; + var tol; + var i; + var p; + var y; + + expected = data.expected; + p = data.p; + for ( i = 0; i < expected.length; i++ ) { + y = skewness( p[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'p: '+p[i]+', y: '+y+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 1.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. p: '+p[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); From 7eddf33a16680f064dc978eddeae0f740d8570ab Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Wed, 11 Dec 2024 21:45:35 +0530 Subject: [PATCH 02/14] fix: lib lint errors --- .../@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js index 3540504f7061..dd146d41d2ef 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js @@ -1,4 +1,4 @@ -/** +/** * @license Apache-2.0 * * Copyright (c) 2024 The Stdlib Authors. @@ -41,7 +41,7 @@ var addon = require( './../src/addon.node' ); * * @example * var v = skewness( NaN ); -* // returns ~NaN +* // returns NaN * * @example * var v = skewness( 1.5 ); From 70a6140ff676fea949bc8d549a30e0f87ba7a7cf Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Wed, 11 Dec 2024 21:56:16 +0530 Subject: [PATCH 03/14] fix: test lint errors --- .../stats/base/dists/bernoulli/skewness/test/test.native.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js index 19a8da90d682..b3ef60f7e54f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js @@ -24,11 +24,10 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); +var tryRequire = require( '@stdlib/utils/try-require' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var EPS = require( '@stdlib/constants/float64/eps' ); -var skewness = require( './../lib' ); -var tryRequire = require( '@stdlib/utils/try-require' ); // FIXTURES // From 1e0dcee221a262c5644ef11e49f062751244550b Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 12 Dec 2024 12:12:31 +0530 Subject: [PATCH 04/14] fix: changes from code review --- .../base/dists/bernoulli/skewness/LICENSE | 213 ------------------ .../base/dists/bernoulli/skewness/README.md | 8 +- .../bernoulli/skewness/examples/c/Makefile | 81 ++----- .../bernoulli/skewness/examples/c/example.c | 2 +- .../stats/base/dists/bernoulli/skewness.h | 2 +- .../dists/bernoulli/skewness/manifest.json | 3 - .../base/dists/bernoulli/skewness/src/main.c | 12 +- 7 files changed, 35 insertions(+), 286 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE deleted file mode 100644 index a805c2f4a606..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/LICENSE +++ /dev/null @@ -1,213 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - -DEPENDENCIES & ATTRIBUTION - -The library links against the following external libraries or contains -implementations from the following external libraries, which have their own -licenses: - -* Go - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md index f58239cfdc19..113dfafcecac 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md @@ -148,9 +148,9 @@ for ( i = 0; i < 10; i++ ) { #include "stdlib/stats/base/dists/bernoulli/skewness.h" ``` -#### stdlib_base_dists_bernoulli_skewness( P ) +#### stdlib_base_dists_bernoulli_skewness( p ) -Returns the skewness of a Bernoulli distribution for probability 'p' +Returns the skewness of a Bernoulli distribution with success probability 'p'. ```c double y = stdlib_base_dists_bernoulli_skewness( 0.1 ); @@ -162,7 +162,7 @@ y = stdlib_base_dists_bernoulli_skewness( 0.5 ); The function accepts the following arguments: -- **y**: `[in] double` - `y` probability +- **p**: `[in] double` success probability. ```c double stdlib_base_dists_bernoulli_skewness( const double p ); @@ -199,7 +199,7 @@ int main( void ) { for ( i = 0; i < 25; i++ ) { p = ( (double)rand() / (double)RAND_MAX ) ; y = stdlib_base_dists_bernoulli_skewness( p ); - printf( "x: %lf , H(X;p): %lf\n", p , y ); + printf( "x: %lf , skew(X;p): %lf\n", p , y ); } } ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile index f69e9da2b4d3..e4542b1e66e9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,15 +16,14 @@ # limitations under the License. #/ + # VARIABLES # ifndef VERBOSE QUIET := @ -else - QUIET := endif -# Determine the OS ([1][1], [2][2]). +# Determine the OS: # # [1]: https://en.wikipedia.org/wiki/Uname#Examples # [2]: http://stackoverflow.com/a/27776822/2225624 @@ -37,10 +36,6 @@ ifneq (, $(findstring MSYS,$(OS))) else ifneq (, $(findstring CYGWIN,$(OS))) OS := WINNT -else -ifneq (, $(findstring Windows_NT,$(OS))) - OS := WINNT -endif endif endif endif @@ -59,7 +54,7 @@ CFLAGS ?= \ -Wall \ -pedantic -# Determine whether to generate position independent code ([1][1], [2][2]). +# Determine whether to generate [position independent code][1]: # # [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options # [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option @@ -69,77 +64,43 @@ else fPIC ?= -fPIC endif -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - # List of C targets: c_targets := benchmark.out -# RULES # +# TARGETS # -#/ -# Compiles source files. +# Default target. # -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ +# This target is the default target. + all: $(c_targets) .PHONY: all -#/ -# Compiles C source files. + +# Compile C source. # -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ +# This target compiles C source files. + $(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm -#/ -# Runs compiled benchmarks. + +# Run a benchmark. # -# @example -# make run -#/ +# This target runs a benchmark. + run: $(c_targets) $(QUIET) ./$< .PHONY: run -#/ -# Removes generated files. + +# Perform clean-up. # -# @example -# make clean -#/ +# This target removes generated files. + clean: $(QUIET) -rm -f *.o *.out diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c index 78933ad3ce99..0f937dcd71a5 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c @@ -28,6 +28,6 @@ int main( void ) { for ( i = 0; i < 25; i++ ) { p = ( (double)rand() / (double)RAND_MAX ) ; y = stdlib_base_dists_bernoulli_skewness( p ); - printf( "x: %lf , H(X;p): %lf\n", p , y ); + printf( "x: %lf , skew(X;p): %lf\n", p , y ); } } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h index 1834852a8001..37a67cad681d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h @@ -35,4 +35,4 @@ double stdlib_base_dists_bernoulli_skewness( const double p ); } #endif -#endif // !STDLIB_STATS_BASE_DISTS_BERNOULLI_SKEWNESS_H \ No newline at end of file +#endif // !STDLIB_STATS_BASE_DISTS_BERNOULLI_SKEWNESS_H diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/manifest.json index 25df60507075..b99b137fc6c3 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/manifest.json @@ -42,7 +42,6 @@ "@stdlib/math/base/assert/is-nan", "@stdlib/constants/float64/pinf", "@stdlib/constants/float64/ninf", - "@stdlib/math/base/special/asin", "@stdlib/math/base/special/sqrt" ] }, @@ -61,7 +60,6 @@ "@stdlib/math/base/assert/is-nan", "@stdlib/constants/float64/pinf", "@stdlib/constants/float64/ninf", - "@stdlib/math/base/special/asin", "@stdlib/math/base/special/sqrt" ] }, @@ -80,7 +78,6 @@ "@stdlib/math/base/assert/is-nan", "@stdlib/constants/float64/pinf", "@stdlib/constants/float64/ninf", - "@stdlib/math/base/special/asin", "@stdlib/math/base/special/sqrt" ] } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c index bdf4511704d9..0c9f00523aba 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c @@ -18,24 +18,28 @@ #include "stdlib/stats/base/dists/bernoulli/skewness.h" #include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/special/sqrt.h" #include "stdlib/constants/float64/pinf.h" #include "stdlib/constants/float64/ninf.h" /** * Returns the skewness of a Bernoulli distribution. * -* @param {Probability} p - success probability -* @returns {PositiveNumber} skewness +* @param p success probability +* @returns skewness * * @example * double y = stdlib_base_dists_bernoulli_skewness( 0.1 ); * // returns ~2.667 +* * @example * double y = stdlib_base_dists_bernoulli_skewness( 0.5 ); * // returns ~0.0 +* * @example * double y = stdlib_base_dists_bernoulli_skewness( 1.1 ); * // returns ~NaN +* * @example * double y = stdlib_base_dists_bernoulli_skewness( NaN ); * // returns ~NaN @@ -48,11 +52,11 @@ double stdlib_base_dists_bernoulli_skewness( const double p ) { ) { return 0.0 / 0.0; } - if ( p == 0.0 ) { + if ( p == 0.0 ) { return STDLIB_CONSTANT_FLOAT64_PINF; } if ( p == 1.0 ) { return STDLIB_CONSTANT_FLOAT64_NINF; } - return ( 1.0 - ( 2.0*p ) ) / sqrt( p * ( 1.0-p ) ); + return ( 1.0 - ( 2.0*p ) ) / stdlib_base_sqrt( p * ( 1.0-p ) ); } From 349c2f2a61b92b5b368ee1ecc3b55c21f14b28b2 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 12 Dec 2024 12:20:01 +0530 Subject: [PATCH 05/14] fix: example errors --- .../stats/base/dists/bernoulli/skewness/examples/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile index e4542b1e66e9..ad9fedcd4fff 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 7a9086e878066444a26de5fbb6a2135cfdf84214 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 12 Dec 2024 12:34:43 +0530 Subject: [PATCH 06/14] fix: example errors --- .../stats/base/dists/bernoulli/skewness/benchmark/c/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile index f69e9da2b4d3..6aed70daf167 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile @@ -82,7 +82,7 @@ LIBRARIES ?= LIBPATH ?= # List of C targets: -c_targets := benchmark.out +c_targets := example.out # RULES # @@ -124,7 +124,7 @@ $(c_targets): %.out: %.c $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) #/ -# Runs compiled benchmarks. +# Runs compiled examples. # # @example # make run From 6d23a17606a1b694758f51e413f4848155e67790 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 12 Dec 2024 13:18:21 +0530 Subject: [PATCH 07/14] fix: makefile errors --- .../bernoulli/skewness/benchmark/c/Makefile | 5 +- .../bernoulli/skewness/examples/c/Makefile | 81 ++++++++++++++----- 2 files changed, 63 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile index 6aed70daf167..ff0f31e79237 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile @@ -82,7 +82,7 @@ LIBRARIES ?= LIBPATH ?= # List of C targets: -c_targets := example.out +c_targets := benchmark.out # RULES # @@ -124,7 +124,7 @@ $(c_targets): %.out: %.c $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) #/ -# Runs compiled examples. +# Runs compiled benchmarks. # # @example # make run @@ -144,3 +144,4 @@ clean: $(QUIET) -rm -f *.o *.out .PHONY: clean + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile index ad9fedcd4fff..6aed70daf167 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile @@ -16,14 +16,15 @@ # limitations under the License. #/ - # VARIABLES # ifndef VERBOSE QUIET := @ +else + QUIET := endif -# Determine the OS: +# Determine the OS ([1][1], [2][2]). # # [1]: https://en.wikipedia.org/wiki/Uname#Examples # [2]: http://stackoverflow.com/a/27776822/2225624 @@ -36,6 +37,10 @@ ifneq (, $(findstring MSYS,$(OS))) else ifneq (, $(findstring CYGWIN,$(OS))) OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif endif endif endif @@ -54,7 +59,7 @@ CFLAGS ?= \ -Wall \ -pedantic -# Determine whether to generate [position independent code][1]: +# Determine whether to generate position independent code ([1][1], [2][2]). # # [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options # [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option @@ -64,43 +69,77 @@ else fPIC ?= -fPIC endif +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + # List of C targets: -c_targets := benchmark.out +c_targets := example.out -# TARGETS # +# RULES # -# Default target. +#/ +# Compiles source files. # -# This target is the default target. - +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ all: $(c_targets) .PHONY: all - -# Compile C source. +#/ +# Compiles C source files. # -# This target compiles C source files. - +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ $(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm - + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) -# Run a benchmark. +#/ +# Runs compiled examples. # -# This target runs a benchmark. - +# @example +# make run +#/ run: $(c_targets) $(QUIET) ./$< .PHONY: run - -# Perform clean-up. +#/ +# Removes generated files. # -# This target removes generated files. - +# @example +# make clean +#/ clean: $(QUIET) -rm -f *.o *.out From c5c68768137526b0f2f0897215503a186dcd4973 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 16 Jan 2025 18:06:25 +0530 Subject: [PATCH 08/14] chore: clean up --- .../base/dists/bernoulli/skewness/README.md | 26 ++++++++++--------- .../skewness/benchmark/benchmark.native.js | 2 +- .../skewness/benchmark/c/benchmark.c | 15 ++++++----- .../bernoulli/skewness/examples/c/example.c | 9 +++++-- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md index 113dfafcecac..d9de01f0a62e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md @@ -155,9 +155,6 @@ Returns the skewness of a Bernoulli distribution with success probability 'p'. ```c double y = stdlib_base_dists_bernoulli_skewness( 0.1 ); // returns ~2.667 - -y = stdlib_base_dists_bernoulli_skewness( 0.5 ); -// returns ~0.0 ``` The function accepts the following arguments: @@ -191,16 +188,21 @@ double stdlib_base_dists_bernoulli_skewness( const double p ); #include #include +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + int main( void ) { - double p; - double y; - int i; - - for ( i = 0; i < 25; i++ ) { - p = ( (double)rand() / (double)RAND_MAX ) ; - y = stdlib_base_dists_bernoulli_skewness( p ); - printf( "x: %lf , skew(X;p): %lf\n", p , y ); - } + double p; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + p = random_uniform( 0.1, 10.0 ); + y = stdlib_base_dists_bernoulli_skewness( p ); + printf( "x: %lf , skew(X;p): %lf\n", p , y ); + } } ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js index 5179f4af6c4b..0af16351350e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js @@ -38,7 +38,7 @@ var opts = { // MAIN // -bench( pkg, opts, function benchmark( b ) { +bench( pkg+'::native', opts, function benchmark( b ) { var p; var y; var i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c index b61ef8fe4092..f784b0a4d2bc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c @@ -79,9 +79,9 @@ static double tic( void ) { * * @return random number */ -static double rand_double( void ) { - int r = rand(); - return (double)r / ( (double)RAND_MAX + 1.0 ); +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); } /** @@ -91,15 +91,18 @@ static double rand_double( void ) { */ static double benchmark( void ) { double elapsed; - double p; + double p[ 100 ]; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + p[ i ] = random_uniform( 0.1, 10.0 ); + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - p = ( (double)rand() / (double)RAND_MAX ) ; - y = stdlib_base_dists_bernoulli_skewness( p ); + y = stdlib_base_dists_bernoulli_skewness( p[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c index 0f937dcd71a5..7efdefd107bb 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c @@ -20,13 +20,18 @@ #include #include +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + int main( void ) { double p; double y; int i; - for ( i = 0; i < 25; i++ ) { - p = ( (double)rand() / (double)RAND_MAX ) ; + for ( i = 0; i < 10; i++ ) { + p = random_uniform( 0.1, 10.0 ); y = stdlib_base_dists_bernoulli_skewness( p ); printf( "x: %lf , skew(X;p): %lf\n", p , y ); } From 889901deb9224ff3977b959be4b4f5b25f826815 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 16 Jan 2025 18:13:37 +0530 Subject: [PATCH 09/14] fix: lint error --- .../base/dists/bernoulli/skewness/README.md | 22 +++++++++---------- .../bernoulli/skewness/benchmark/c/Makefile | 1 - 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md index d9de01f0a62e..f287298dd385 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md @@ -189,20 +189,20 @@ double stdlib_base_dists_bernoulli_skewness( const double p ); #include static double random_uniform( const double min, const double max ) { - double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); - return min + ( v * ( max - min ) ); + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); } int main( void ) { - double p; - double y; - int i; - - for ( i = 0; i < 10; i++ ) { - p = random_uniform( 0.1, 10.0 ); - y = stdlib_base_dists_bernoulli_skewness( p ); - printf( "x: %lf , skew(X;p): %lf\n", p , y ); - } + double p; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + p = random_uniform( 0.1, 10.0 ); + y = stdlib_base_dists_bernoulli_skewness( p ); + printf( "x: %lf , skew(X;p): %lf\n", p , y ); + } } ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile index ff0f31e79237..f69e9da2b4d3 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile @@ -144,4 +144,3 @@ clean: $(QUIET) -rm -f *.o *.out .PHONY: clean - \ No newline at end of file From a86ed82c85ecbde4f6497133945acc37b1c4595e Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Thu, 16 Jan 2025 12:46:23 +0000 Subject: [PATCH 10/14] chore: update copyright years --- .../base/dists/bernoulli/skewness/benchmark/benchmark.native.js | 2 +- .../stats/base/dists/bernoulli/skewness/benchmark/c/Makefile | 2 +- .../stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c | 2 +- .../@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp | 2 +- .../stats/base/dists/bernoulli/skewness/examples/c/Makefile | 2 +- .../stats/base/dists/bernoulli/skewness/examples/c/example.c | 2 +- .../@stdlib/stats/base/dists/bernoulli/skewness/include.gypi | 2 +- .../include/stdlib/stats/base/dists/bernoulli/skewness.h | 2 +- .../@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js | 2 +- .../@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile | 2 +- .../@stdlib/stats/base/dists/bernoulli/skewness/src/addon.c | 2 +- .../@stdlib/stats/base/dists/bernoulli/skewness/src/main.c | 2 +- .../stats/base/dists/bernoulli/skewness/test/test.native.js | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js index 0af16351350e..f0393e77c0e7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile index f69e9da2b4d3..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c index f784b0a4d2bc..1a5ad645d97e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp index ec3992233442..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile index 6aed70daf167..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c index 7efdefd107bb..36fefa9822a3 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi index 575cb043c0bf..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h index 37a67cad681d..73cc0d586f75 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js index dd146d41d2ef..f5fe8a0bbdf2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile index f69e9da2b4d3..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/addon.c index 73e3d35bcf69..79fe4bd4a3be 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c index 0c9f00523aba..acdfe87074f0 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js index b3ef60f7e54f..755087d71c90 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From a6700949e2cd68b8b5fd334a02d611236ca579bb Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Thu, 16 Jan 2025 18:50:55 +0530 Subject: [PATCH 11/14] chore: update bench --- .../base/dists/bernoulli/skewness/benchmark/c/benchmark.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c index 1a5ad645d97e..f021957f51fe 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c @@ -75,9 +75,11 @@ static double tic( void ) { } /** -* Generates a random number on the interval [0,1). +* Generates a random number on the interval [min,max). * -* @return random number +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number */ static double random_uniform( const double min, const double max ) { double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); From fdb5b88fdaa4e6824b01d507834c729dbbaf8f62 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Fri, 17 Jan 2025 21:20:38 +0530 Subject: [PATCH 12/14] chore: clean up --- .../stats/base/dists/bernoulli/skewness/README.md | 2 +- .../dists/bernoulli/skewness/benchmark/benchmark.js | 13 ++++++++++--- .../skewness/benchmark/benchmark.native.js | 13 ++++++++++--- .../dists/bernoulli/skewness/examples/c/example.c | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md index f287298dd385..25e056005d01 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md @@ -199,7 +199,7 @@ int main( void ) { int i; for ( i = 0; i < 10; i++ ) { - p = random_uniform( 0.1, 10.0 ); + p = random_uniform( 0.0, 1.0 ); y = stdlib_base_dists_bernoulli_skewness( p ); printf( "x: %lf , skew(X;p): %lf\n", p , y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js index e9cf3043fd80..a4d7e215a36b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var skewness = require( './../lib' ); @@ -30,14 +31,20 @@ var skewness = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { + var len; var p; var y; var i; + len = 100; + p = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + p[ i ] = uniform( 0.0, 1.0 ); + } + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - p = randu(); - y = skewness( p ); + y = skewness( p[ i%100 ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js index f0393e77c0e7..b903db7073be 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -39,14 +40,20 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { + var len; var p; var y; var i; + len = 100; + p = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + p[ i ] = uniform( 0.0, 1.0 ); + } + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - p = randu(); - y = skewness( p ); + y = skewness( p[ i%100 ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c index 36fefa9822a3..d70d92efdcc6 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/examples/c/example.c @@ -31,7 +31,7 @@ int main( void ) { int i; for ( i = 0; i < 10; i++ ) { - p = random_uniform( 0.1, 10.0 ); + p = random_uniform( 0.0, 1.0 ); y = stdlib_base_dists_bernoulli_skewness( p ); printf( "x: %lf , skew(X;p): %lf\n", p , y ); } From fb8c8a0f1802a0338b9fdc7608654276c7c8d47b Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Fri, 31 Jan 2025 21:17:50 +0530 Subject: [PATCH 13/14] chore: minor clean up --- .../bernoulli/skewness/benchmark/benchmark.js | 4 +- .../skewness/benchmark/benchmark.native.js | 4 +- .../skewness/benchmark/c/benchmark.c | 4 +- .../stats/base/dists/bernoulli/skewness.h | 2 +- .../dists/bernoulli/skewness/src/Makefile | 88 ++----------------- .../base/dists/bernoulli/skewness/src/main.c | 4 +- 6 files changed, 15 insertions(+), 91 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js index a4d7e215a36b..086db4bd41ca 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js @@ -39,12 +39,12 @@ bench( pkg, function benchmark( b ) { len = 100; p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 1.0 ); + p[ i ] = uniform( 0.0, 10.0 ); } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = skewness( p[ i%100 ] ); + y = skewness( p[ i % len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js index b903db7073be..588f1ba418f4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.native.js @@ -48,12 +48,12 @@ bench( pkg+'::native', opts, function benchmark( b ) { len = 100; p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 1.0 ); + p[ i ] = uniform( 0.0, 10.0 ); } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = skewness( p[ i%100 ] ); + y = skewness( p[ i % len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c index f021957f51fe..0b6361a9df02 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/c/benchmark.c @@ -99,12 +99,12 @@ static double benchmark( void ) { int i; for ( i = 0; i < 100; i++ ) { - p[ i ] = random_uniform( 0.1, 10.0 ); + p[ i ] = random_uniform( 0.0, 10.0 ); } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_dists_bernoulli_skewness( p[ i%100 ] ); + y = stdlib_base_dists_bernoulli_skewness( p[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h index 73cc0d586f75..9fcc80662f83 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/include/stdlib/stats/base/dists/bernoulli/skewness.h @@ -27,7 +27,7 @@ extern "C" { #endif /** -* Returns the skewness of a Bernoulli distribution. +* Returns the skewness of a Bernoulli distribution with success probability 'p'. */ double stdlib_base_dists_bernoulli_skewness( const double p ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile index a4bd7b38fd74..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/Makefile @@ -45,94 +45,19 @@ endif endif endif -# Define the program used for compiling C source files: -ifdef C_COMPILER - CC := $(C_COMPILER) -else - CC := gcc -endif - -# Define the command-line options when compiling C files: -CFLAGS ?= \ - -std=c99 \ - -O3 \ - -Wall \ - -pedantic - -# Determine whether to generate position independent code ([1][1], [2][2]). -# -# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options -# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option -ifeq ($(OS), WINNT) - fPIC ?= -else - fPIC ?= -fPIC -endif - -# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): -INCLUDE ?= - -# List of source files: -SOURCE_FILES ?= - -# List of libraries (e.g., `-lopenblas -lpthread`): -LIBRARIES ?= - -# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): -LIBPATH ?= - -# List of C targets: -c_targets := benchmark.out - # RULES # #/ -# Compiles source files. -# -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files -# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) -# -# @example -# make -# -# @example -# make all -#/ -all: $(c_targets) - -.PHONY: all - -#/ -# Compiles C source files. -# -# @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) -#/ -$(c_targets): %.out: %.c - $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) - -#/ -# Runs compiled benchmarks. +# Removes generated files for building an add-on. # # @example -# make run +# make clean-addon #/ -run: $(c_targets) - $(QUIET) ./$< +clean-addon: + $(QUIET) -rm -f *.o *.node -.PHONY: run +.PHONY: clean-addon #/ # Removes generated files. @@ -140,7 +65,6 @@ run: $(c_targets) # @example # make clean #/ -clean: - $(QUIET) -rm -f *.o *.out +clean: clean-addon .PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c index acdfe87074f0..a8320fef67b6 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c @@ -23,7 +23,7 @@ #include "stdlib/constants/float64/ninf.h" /** -* Returns the skewness of a Bernoulli distribution. +* Returns the skewness of a Bernoulli distribution with success probability 'p'. * * @param p success probability * @returns skewness @@ -58,5 +58,5 @@ double stdlib_base_dists_bernoulli_skewness( const double p ) { if ( p == 1.0 ) { return STDLIB_CONSTANT_FLOAT64_NINF; } - return ( 1.0 - ( 2.0*p ) ) / stdlib_base_sqrt( p * ( 1.0-p ) ); + return ( 1.0 - ( 2.0 * p ) ) / stdlib_base_sqrt( p * ( 1.0 - p ) ); } From afcebedc4eea803158de839bfcbb619d9b9b5f06 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 5 Feb 2025 09:04:47 -0500 Subject: [PATCH 14/14] chore: apply suggestions from code review Signed-off-by: Philipp Burckhardt --- .../stats/base/dists/bernoulli/skewness/README.md | 2 +- .../dists/bernoulli/skewness/benchmark/benchmark.js | 2 +- .../base/dists/bernoulli/skewness/lib/native.js | 1 + .../stats/base/dists/bernoulli/skewness/src/main.c | 12 ------------ 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md index 25e056005d01..bb5369a9f41f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +Copyright (c) 2018 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js index 086db4bd41ca..db68310661c1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/benchmark/benchmark.js @@ -39,7 +39,7 @@ bench( pkg, function benchmark( b ) { len = 100; p = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 10.0 ); + p[ i ] = uniform( 0.0, 1.0 ); } b.tic(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js index f5fe8a0bbdf2..77e31388de28 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/lib/native.js @@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' ); /** * Returns the skewness of a Bernoulli distribution. * +* @private * @param {Probability} p - success probability * @returns {PositiveNumber} skewness * diff --git a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c index a8320fef67b6..992faf48ca55 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/bernoulli/skewness/src/main.c @@ -31,18 +31,6 @@ * @example * double y = stdlib_base_dists_bernoulli_skewness( 0.1 ); * // returns ~2.667 -* -* @example -* double y = stdlib_base_dists_bernoulli_skewness( 0.5 ); -* // returns ~0.0 -* -* @example -* double y = stdlib_base_dists_bernoulli_skewness( 1.1 ); -* // returns ~NaN -* -* @example -* double y = stdlib_base_dists_bernoulli_skewness( NaN ); -* // returns ~NaN */ double stdlib_base_dists_bernoulli_skewness( const double p ) { if (