rand(): number
Uniformly distributed pseudorandom numbers.
Generates uniformly distributed pseudorandom numbers. It can return:
- A single random number if no arguments are provided.
- A 2D array of random numbers if dimensions are provided.
Single random number
Single random number
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(typeof rand(), 'number');
Empty matrix
Empty matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(rand(0), []);
1x1 matrix
1x1 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result1x1 = rand(1) as matrix; assertEquals(result1x1.length, 1); assertEquals(result1x1[0].length, 1);
2x2 matrix
2x2 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result2x2 = rand(2) as matrix; assertEquals(result2x2.length, 2); assertEquals(result2x2[0].length, 2);
rand(n: number): matrix
Uniformly distributed pseudorandom numbers.
Generates uniformly distributed pseudorandom numbers. It can return:
- A single random number if no arguments are provided.
- A 2D array of random numbers if dimensions are provided.
Single random number
Single random number
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(typeof rand(), 'number');
Empty matrix
Empty matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(rand(0), []);
1x1 matrix
1x1 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result1x1 = rand(1) as matrix; assertEquals(result1x1.length, 1); assertEquals(result1x1[0].length, 1);
2x2 matrix
2x2 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result2x2 = rand(2) as matrix; assertEquals(result2x2.length, 2); assertEquals(result2x2[0].length, 2);
A random number or a matrix of random numbers
rand(dims: array): matrix
Uniformly distributed pseudorandom numbers.
Generates uniformly distributed pseudorandom numbers. It can return:
- A single random number if no arguments are provided.
- A 2D array of random numbers if dimensions are provided.
Single random number
Single random number
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(typeof rand(), 'number');
Empty matrix
Empty matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(rand(0), []);
1x1 matrix
1x1 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result1x1 = rand(1) as matrix; assertEquals(result1x1.length, 1); assertEquals(result1x1[0].length, 1);
2x2 matrix
2x2 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result2x2 = rand(2) as matrix; assertEquals(result2x2.length, 2); assertEquals(result2x2[0].length, 2);
dims: array
A random number or a matrix of random numbers
rand(rows: number,cols: number,): matrix
Uniformly distributed pseudorandom numbers.
Generates uniformly distributed pseudorandom numbers. It can return:
- A single random number if no arguments are provided.
- A 2D array of random numbers if dimensions are provided.
Single random number
Single random number
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(typeof rand(), 'number');
Empty matrix
Empty matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; assertEquals(rand(0), []);
1x1 matrix
1x1 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result1x1 = rand(1) as matrix; assertEquals(result1x1.length, 1); assertEquals(result1x1[0].length, 1);
2x2 matrix
2x2 matrix
import { assertEquals } from "jsr:@std/assert"; import type { matrix } from "../types.d.ts"; const result2x2 = rand(2) as matrix; assertEquals(result2x2.length, 2); assertEquals(result2x2[0].length, 2);
A random number or a matrix of random numbers