@stdlib/stats-base-dists-geometric

Geometric distribution.

https://github.com/stdlib-js/stats-base-dists-geometric

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.5%) to scientific vocabulary

Keywords

discrete dist distribution geometric javascript lib library node node-js nodejs probability standard statistics stats stdlib univariate
Last synced: 6 months ago · JSON representation ·

Repository

Geometric distribution.

Basic Info
Statistics
  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
discrete dist distribution geometric javascript lib library node node-js nodejs probability standard statistics stats stdlib univariate
Created over 4 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Geometric

NPM version Build Status Coverage Status <!-- dependencies -->

Geometric distribution.

## Installation ```bash npm install @stdlib/stats-base-dists-geometric ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var geometric = require( '@stdlib/stats-base-dists-geometric' ); ``` #### geometric Geometric distribution. ```javascript var dist = geometric; // returns {...} ``` The namespace contains the following distribution functions:
- [`cdf( x, p )`][@stdlib/stats/base/dists/geometric/cdf]: geometric distribution cumulative distribution function. - [`logcdf( x, p )`][@stdlib/stats/base/dists/geometric/logcdf]: geometric distribution logarithm of cumulative distribution function. - [`logpmf( x, p )`][@stdlib/stats/base/dists/geometric/logpmf]: geometric distribution logarithm of probability mass function (PMF). - [`mgf( t, p )`][@stdlib/stats/base/dists/geometric/mgf]: geometric distribution moment-generating function (MGF). - [`pmf( x, p )`][@stdlib/stats/base/dists/geometric/pmf]: geometric distribution probability mass function (PMF). - [`quantile( r, p )`][@stdlib/stats/base/dists/geometric/quantile]: geometric distribution quantile function.
The namespace contains the following functions for calculating distribution properties:
- [`entropy( p )`][@stdlib/stats/base/dists/geometric/entropy]: geometric distribution entropy. - [`kurtosis( p )`][@stdlib/stats/base/dists/geometric/kurtosis]: geometric distribution excess kurtosis. - [`mean( p )`][@stdlib/stats/base/dists/geometric/mean]: geometric distribution expected value. - [`median( p )`][@stdlib/stats/base/dists/geometric/median]: geometric distribution median. - [`mode( p )`][@stdlib/stats/base/dists/geometric/mode]: geometric distribution mode. - [`skewness( p )`][@stdlib/stats/base/dists/geometric/skewness]: geometric distribution skewness. - [`stdev( p )`][@stdlib/stats/base/dists/geometric/stdev]: geometric distribution standard deviation. - [`variance( p )`][@stdlib/stats/base/dists/geometric/variance]: geometric distribution variance.
The namespace contains a constructor function for creating a [geometric][geometric-distribution] distribution object.
- [`Geometric( [p] )`][@stdlib/stats/base/dists/geometric/ctor]: geometric distribution constructor.
```javascript var Geometric = require( '@stdlib/stats-base-dists-geometric' ).Geometric; var dist = new Geometric( 0.2 ); var y = dist.logpmf( 3.0 ); // returns ~-2.279 y = dist.logpmf( 2.3 ); // returns -Infinity ```
## Examples ```javascript var geometricRandomFactory = require( '@stdlib/random-base-geometric' ).factory; var negativeBinomial = require( '@stdlib/stats-base-dists-negative-binomial' ); var filledarrayBy = require( '@stdlib/array-filled-by' ); var variance = require( '@stdlib/stats-strided-variance' ); var linspace = require( '@stdlib/array-base-linspace' ); var mean = require( '@stdlib/stats-strided-mean' ); var abs = require( '@stdlib/math-base-special-abs' ); var geometric = require( '@stdlib/stats-base-dists-geometric' ); // Define the success probability: var p = 0.3; // Probability of success on each trial // Generate an array of x values (number of failures before first success): var x = linspace( 0, 10, 11 ); // Geometric distribution is discrete // Compute the PMF for each x: var geometricPMF = geometric.pmf.factory( p ); var pmf = filledarrayBy( x.length, 'float64', geometricPMF ); // Compute the CDF for each x: var geometricCDF = geometric.cdf.factory( p ); var cdf = filledarrayBy( x.length, 'float64', geometricCDF ); // Output the PMF and CDF values: console.log( 'x values: ', x ); console.log( 'PMF values: ', pmf ); console.log( 'CDF values: ', cdf ); // Compute statistical properties: var theoreticalMean = geometric.mean( p ); var theoreticalVariance = geometric.variance( p ); var theoreticalSkewness = geometric.skewness( p ); var theoreticalKurtosis = geometric.kurtosis( p ); console.log( 'Theoretical Mean: ', theoreticalMean ); console.log( 'Theoretical Variance: ', theoreticalVariance ); console.log( 'Skewness: ', theoreticalSkewness ); console.log( 'Kurtosis: ', theoreticalKurtosis ); // Generate random samples from the geometric distribution: var rgeom = geometricRandomFactory( p ); var n = 1000; var samples = filledarrayBy( n, 'float64', rgeom ); // Compute sample mean and variance: var sampleMean = mean( n, samples, 1 ); var sampleVariance = variance( n, 1, samples, 1 ); console.log( 'Sample Mean: ', sampleMean ); console.log( 'Sample Variance: ', sampleVariance ); // Demonstrate the memoryless property: var s = 2.0; var t = 3.0; var prob1 = ( 1.0 - geometric.cdf( s + t - 1.0, p ) ) / ( 1.0 - geometric.cdf( s - 1.0, p ) ); var prob2 = 1.0 - geometric.cdf( t - 1.0, p ); console.log( 'P(X > s + t | X > s): ', prob1 ); console.log( 'P(X > t): ', prob2 ); console.log( 'Difference: ', abs( prob1 - prob2 ) ); // Demonstrate that the sum of k independent geometric random variables follows a negative binomial distribution: var k = 5; function drawSum() { var sum = 0; var j; for ( j = 0; j < k; j++ ) { sum += rgeom(); } return sum; } var sumSamples = filledarrayBy( n, 'float64', drawSum ); // Compute sample mean and variance for the sum: var sumSampleMean = mean( n, sumSamples, 1 ); var sumSampleVariance = variance( n, 1, sumSamples, 1 ); // Theoretical mean and variance of Negative Binomial distribution: var nbMean = negativeBinomial.mean( k, p ); var nbVariance = negativeBinomial.variance( k, p ); console.log( 'Sum Sample Mean: ', sumSampleMean ); console.log( 'Sum Sample Variance: ', sumSampleVariance ); console.log( 'Negative Binomial Mean: ', nbMean ); console.log( 'Negative Binomial Variance: ', nbVariance ); // Compare sample statistics to theoretical values: console.log( 'Difference in Mean: ', abs( nbMean - sumSampleMean ) ); console.log( 'Difference in Variance: ', abs( nbVariance - sumSampleVariance ) ); ```
* * * ## Notice This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 35
Last Year
  • Push event: 35

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 44
  • Total Committers: 1
  • Avg Commits per committer: 44.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 13
  • Committers: 1
  • Avg Commits per committer: 13.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 44
Committer Domains (Top 20 + Academic)

Packages

  • Total packages: 1
  • Total downloads:
    • npm 26 last-month
  • Total dependent packages: 4
  • Total dependent repositories: 2
  • Total versions: 11
  • Total maintainers: 4
npmjs.org: @stdlib/stats-base-dists-geometric

Geometric distribution.

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.2.2
    published over 1 year ago
  • Versions: 11
  • Dependent Packages: 4
  • Dependent Repositories: 2
  • Downloads: 26 Last month
Rankings
Dependent packages count: 4.5%
Dependent repos count: 7.6%
Average: 11.4%
Stargazers count: 14.5%
Downloads: 14.9%
Forks count: 15.4%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 6 months ago

Dependencies

package.json npm
  • @stdlib/assert-has-own-property ^0.0.x development
  • @stdlib/assert-is-function ^0.0.x development
  • @stdlib/assert-is-probability ^0.0.x development
  • @stdlib/bench ^0.0.x development
  • @stdlib/constants-float64-eps ^0.0.x development
  • @stdlib/constants-float64-ninf ^0.0.x development
  • @stdlib/constants-float64-pinf ^0.0.x development
  • @stdlib/math-base-assert-is-nan ^0.0.x development
  • @stdlib/math-base-assert-is-nonnegative-integer ^0.0.x development
  • @stdlib/math-base-assert-is-probability ^0.0.x development
  • @stdlib/math-base-special-abs ^0.0.x development
  • @stdlib/math-base-special-ceil ^0.0.x development
  • @stdlib/math-base-special-exp ^0.0.x development
  • @stdlib/math-base-special-floor ^0.0.x development
  • @stdlib/math-base-special-ln ^0.0.x development
  • @stdlib/math-base-special-log1p ^0.0.x development
  • @stdlib/math-base-special-log2 ^0.0.x development
  • @stdlib/math-base-special-max ^0.0.x development
  • @stdlib/math-base-special-pow ^0.0.x development
  • @stdlib/math-base-special-round ^0.0.x development
  • @stdlib/math-base-special-sqrt ^0.0.x development
  • @stdlib/random-base-randu ^0.0.x development
  • @stdlib/string-format ^0.0.x development
  • @stdlib/utils-constant-function ^0.0.x development
  • @stdlib/utils-define-nonenumerable-read-only-accessor ^0.0.x development
  • @stdlib/utils-define-nonenumerable-read-only-property ^0.0.x development
  • @stdlib/utils-define-property ^0.0.x development
  • @stdlib/utils-keys ^0.0.x development
  • istanbul ^0.4.1 development
  • tap-spec 5.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/stats-base-dists-geometric-cdf ^0.0.x
  • @stdlib/stats-base-dists-geometric-ctor ^0.0.x
  • @stdlib/stats-base-dists-geometric-entropy ^0.0.x
  • @stdlib/stats-base-dists-geometric-kurtosis ^0.0.x
  • @stdlib/stats-base-dists-geometric-logcdf ^0.0.x
  • @stdlib/stats-base-dists-geometric-logpmf ^0.0.x
  • @stdlib/stats-base-dists-geometric-mean ^0.0.x
  • @stdlib/stats-base-dists-geometric-median ^0.0.x
  • @stdlib/stats-base-dists-geometric-mgf ^0.0.x
  • @stdlib/stats-base-dists-geometric-mode ^0.0.x
  • @stdlib/stats-base-dists-geometric-pmf ^0.0.x
  • @stdlib/stats-base-dists-geometric-quantile ^0.0.x
  • @stdlib/stats-base-dists-geometric-skewness ^0.0.x
  • @stdlib/stats-base-dists-geometric-stdev ^0.0.x
  • @stdlib/stats-base-dists-geometric-variance ^0.0.x
  • @stdlib/utils-define-read-only-property ^0.0.x
.github/workflows/benchmark.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite