141120 Random

pseudorandom:伪随机

maintain:保持,维持,维护

/**
     * Creates a new random number generator using a single {@code long} seed.
     * The seed is the initial value of the internal state of the pseudorandom
     * number generator which is maintained by method {@link #next}.
     *
     * <p>The invocation {@code new Random(seed)} is equivalent to:
     *  <pre> {@code
     * Random rnd = new Random();
     * rnd.setSeed(seed);}</pre>
     *
     * @param seed the initial seed
     * @see   #setSeed(long)
     */
    public Random(long seed) {
        this.seed = new AtomicLong(0L);
        setSeed(seed);
    }

approximate:约莫的 大概的 接近于;近似于

uniformly:统一的

distribute:分布,分配

/**
     * Returns the next pseudorandom, uniformly distributed {@code int}
     * value from this random number generator‘s sequence. The general
     * contract of {@code nextInt} is that one {@code int} value is
     * pseudorandomly generated and returned. All 2<font size="-1"><sup>32
     * </sup></font> possible {@code int} values are produced with
     * (approximately) equal probability.
     *
     * <p>The method {@code nextInt} is implemented by class {@code Random}
     * as if by:
     *  <pre> {@code
     * public int nextInt() {
     *   return next(32);
     * }}</pre>
     *
     * @return the next pseudorandom, uniformly distributed {@code int}
     *         value from this random number generator‘s sequence
     */
    public int nextInt() {
	return next(32);
    }

时间: 2024-11-08 21:44:19

141120 Random的相关文章

numpy的random模块

[说明] 翻译自官网的文档. 随机抽样 (numpy.random) 简单的随机数据 rand(d0, d1, ..., dn) 随机值 >>> np.random.rand(3,2) array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random randn(d0, d1, ..., dn) 返回一个样本,具有标准正态分布.

[TypeScript] Create random integers in a given range

Learn how to create random integers using JavaScript / TypeScript. /** * Returns a random int between * @param start inclusive * @param before exclusive */ export function randomInt(start: number, before: number) { return start + Math.floor(Math.rand

java中Random随机种子使用

在java中,通过Random生成随机数时,如果设置随机种子,则相同的种子,产生的随机数相同.若不设置则每次随机的不同. Random rnd = new Random(); rnd.setSeed(10);//用于设置种子. rnd.nextInt();// 用于产生随机数. rnd.nextInt(10); // 产生(0-9)数字.

random模块

首先random函数并不是一个真正的随机数,而是根据随机数算法算出来的数 random 函数返回一个从 0.0 到 1.0 的随机浮点数 (包括 0.0, 但是不包括 1.0).每次,调用 random,就会的到一个随机数. >>> import random >>> random.random()  0.9536935859948081  >>> random.random()  0.40421571099356646  randint 函数接受一个

python标准库-random学习

参考资料:Python 2.7.7 documentation 参考工具:http://translate.google.cn/ random模块学习 一.Bookkeeping functions(几乎没看懂)     random.seed([x]) Initialize the basic random number generator     random.getstate() Return an object capturing the current internal state o

Python模块学习笔记— —random

Python中的random模块用于生成随机数. random.random 函数原型 random.random() 生成一个范围在[0,1)的随机浮点数. import random print random.random() random.uniform 函数原型 random.uniform(a,b) 生成一个指定范围内的随机浮点数,两个参数一个是上限,一个是下限.如果a > b,则生成的随机数范围在[b,a].否则, 范围在[a,b]. import random print rand

hdu 4790 Just Random 容斥原理+数学

Just Random Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1723    Accepted Submission(s): 483 Problem Description Coach Pang and Uncle Yang both love numbers. Every morning they play a game w

Python -- random 随机数生成

Python中的random模块用于生成随机数.下面介绍一下random模块中最常用的几个函数. random.random random.random()用于生成一个0到1的随机符点数: 0 <= n < 1.0 random.uniform random.uniform的函数原型为:random.uniform(a, b),用于生成一个指定范围内的随机符点数,两个参数其中一个是上限,一个是下限.如果a > b,则生成的随机数n: b <= n <= a.如果 a <

Java Random

http://blog.csdn.net/huangbiao86/article/details/6433964 java中Math.random()与java.util.random()的区别 public class Random1 { public static void main(String[] args) { // TODO 自动生成的方法存根 for(int i=10;i<30;i++){ System.out.println((int)(1+Math.random()*10));