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 28, 2024
1 parent 67011d2 commit 60f3c00
Show file tree
Hide file tree
Showing 17 changed files with 1,932 additions and 1,617 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/index.js.map

Large diffs are not rendered by default.

204 changes: 179 additions & 25 deletions strided/exponential/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ limitations under the License.
var exponential = require( '@stdlib/random/strided/exponential' );
```

#### exponential( N, lambda, sl, out, so\[, options] )
#### exponential( N, lambda, sl, out, so )

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

Expand Down Expand Up @@ -80,6 +80,50 @@ var out = new Float64Array( 3 );
exponential( out.length, lambda1, -1, out, 1 );
```

#### exponential.ndarray( N, lambda, sl, ol, out, so, oo )

Fills a strided array with pseudorandom numbers drawn from an [exponential][@stdlib/random/base/exponential] distribution using alternative indexing semantics.

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

// Create an array:
var out = new Float64Array( 10 );

// Fill the array with pseudorandom numbers:
exponential.ndarray( out.length, [ 2.0 ], 0, 0, out, 1, 0 );
```

The function has the following additional parameters:

- **ol**: starting index for `lambda`.
- **oo**: starting index for `out`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameters support indexing semantics based on starting indices. For example, to access every other value in `out` starting from the second value,

```javascript
var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];

exponential.ndarray( 3, [ 2.0 ], 0, 0, out, 2, 1 );
```

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

Returns a function for filling strided arrays with pseudorandom numbers drawn from an [exponential][@stdlib/random/base/exponential] distribution.

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

var random = exponential.factory();
// returns <Function>

// Create an array:
var out = new Float64Array( 10 );

// Fill the array with pseudorandom numbers:
random( out.length, [ 2.0 ], 0, out, 1 );
```

The function accepts the following `options`:

- **prng**: pseudorandom number generator for generating uniformly distributed pseudorandom numbers on the interval `[0,1)`. If provided, the function **ignores** both the `state` and `seed` options. In order to seed the underlying pseudorandom number generator, one must seed the provided `prng` (assuming the provided `prng` is seedable).
Expand All @@ -96,9 +140,10 @@ var minstd = require( '@stdlib/random/base/minstd' );
var opts = {
'prng': minstd.normalized
};
var random = exponential.factory( opts );

var out = new Float64Array( 10 );
exponential( out.length, [ 2.0 ], 0, out, 1, opts );
random( out.length, [ 2.0 ], 0, out, 1 );
```

To seed the underlying pseudorandom number generator, set the `seed` option.
Expand All @@ -109,64 +154,166 @@ var Float64Array = require( '@stdlib/array/float64' );
var opts = {
'seed': 12345
};
var random = exponential.factory( opts );

var out = new Float64Array( 10 );
exponential( out.length, [ 2.0 ], 0, out, 1, opts );
random( out.length, [ 2.0 ], 0, out, 1 );
```

#### exponential.ndarray( N, lambda, sl, ol, out, so, oo\[, options] )
* * *

Fills a strided array with pseudorandom numbers drawn from an [exponential][@stdlib/random/base/exponential] distribution using alternative indexing semantics.
#### random.PRNG

The underlying pseudorandom number generator.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var prng = exponential.PRNG;
// returns <Function>
```

// Create an array:
var out = new Float64Array( 10 );
#### exponential.seed

// Fill the array with pseudorandom numbers:
exponential.ndarray( out.length, [ 2.0 ], 0, 0, out, 1, 0 );
The value used to seed the underlying pseudorandom number generator.

```javascript
var seed = exponential.seed;
// returns <Uint32Array>
```

The function has the following additional parameters:
If the `factory` method is provided a PRNG for uniformly distributed numbers, the associated property value on the returned function is `null`.

- **ol**: starting index for `lambda`.
- **oo**: starting index for `out`.
```javascript
var minstd = require( '@stdlib/random/base/minstd-shuffle' ).normalized;

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameters support indexing semantics based on starting indices. For example, to access every other value in `out` starting from the second value,
var random = exponential.factory({
'prng': minstd
});
// returns <Function>

var seed = random.seed;
// returns null
```

#### exponential.seedLength

Length of underlying pseudorandom number generator seed.

```javascript
var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
var len = exponential.seedLength;
// returns <number>
```

exponential.ndarray( 3, [ 2.0 ], 0, 0, out, 2, 1 );
If the `factory` method is provided a PRNG for uniformly distributed numbers, the associated property value on the returned function is `null`.

```javascript
var minstd = require( '@stdlib/random/base/minstd-shuffle' ).normalized;

var random = exponential.factory({
'prng': minstd
});
// returns <Function>

var len = random.seedLength;
// returns null
```

#### exponential.state

Writable property for getting and setting the underlying pseudorandom number generator state.

```javascript
var state = exponential.state;
// returns <Uint32Array>
```

If the `factory` method is provided a PRNG for uniformly distributed numbers, the associated property value on the returned function is `null`.

```javascript
var minstd = require( '@stdlib/random/base/minstd-shuffle' ).normalized;

var random = exponential.factory({
'prng': minstd
});
// returns <Function>

var state = random.state;
// returns null
```

#### exponential.stateLength

Length of underlying pseudorandom number generator state.

```javascript
var len = exponential.stateLength;
// returns <number>
```

The function accepts the same `options` as documented above for `exponential()`.
If the `factory` method is provided a PRNG for uniformly distributed numbers, the associated property value on the returned function is `null`.

```javascript
var minstd = require( '@stdlib/random/base/minstd-shuffle' ).normalized;

var random = exponential.factory({
'prng': minstd
});
// returns <Function>

var len = random.stateLength;
// returns null
```

#### exponential.byteLength

Size (in bytes) of underlying pseudorandom number generator state.

```javascript
var sz = exponential.byteLength;
// returns <number>
```

If the `factory` method is provided a PRNG for uniformly distributed numbers, the associated property value on the returned function is `null`.

```javascript
var minstd = require( '@stdlib/random/base/minstd-shuffle' ).normalized;

var random = exponential.factory({
'prng': minstd
});
// returns <Function>

var sz = random.byteLength;
// returns null
```

</section>

<!-- /.usage -->

<section class="notes">

* * *

## Notes

- If `N <= 0`, both functions leave the output array unchanged.
- Both functions support array-like objects having getter and setter accessors for array element access.
- If `N <= 0`, both `exponential` and `exponential.ndarray` leave the output array unchanged.
- Both `exponential` and `exponential.ndarray` support array-like objects having getter and setter accessors for array element access.

</section>

<!-- /.notes -->

<section class="examples">

* * *

## Examples

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

```javascript
var zeros = require( '@stdlib/array/zeros' );
var zeroTo = require( '@stdlib/array/base/zero-to' );
var zeroTo = require( '@stdlib/array/zero-to' );
var logEach = require( '@stdlib/console/log-each' );
var exponential = require( '@stdlib/random/strided/exponential' );

Expand All @@ -175,20 +322,27 @@ var opts = {
'seed': 1234
};

// Create a seeded PRNG:
var rand1 = exponential.factory( opts );

// Create an array:
var x1 = zeros( 10, 'float64' );

// Create a list of indices:
var idx = zeroTo( x1.length );

// Fill the array with pseudorandom numbers:
exponential( x1.length, [ 2.0 ], 0, x1, 1, opts );
rand1( x1.length, [ 2.0 ], 0, x1, 1 );

// Create another function for filling strided arrays:
var rand2 = exponential.factory( opts );
// returns <Function>

// Create a second array:
var x2 = zeros( 10, 'generic' );

// Fill the array with the same pseudorandom numbers:
exponential( x2.length, [ 2.0 ], 0, x2, 1, opts );
rand2( x2.length, [ 2.0 ], 0, x2, 1 );

// Create a list of indices:
var idx = zeroTo( x1.length, 'generic' );

// Print the array contents:
logEach( 'x1[%d] = %.2f; x2[%d] = %.2f', idx, x1, idx, x2 );
Expand Down
107 changes: 0 additions & 107 deletions strided/exponential/benchmark/benchmark.float64.broadcast.options.js

This file was deleted.

Loading

0 comments on commit 60f3c00

Please sign in to comment.