Python method to generate random numbers with any range and any precision

不言
Release: 2018-04-09 15:00:30
Original
3807 people have browsed it

The following is a Python method for generating random numbers with any range and any precision. It has certain reference value and I hope it will be helpful to everyone.

An example is as follows:

# -*- coding: utf-8 -*-
import numpy as np
random = np.random.RandomState(0)#RandomState生成随机数种子
for i in range(200):#随机数个数
 a = random.uniform(-0.1, 0.1)#随机数范围
 print round(a, 2)#随机数精度要求
Copy after login


The above is the detailed content of Python method to generate random numbers with any range and any precision. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template