File: stdlib_random.md

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (65 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: random
---

# Statistical Distributions -- Pseudorandom Number Generator Module

[TOC]

## `random_seed` - set or get a value of seed to the probability distribution pseudorandom number generator

### Status

Experimental

### Description

Set or get the seed value before calling the probability distribution pseudorandom number generator for variates.

### Syntax

`call ` [[stdlib_random(module):random_seed(interface)]] `(put, get)`

### Arguments

`put`: argument has `intent(in)` and may be a scalar of type `integer`.

`get`: argument has `intent(out)` and is a scalar of type `integer`.

### Return value

Return a scalar of type `integer`.

### Example

```fortran
{!example/random/example_random_seed.f90!}
```

## `dist_rand` - Get a random integer with specified kind

### Status

Experimental

### Description

Generate an integer pseudorandom number in a specific range [-2^k, 2^k - 1] according to the input integer kind n. This pseudorandom number will be operated by bit opeartors instead of normal arithmetic operators.

### Syntax

`result = ` [[stdlib_random(module):dist_rand(interface)]] `(n)`

### Arguments

`n`: argument has `intent(in)` is a scalar of type `integer`.

### Return value

Return a scalar of type `integer`.

### Example

```fortran
{!example/random/example_dist_rand.f90!}
```