I am trying to plot multiple gaussian plots that'll have same mean and std dev, meaning that when the first plot ends at 20, the second plot must start from 20 and end at 40 with the peak being at 30mu = 10sigma = 2n = 2x = np.linspace(0,n*20,n*20)for i in range(0,n): pdf = stats.norm.pdf(x, n*mu, sigma) plt.plot(x, pdf)但这只给了我一个图作为图像but this gives me just one plot as Image我想生成的是:所需的输出有人可以告诉我我在做的错误吗?Can someone please tell me the mistake that I am doing?推荐答案首先,您的两个高斯人的均值不同,因为一个高斯数为10,另一个高斯数为30.First, your two gaussians do not have the same means, since one is at 10 and the other at 30.第二,您实际上是在创建一个高斯,平均值为 n * mu = 20 .如果您需要生成多个高斯信号,则必须多次调用 norm.pdf ,例如循环:Second, you are actually creating one one gaussian, with mean at n*mu=20. If you need to generate multiple gaussians, you'll have to call norm.pdf several times, e.g. in a loop:mus = [10,30]sigmas = [2,2]x = np.linspace(0,40,100)pdf = np.zeros(shape=x.shape)for m,s in zip(mus,sigmas): pdf += stats.norm.pdf(x, m, s)plt.plot(x, pdf) 这篇关于如何生成多个高斯图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-07 02:19