• random


    np.random模块

    1、rand(d0, d1, ..., dn)

    Random values in a given shape.

    Create an array of the given shape and populate it with random samples from a uniform distribution over [0,1).

    2、randn(d0, d1, ..., dn)

    Return a sample (or samples) from the “standard normal” distribution.

    3、randint(low[, high, size, dtype])

    Return random integers from low (inclusive) to high (exclusive).

    Return random integers from the “discrete uniform” distribution of the specified dtype in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).

    4、random_integers(low[, high, size])

    Random integers of type np.int between low and high, inclusive.

    5、random_sample([size])

    Return random floats in the half-open interval [0.0, 1.0).

    Results are from the “continuous uniform” distribution over the stated interval. To sample Unif[a, b), b > a multiply the output of random_sample by (b-a) and add a:

    6、random([size])

    Return random floats in the half-open interval [0.0, 1.0).

    7、ranf([size])

    Return random floats in the half-open interval [0.0, 1.0).

    8、sample([size])

    Return random floats in the half-open interval [0.0, 1.0).

    9、choice(a[, size, replace, p])

    Generates a random sample from a given 1-D array

    10、bytes(length) Return random bytes.

    1、np.ones(shape, dtype=None, order=’C’)

    Return a new array of given shape and type, filled with ones.

    2、np.zeros(shape, dtype=float, order=’C’)

    Return a new array of given shape and type, filled with zeros.

    3、np.eye(N, M=None, k=0, dtype=<type ‘float’>)
    Return a 2-D array with ones on the diagonal and zeros elsewhere.

    内置random模块

    1、random.gauss(mu, sigma)  Gaussian distribution高斯分布

    mu-->mean, sigma-->standard deviation

    2、random.normavariate(mu, sigma)  Nomal distribution正态分布

    mu-->mean, sigma-->standard deviation

    3、random.shuffle(x, random=None)

    shuffle list x in place and return None.原地清洗列表x并返回None

    4、random.choice(seq)

    Choose a random element from a non-empty sequence.从非空序列中随机选择一个元素。

    5、random.randint(a, b)

    Return random integer in range [a, b], including both end points.从闭区间[a,b]返回一个随机整数.

    6、random.random()  在区间[0, 1)随机生成一个小数

    7、random.uniform(a, b)

    Get a random number in the range [a, b) or [a, b] depending on rounding.根据数值修约在区间[a, b]返回一个随机数

  • 相关阅读:
    eureka 注册中心(单机版)
    金蝶实际成本培训01
    查看WIN10内核
    金蝶K3 WISE 15.0 GUID
    win10卸载系统自带office365
    金蝶K3wise15.0BOM维护默认只能查看登录账户作为建立人的BOM清单
    阿里云邮箱代收邮件
    金蝶寄售业务流程
    转-商品流通企业代销商品核算方法
    转-ERP待检仓、代管仓、赠品仓
  • 原文地址:https://www.cnblogs.com/yl153/p/6849254.html
Copyright © 2020-2023  润新知