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 Jan 5, 2024
1 parent cd0e7e7 commit b57859d
Show file tree
Hide file tree
Showing 18 changed files with 567 additions and 26 deletions.
14 changes: 7 additions & 7 deletions array/exponential/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ interface PRNG {
*/
interface UnaryFunction extends PRNG {
/**
* Returns an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Returns an array containing pseudorandom numbers drawn from an exponential distribution.
*
* @param len - array length
* @param options - function options
Expand All @@ -122,7 +122,7 @@ interface UnaryFunction extends PRNG {
( len: number, options?: Options ): RandomArray;

/**
* Fills an array with pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Fills an array with pseudorandom numbers drawn from an exponential distribution.
*
* @param out - output array
* @returns output array
Expand All @@ -135,7 +135,7 @@ interface UnaryFunction extends PRNG {
*/
interface BinaryFunction extends PRNG {
/**
* Returns an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Returns an array containing pseudorandom numbers drawn from an exponential distribution.
*
* @param len - array length
* @param lambda - rate parameter
Expand All @@ -145,7 +145,7 @@ interface BinaryFunction extends PRNG {
( len: number, lambda: number, options?: Options ): RandomArray;

/**
* Fills an array with pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Fills an array with pseudorandom numbers drawn from an exponential distribution.
*
* @param lambda - rate parameter
* @param out - output array
Expand All @@ -159,7 +159,7 @@ interface BinaryFunction extends PRNG {
*/
interface Random extends PRNG {
/**
* Returns an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Returns an array containing pseudorandom numbers drawn from an exponential distribution.
*
* @param len - array length
* @param lambda - rate parameter
Expand All @@ -173,7 +173,7 @@ interface Random extends PRNG {
( len: number, lambda: number, options?: Options ): RandomArray;

/**
* Fills an array with pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Fills an array with pseudorandom numbers drawn from an exponential distribution.
*
* @param lambda - rate parameter
* @param out - output array
Expand Down Expand Up @@ -249,7 +249,7 @@ interface Random extends PRNG {
}

/**
* Returns an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Returns an array containing pseudorandom numbers drawn from an exponential distribution.
*
* @param len - array length
* @param lambda - rate parameter
Expand Down
2 changes: 1 addition & 1 deletion array/exponential/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ import random = require( './index' );
const x = zeros( 10, 'float64' );

random.assign(); // $ExpectError
random.assign( 2.0 ); // $ExpectError
random.assign( x ); // $ExpectError
random.assign( x, 2.0, {} ); // $ExpectError
}

Expand Down
2 changes: 1 addition & 1 deletion array/exponential/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Create an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Create an array containing pseudorandom numbers drawn from an exponential distribution.
*
* @module @stdlib/random/array/exponential
*
Expand Down
2 changes: 1 addition & 1 deletion array/exponential/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var factory = require( './factory.js' );
// MAIN //

/**
* Returns an array containing pseudorandom numbers drawn from an exponential distribution with rate parameter `lambda`.
* Returns an array containing pseudorandom numbers drawn from an exponential distribution.
*
* @name exponential
* @type {Function}
Expand Down
22 changes: 22 additions & 0 deletions array/geometric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ var out = geometric( 10, 0.01, opts );
// returns [...]
```

#### geometric.assign( p, out )

Fills an array with pseudorandom numbers drawn from a [geometric][@stdlib/random/base/geometric] distribution.

```javascript
var zeros = require( '@stdlib/array/zeros' );

var x = zeros( 10, 'float64' );
// returns <Float64Array>

var out = geometric.assign( 0.01, x );
// returns <Float64Array>

var bool = ( out === x );
// returns true
```

The function has the following parameters:

- **p**: success probability.
- **out**: output array.

#### geometric.factory( \[p, ]\[options] )

Returns a function for creating arrays containing pseudorandom numbers drawn from a [geometric][@stdlib/random/base/geometric] distribution.
Expand Down
97 changes: 97 additions & 0 deletions array/geometric/benchmark/benchmark.float32.assign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var zeros = require( '@stdlib/array/zeros' );
var pkg = require( './../package.json' ).name;
var geometric = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var out;
var o;
var i;

out = zeros( len, 'float32' );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
o = geometric.assign( 0.01, out );
if ( isnan( o[ i%len ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( o[ i%len ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':assign:dtype=float32,len='+len, f );
}
}

main();
97 changes: 97 additions & 0 deletions array/geometric/benchmark/benchmark.float64.assign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var zeros = require( '@stdlib/array/zeros' );
var pkg = require( './../package.json' ).name;
var geometric = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var out;
var o;
var i;

out = zeros( len, 'float64' );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
o = geometric.assign( 0.01, out );
if ( isnan( o[ i%len ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( o[ i%len ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':assign:dtype=float64,len='+len, f );
}
}

main();
Loading

0 comments on commit b57859d

Please sign in to comment.