- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想按钟声顺序生成正态分布。我使用此代码生成数字:
import numpy as np
mu,sigma,n = 0.,1.,1000
def normal(x,mu,sigma):
return ( 2.*np.pi*sigma**2. )**-.5 * np.exp( -.5 * (x-mu)**2. / sigma**2. )
x = np.random.normal(mu,sigma,n) #generate random list of points from normal distribution
y = normal(x,mu,sigma) #evaluate the probability density at each point
x,y = x[np.argsort(y)],np.sort(y) #sort according to the probability density
这是建议的代码:Generating normal distribution in order python, numpy
但数字并不遵循钟形。有任何想法吗?非常感谢
最佳答案
有几件事让您感到困惑。
random.normal 从钟形曲线中随机绘制 n
个数字
所以您有 1000 个数字,每个数字都不同,都是从曲线中绘制的。要重新创建曲线,您需要应用一些分箱。每个 bin 中的点数将重新创建曲线(仅一个点本身很难代表概率)。在只有 1000 个点的 x
向量上使用一些广泛的分箱:
h,hx=np.histogram(x,bins=50)
并绘制 h
作为 hx
的函数(所以我将你的千位数字分为 50 个 bin,y
轴将显示数量垃圾箱中的点数:
现在我们可以看到 x
是从钟形分布中抽取的 - 落入中心 bin 的机会由高斯分布决定。这是一个采样,因此每个点当然可能会有所不同 - 您使用的点越多,分箱越精细,效果就越好(更平滑)。
y = normal(x,mu,sigma)
这只是在任何给定的 x
上评估高斯分布,所以实际上,为 normal
提供围绕您的均值 (mu) 的任何数字列表,它将计算钟形曲线恰好(确切的概率)。绘制你的 y
对 x
(你的 x
本身是高斯并不重要,但它是平均值附近的 1000 点,所以它可以重新创建功能):
看看它有多流畅?那是因为它不是采样,而是函数的精确计算。您可以使用 0 附近的任何 1000 个点,它看起来同样好。
关于 python : Generate normal distribution in the order of the bell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51012793/
如果我有 distributed.Client我可以用它来关闭远程集群吗?即杀死所有 worker 并关闭调度程序? 如果使用 Client 无法做到这一点例如,除了手动杀死每个远程进程之外,还有其他
我对使用 Dask Distributed 作为任务执行器很感兴趣。 在 Celery 中,可以将任务分配给特定的 worker 。如何使用 Dask Distributed? 最佳答案 有2个选项:
我正在创建我的第一个应用程序,并且对 Ad Hoc 配置文件和开发配置文件有些困惑。我知道这个问题是在此之前提出的,但需要一些澄清和确认。 查看之前关于 stackoverflow 的答案,我认为存在
我正在尝试确定如何计算两个 torch.distribution.Distribution 对象的 KL 散度。到目前为止,我找不到执行此操作的功能。这是我尝试过的: import torch as
这听起来(比方说)幼稚,但我不知道我应该为移动 (iOS) 应用使用哪个证书。 显而易见的选项是 iOS 分发证书,但在 Apple 分发证书上,解释是: ...For use with Xcode
问题: 我的数字范围是 1 到 20,000。我想从范围内采样 8 个不同数字的均匀分布,1000 次。每个分布不应有重复的数字。此外,1000 个分布中的每个分布都必须是唯一的(在对所有获得的分布进
我对 dask 文档中的并发 future 要点有疑问:https://gist.github.com/mrocklin/ef9ccd29a6ec5f4de84d6192be95042a 当我们实例化
完成 DASK 代码后,我不断收到“distributed.utils_perf - 警告 - 完整垃圾收集最近占用了 19% CPU 时间”警告消息。我正在使用 DASK 进行大型地震数据计算。计算
场景:S3 存储桶有 1000 个文件。我有两台机器。每台机器都有两个驱动器/dev/sda 和/dev/sdb。限制:没有一个单独的驱动器可以容纳所有 1000 个文件。没有一台机器可以容纳所有 1
我已将一个项目导入 android studio 3.5,但在与 Gradle 文件同步时遇到此错误 指定的Gradle发行版'https://services.gradle.org/distribu
在 Android Studio 中创建项目时,我收到以下错误消息。 Failed to import new Gradle project: Could not install Gradle dis
在android studio 2.3.2 中运行项目时显示 Error:Could not run build action using Gradle distribution 'https://s
我正在将项目中的 gradle 版本从 1.7 升级到 4.2.1。我已将 Intellij 设置为导入 gradle 项目,但是当我单击“刷新所有 Gradle 项目”时,出现以下错误 Gradle
对于一个独特的商品销售数据库,如果我们使用顺序一致性,我们就可以保证,例如,这个独特的商品永远不会被重复卖给不同的人。因果一致性能保证我们做到这一点吗? 如果有一些销售同时开始/结束,系统会中断吗?
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
我正在使用J2ME为Nokia手机编写应用程序。 我想知道如何分发我的诺基亚应用程序。 最佳答案 分发有两个步骤 1.)使您的应用程序签名 您需要对您的应用进行签名,以便可以将其安装在诺基亚手机上。签
顺序一致性 The result of any execution is the same as if the operations of all the processors were execut
我知道三阶段提交是为了解决“两阶段提交”的问题,当在第二阶段协调器和群组同时失败时,不可能知道协调器是否决定了提交消息。 显然,三阶段提交旨在通过添加一个额外的阶段来解决这个问题。但是,如果协调器和队
我一直在研究 a project ,它是应用服务器和对象数据库的组合,目前仅在单台机器上运行。前段时间看了a paper它描述了一个分布式关系数据库,并获得了一些关于如何将该论文中的想法应用到我的项目
我想堆叠这种类型的数据集: PATIENT_ID AA BB CC DD EE 1 22 33 44 55 66 2 77 88 99 10 11 ..
我是一名优秀的程序员,十分优秀!