From 1eefced0448538a29793401c80faf2060e69411d Mon Sep 17 00:00:00 2001 From: DhruvArvindSingh Date: Sat, 28 Dec 2024 10:44:14 +0000 Subject: [PATCH 1/3] feat: added c implementation for @stdlib/stats/base/dists/pareto-type1/logpdf --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../base/dists/pareto-type1/logpdf/README.md | 89 +++++++- .../logpdf/benchmark/benchmark.js | 19 +- .../logpdf/benchmark/benchmark.native.js | 74 ++++++ .../pareto-type1/logpdf/benchmark/c/Makefile | 146 ++++++++++++ .../logpdf/benchmark/c/benchmark.c | 142 ++++++++++++ .../dists/pareto-type1/logpdf/binding.gyp | 170 ++++++++++++++ .../pareto-type1/logpdf/examples/c/Makefile | 146 ++++++++++++ .../pareto-type1/logpdf/examples/c/example.c | 42 ++++ .../dists/pareto-type1/logpdf/include.gypi | 53 +++++ .../stats/base/dists/pareto-type1/logpdf.h | 38 ++++ .../dists/pareto-type1/logpdf/lib/native.js | 87 +++++++ .../dists/pareto-type1/logpdf/manifest.json | 82 +++++++ .../dists/pareto-type1/logpdf/package.json | 3 + .../dists/pareto-type1/logpdf/src/Makefile | 70 ++++++ .../dists/pareto-type1/logpdf/src/addon.c | 23 ++ .../base/dists/pareto-type1/logpdf/src/main.c | 97 ++++++++ .../pareto-type1/logpdf/test/test.native.js | 212 ++++++++++++++++++ 17 files changed, 1487 insertions(+), 6 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/include/stdlib/stats/base/dists/pareto-type1/logpdf.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/README.md index b2be828ad786..707b2e6c730d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/pareto-type1/logpdf/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. @@ -166,6 +166,93 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/pareto-type1/logpdf.h" +``` + +#### stdlib_base_dists_pareto_type1_logpdf( x, alpha, beta ) + +Returns the logpdf of a Pareto (Type I) distribution. + +```c +double y = stdlib_base_dists_pareto_type1_logpdf( 4.0, 1.0, 1.0 ); +// returns ~-2.773 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` first shape parameter. +- **alpha**: `[in] double` second shape parameter. +- **beta**: `[in] double` third shape parameter. + +```c +double stdlib_base_dists_pareto_type1_logpdf( const double x, const double alpha, const double beta ); +``` + +
+ + +
+
+ + +
+### Examples +```c +#include "stdlib/stats/base/dists/pareto-type1/logpdf.h" +#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 alpha; + double beta; + double x; + double y; + int i; + for ( i = 0; i < 25; i++ ) { + alpha = random_uniform( 0, 10 ) + 3.0; + beta = random_uniform( 0, 10 ); + x = random_uniform( 0, 10 ); + y = stdlib_base_dists_pareto_type1_logpdf( x, alpha, beta ); + printf( "x: %lf, α: %lf, β: %lf, logpdf(X,α,β): %lf\n", x, alpha, beta, y ); + } +} +``` + +
+ + + +
+ + + +