Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.04 KB

byte.md

File metadata and controls

63 lines (41 loc) · 1.04 KB

byte

Fill a byte buffer with random values.

API

Numeric.random.byte(length, generator)

Fills a byte buffer with uniform random values.

  • Parameters:
    • length: Number of bytes to generate
    • generator: Generator supplying uniform samples
  • Returns: Buffer of random byte values
  • NumPy: Equivalent to Generator.bytes.

Examples

Generate four bytes

import Numeric from '@neabyte/numerix'

const bytes = Numeric.random.byte(4, Numeric.random.seed(42))

console.log(Array.from(bytes))
// [0,169,28,217]

Generate a single byte

import Numeric from '@neabyte/numerix'

const bytes = Numeric.random.byte(1, Numeric.random.seed(42))

console.log(Array.from(bytes))
// [0]

Generate an empty buffer

import Numeric from '@neabyte/numerix'

const bytes = Numeric.random.byte(0, Numeric.random.seed(42))

console.log(Array.from(bytes))
// []

Generate bytes without a generator

import Numeric from '@neabyte/numerix'

const bytes = Numeric.random.byte(4)

console.log(bytes.length)
// 4