Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Dec 25, 2024
1 parent c6a0e9c commit 14b6848
Show file tree
Hide file tree
Showing 13 changed files with 706 additions and 1 deletion.
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,28 @@ This release closes the following issue:

<!-- /.package -->

<section class="package" id="stats-base-dists-planck-mean-unreleased">

#### [@stdlib/stats/base/dists/planck/mean](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/planck/mean)

<details>

<section class="features">

##### Features

- [`56801e8`](https://github.com/stdlib-js/stdlib/commit/56801e8c64bc227a69e9b9b811d74994f2ad88a1) - add `stats/base/dists/planck/mean` [(#3942)](https://github.com/stdlib-js/stdlib/pull/3942)

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="stats-base-dists-poisson-mean-unreleased">

#### [@stdlib/stats/base/dists/poisson/mean](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/dists/poisson/mean)
Expand Down Expand Up @@ -2882,14 +2904,15 @@ A total of 85 issues were closed in this release:

### Contributors

A total of 17 people contributed to this release. Thank you to the following contributors:
A total of 18 people contributed to this release. Thank you to the following contributors:

- Aadish Jain
- Aayush Khanna
- Athan Reines
- Desh Deepak Kant
- Divyansh Seth
- Gururaj Gurram
- Jaysukh Makvana
- Kohantika Nath
- Manvith M
- Neeraj Pathak
Expand All @@ -2912,6 +2935,7 @@ A total of 17 people contributed to this release. Thank you to the following con

<details>

- [`56801e8`](https://github.com/stdlib-js/stdlib/commit/56801e8c64bc227a69e9b9b811d74994f2ad88a1) - **feat:** add `stats/base/dists/planck/mean` [(#3942)](https://github.com/stdlib-js/stdlib/pull/3942) _(by Jaysukh Makvana, Athan Reines, stdlib-bot)_
- [`ad690a4`](https://github.com/stdlib-js/stdlib/commit/ad690a448fa6f7dc3bb358dbd031c9d6d9bbdb90) - **refactor:** update `stats/base/drange` native addon from C++ to C [(#4216)](https://github.com/stdlib-js/stdlib/pull/4216) _(by Vivek maurya)_
- [`51565a4`](https://github.com/stdlib-js/stdlib/commit/51565a4e5125fb8e7bf2a640e1bcb1f3647e50e3) - **refactor:** update `stats/base/sstdevyc` native addon from C++ to C [(#4208)](https://github.com/stdlib-js/stdlib/pull/4208) _(by Vinit Pandit, Athan Reines)_
- [`1223597`](https://github.com/stdlib-js/stdlib/commit/1223597e150b36a74a6a9d7deb9a0804db51387c) - **refactor:** update `stats/base/svariance` native addon from C++ to C [(#4213)](https://github.com/stdlib-js/stdlib/pull/4213) _(by Vinit Pandit, Athan Reines)_
Expand Down
139 changes: 139 additions & 0 deletions base/dists/planck/mean/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<!--
@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.
-->

# Mean

> Planck distribution [expected value][expected-value].
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

The [expected value][expected-value] for a Planck random variable is

<!-- <equation class="equation" label="eq:planck_expectation" align="center" raw="\mathbb{E}\left[ X \right] = \frac{1}{e^{\lambda} - 1}" alt="Expected value for a Planck distribution."> -->

```math
\mathbb{E}\left[ X \right] = \frac{1}{e^{\lambda} - 1}
```

<!-- </equation> -->

where `λ` is the shape parameter.

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var mean = require( '@stdlib/stats/base/dists/planck/mean' );
```

#### mean( lambda )

Returns the [expected value][expected-value] of a Planck distribution with shape parameter `lambda`.

```javascript
var v = mean( 0.1 );
// returns ~9.5083

v = mean( 0.5 );
// returns ~1.5415
```

If provided a shape parameter `lambda` which is nonpositive or `NaN`, the function returns `NaN`.

```javascript
var v = mean( NaN );
// returns NaN

v = mean( -1.5 );
// returns NaN
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var uniform = require( '@stdlib/random/array/uniform' );
var mean = require( '@stdlib/stats/base/dists/planck/mean' );

var lambda = uniform( 10, 0.1, 10.0 );

var v;
var i;
for ( i = 0; i < 10; i++ ) {
v = mean( lambda[ i ] );
console.log( 'λ: %d, E(X;λ): %d', lambda[ i ].toFixed( 4 ), v.toFixed( 4 ) );
}
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[expected-value]: https://en.wikipedia.org/wiki/Expected_value

</section>

<!-- /.links -->
52 changes: 52 additions & 0 deletions base/dists/planck/mean/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @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 bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var mean = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var lambda;
var y;
var i;

lambda = uniform( 100, 0.1, 10.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = mean( lambda[ i % lambda.length ] );
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();
});
26 changes: 26 additions & 0 deletions base/dists/planck/mean/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

{{alias}}( λ )
Returns the expected value of a Planck distribution with shape parameter λ.

If `λ <= 0`, the function returns `NaN`.

Parameters
----------
λ: number
Shape parameter.

Returns
-------
out: number
Expected value.

Examples
--------
> var v = {{alias}}( 0.1 )
~9.5083
> v = {{alias}}( 0.5 )
~1.5415

See Also
--------

52 changes: 52 additions & 0 deletions base/dists/planck/mean/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* @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.
*/

// TypeScript Version: 4.1

/**
* Returns the expected value of a Planck distribution.
*
* ## Notes
*
* - If `lambda <= 0`, the function returns `NaN`.
*
* @param lambda - shape parameter
* @returns expected value
*
* @example
* var v = mean( 0.1 );
* // returns ~9.5083
*
* @example
* var v = mean( 0.5 );
* // returns ~1.5415
*
* @example
* var v = mean( 1.1 );
* // returns ~0.4989
*
* @example
* var v = mean( NaN );
* // returns NaN
*/
declare function mean( lambda: number ): number;


// EXPORTS //

export = mean;
44 changes: 44 additions & 0 deletions base/dists/planck/mean/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* @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.
*/

import mean = require( './index' );


// TESTS //

// The function returns a number...
{
mean( 0.3 ); // $ExpectType number
}

// The compiler throws an error if the function is provided a value other than a number...
{
mean( true ); // $ExpectError
mean( false ); // $ExpectError
mean( null ); // $ExpectError
mean( undefined ); // $ExpectError
mean( '5' ); // $ExpectError
mean( [] ); // $ExpectError
mean( {} ); // $ExpectError
mean( ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided insufficient arguments...
{
mean(); // $ExpectError
}
Loading

0 comments on commit 14b6848

Please sign in to comment.