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 32c5d96 commit cd0e7e7
Show file tree
Hide file tree
Showing 63 changed files with 4,999 additions and 757 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

22 changes: 22 additions & 0 deletions array/exponential/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ var out = exponential( 10, 2.0, opts );
// returns [...]
```

#### exponential.assign( lambda, out )

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

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

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

var out = exponential.assign( 2.0, x );
// returns <Float64Array>

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

The function has the following parameters:

- **lambda**: rate parameter.
- **out**: output array.

#### exponential.factory( \[lambda, ]\[options] )

Returns a function for creating arrays containing pseudorandom numbers drawn from an [exponential][@stdlib/random/base/exponential] distribution.
Expand Down
97 changes: 97 additions & 0 deletions array/exponential/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 exponential = 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 = exponential.assign( 2.0, 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/exponential/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 exponential = 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 = exponential.assign( 2.0, 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();
97 changes: 97 additions & 0 deletions array/exponential/benchmark/benchmark.generic.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 exponential = 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, 'generic' );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
o = exponential.assign( 2.0, 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=generic,len='+len, f );
}
}

main();
26 changes: 26 additions & 0 deletions array/exponential/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@
<Float64Array>


{{alias}}.assign( lambda, out )
Fills an array with pseudorandom numbers drawn from an exponential
distribution.

Parameters
----------
lambda: number
Rate parameter.

out: Array<number>|Float64Array|Float32Array
Output array.

Returns
-------
out: Array<number>|Float64Array|Float32Array
Output array.

Examples
--------
> var x = {{alias:@stdlib/array/zeros}}( 3, 'float64' );
> var out = {{alias}}.assign( 2.0, x )
<Float64Array>
> var bool = ( out === x )
true


{{alias}}.factory( [lambda, ][options] )
Returns a function for creating arrays containing pseudorandom numbers drawn
from an exponential distribution.
Expand Down
Loading

0 comments on commit cd0e7e7

Please sign in to comment.