> For the complete documentation index, see [llms.txt](https://guanming.gitbook.io/zgg-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guanming.gitbook.io/zgg-doc/biao-zhun-ku/builtins/builtins_random.md).

# random

random提供了常用的随机数相关函数

## 函数目录

### 生成随机数

* [func random()](#random0)
* [func random(end)](#random1)
* [func random(begin, end)](#random2)

### 数组操作

* [func choice(array)](#choice)
* [func shuffle(array)](#shuffle)

## 函数详解

### func random()

返回一个取值范围在\[0, 1)之前的浮点数

### func random(end)

返回一个取值范围在\[0, end)之前的整数

### func random(begin, end)

返回一个取值范围在\[begin, end)之间的整数，如果begin >= end，抛出异常

### func choice(array)

从array中等概率随机挑选一个元素

### func shuffle(array)

原地将array内元素次序打乱
