From 0be9c8c3bdce721b0299cc0f62c1c54d90bfc094 Mon Sep 17 00:00:00 2001 From: Tufailahmed Date: Tue, 19 Mar 2024 10:46:48 +0530 Subject: [PATCH 1/2] docs: improve README examples of stats/base/dists/triangular namespace --- .../stats/base/dists/triangular/README.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/README.md b/lib/node_modules/@stdlib/stats/base/dists/triangular/README.md index d98eabf8970d..3ea4035711a9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/README.md @@ -97,6 +97,8 @@ var y = dist.quantile( 0.5 ); y = dist.quantile( 1.9 ); // returns NaN + + ``` @@ -109,6 +111,7 @@ y = dist.quantile( 1.9 ); + ```javascript @@ -116,6 +119,32 @@ var objectKeys = require( '@stdlib/utils/keys' ); var triangular = require( '@stdlib/stats/base/dists/triangular' ); console.log( objectKeys( triangular ) ); + + +// Basic Usage: Calculate and print the mean, median, and mode +console.log('Mean:', dist.mean()); + // returns Mean: 3.0 + +console.log('Median:', dist.median()); + // returns Median: 3.0 + +console.log('Mode:', dist.mode()); + // returns Mode: 3.0 + +// Probability Density Function (PDF): Calculate the PDF at x=3.5 +var pdfValue = dist.pdf(3.5); +console.log('PDF at x=3.5:', pdfValue); +// returns PDF at x=3.5: 0.4 + +// Cumulative Distribution Function (CDF): Calculate the CDF at x=3.5 +var cdfValue = dist.cdf(3.5); +console.log('CDF at x=3.5:', cdfValue); +// returns CDF at x=3.5: 0.5 + +// Quantile Function: Find the quantile for p=0.5 +var quantileValue = dist.quantile(0.5); +console.log('Quantile for p=0.5:', quantileValue); + // returns Quantile for p=0.5: 3.0 ``` From 40488b80f1e1c87ac5f109a8057a061f76cfae6a Mon Sep 17 00:00:00 2001 From: tufail Date: Tue, 26 Mar 2024 14:34:09 +0530 Subject: [PATCH 2/2] docs: improve README examples of stats/base/dists/logistic namespace --- .../stats/base/dists/logistic/cdf/README.md | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/lib/node_modules/@stdlib/stats/base/dists/logistic/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/logistic/cdf/README.md index 4f84d3dc31b2..ac66993475ca 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/logistic/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/logistic/cdf/README.md @@ -142,10 +142,73 @@ for ( i = 0; i < 10; i++ ) { y = cdf( x, mu, s ); console.log( 'x: %d, µ: %d, s: %d, F(x;µ,s): %d', x, mu, s, y ); } +// Importing the logistic distribution namespace +var logistic = require('@stdlib/stats/base/dists/logistic'); + +// Creating a logistic distribution object with mean (mu) = 2.0 and scale (s) = 4.0 +var dist = new logistic.Logistic(2.0, 4.0); + +// To calculate the probability density function (PDF) at x = 2.0 +var pdfValue = dist.pdf(2.0); +console.log('PDF at x = 2.0:', pdfValue); // Output: PDF at x = 2.0: 0.0625 + +// To calculate the cumulative distribution function (CDF) at x = 3.0 +var cdfValue = logistic.cdf(3.0, 2.0, 4.0); +console.log('CDF at x = 3.0:', cdfValue); // Output: CDF at x = 3.0: 0.5 + +// To calculate the logarithm of the cumulative distribution function (logCDF) at x = 1.0 +var logCDFValue = logistic.logcdf(1.0, 2.0, 4.0); +console.log('LogCDF at x = 1.0:', logCDFValue); + +// To calculate the logarithm of the probability density function (logPDF) at x = 4.0 +var logPDFValue = logistic.logpdf(4.0, 2.0, 4.0); +console.log('LogPDF at x = 4.0:', logPDFValue); + +// To calculate the moment-generating function (MGF) at t = 0.5 +var mgfValue = logistic.mgf(0.5, 2.0, 4.0); +console.log('MGF at t = 0.5:', mgfValue); + +// To calculate the quantile function at p = 0.95 +var quantileValue = logistic.quantile(0.95, 2.0, 4.0); +console.log('Quantile at p = 0.95:', quantileValue); + +// To calculate the differential entropy +var entropyValue = logistic.entropy(2.0, 4.0); +console.log('Differential Entropy:', entropyValue); + +// To calculate the excess kurtosis +var kurtosisValue = logistic.kurtosis(2.0, 4.0); +console.log('Excess Kurtosis:', kurtosisValue); + +// To calculate the expected value (mean) +var meanValue = logistic.mean(2.0, 4.0); +console.log('Expected Value (Mean):', meanValue); + +// To calculate the median +var medianValue = logistic.median(2.0, 4.0); +console.log('Median:', medianValue); + +// To calculate the mode +var modeValue = logistic.mode(2.0, 4.0); +console.log('Mode:', modeValue); + +// To calculate the skewness +var skewnessValue = logistic.skewness(2.0, 4.0); +console.log('Skewness:', skewnessValue); + +// To calculate the standard deviation +var stdevValue = logistic.stdev(2.0, 4.0); +console.log('Standard Deviation:', stdevValue); + +// To calculate the variance +var varianceValue = logistic.variance(2.0, 4.0); +console.log('Variance:', varianceValue); + ``` +