【问题标题】:Generating a numpy random see array of 100 random numbers drawn from a normal distribution with mean 1 and standard deviation 2生成一个 numpy 随机数请参阅从均值为 1 和标准差为 2 的正态分布中抽取的 100 个随机数数组
【发布时间】:2018-10-16 16:08:19
【问题描述】:
np.random.seed(my_seed)

from math import *
import numpy as np

A = np.arrange(100)

我有这个但是不确定如何处理平均值和标准差

【问题讨论】:

标签: python arrays numpy


【解决方案1】:

你可以用这个:

mu, sigma = 1, 2 # mean and standard deviation
s = np.random.normal(mu, sigma, 100)


#to find Standard Deviation and mean:
x = np.random.randn(100)
mean = x.mean()
std = x.std()

【讨论】:

  • 谢谢,我如何计算 A 的均值和标准差。
  • 如果使用 x = np.random.randn(100) 求均值和标准差如下:mean = x.mean() std = x.std()
  • 太棒了,如何将数组 A 转换为形状为 (10, 10) 的新数组 B。
  • 我想我已详细提供了您的问题。所有任务的实现都不是本门户的目的!
猜你喜欢
  • 2016-07-07
  • 2020-11-25
  • 2011-06-25
  • 2021-10-01
  • 2020-12-23
  • 2012-02-03
  • 1970-01-01
  • 1970-01-01
  • 2016-07-12
相关资源
最近更新 更多