Skip to content

Commit 97128a6

Browse files
committed
docs: rename file and update copy
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8a49f09 commit 97128a6

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

docs/user-guides/recipes/how_to_create_ndarrays_of_random_numbers.md renamed to docs/user-guides/recipes/how_to_create_an_ndarray_filled_with_random_numbers.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ limitations under the License.
1818
1919
-->
2020

21-
# How to create ndarrays of random numbers
21+
# How to create an ndarray filled with random numbers
22+
23+
> Create an ndarray of uniformly-distributed pseudorandom numbers (with optional reproducibility via a seed).
2224
2325
## Introduction
2426

25-
stdlib provides elegantly designed APIs and packages to help you create multi-dimensional arrays (a.k.a., ndarrays) containing pseudorandom numbers drawn from statistical distributions. These APIs allow you to specify seeds in order to generate reproducible sequences and to specify the output array shape and precision.
27+
stdlib provides APIs and packages to help you create multi-dimensional arrays (a.k.a., ndarrays) containing pseudorandom numbers drawn from statistical distributions. These APIs allow you to specify seeds in order to generate reproducible sequences and to specify the output array shape and precision.
2628

2729
In this recipe, we will use [`@stdlib/random/uniform`][@stdlib/random/uniform] to create ndarrays containing pseudorandom numbers drawn from a uniform distribution.
2830

@@ -40,7 +42,7 @@ $ npm install @stdlib/stdlib
4042
2. Create a multi-dimensional array.
4143
3. \[Optional] Regenerate a sequence by using a seed.
4244

43-
### 1. Import necessary packages for generating pseudorandom numbers
45+
### 1. Import required packages
4446

4547
For this recipe, we will use `@stdlib/stdlib` and its package [`@stdlib/random/uniform`][@stdlib/random/uniform]. We will also use the package [`@stdlib/ndarray/to-array`][@stdlib/ndarray/to-array] to convert an ndarray to a conventional array-of-arrays format.
4648

@@ -61,9 +63,9 @@ For this recipe, the uniform distribution has two parameters:
6163
In the following code snippet, we generate a 3x3 matrix of pseudorandom numbers sampled from a uniform distribution with minimum support `-10` and maximum support `+10`.
6264

6365
```javascript
64-
const shape = [ 3, 3 ];
65-
const a = -10.0;
66-
const b = 10.0;
66+
const shape = [ 3, 3 ]; // 3x3
67+
const a = -10.0; // minimum support
68+
const b = 10.0; // maximum support
6769

6870
const x = uniform( shape, a, b );
6971
// returns <ndarray>
@@ -78,6 +80,16 @@ const xa = ndarray2array( x );
7880

7981
The output displayed in the above example is representative, and your values are likely to differ. However, notice that, even after running the example multiple times, the values always reside on the half-open interval `[-10,10)`, as expected based on the parameterization we used above.
8082

83+
> 💡 Tip
84+
>
85+
> By default, `uniform` returns an ndarray having a `float64` data type (i.e., an ndarray of double-precision floating-point numbers). To return an ndarray having either a `float32` or `generic` data type, you can provide a `dtype` option when calling `uniform`.
86+
>
87+
> ```javascript
88+
> const x32 = uniform( shape, a, b, {
89+
> 'dtype': 'float32'
90+
> });
91+
> ```
92+
8193
At this point, we have finished creating an ndarray of pseudorandom numbers, and, now, we will reproduce the same sequence of numbers by using a seed.
8294
8395
### 3. \[Optional] Regenerate a sequence by using a seed

0 commit comments

Comments
 (0)