python拟合节距正态分布_使用python中的对数轴缩放和拟合对数正态分布

Primer..

6

从我在你@Warren Weckesser原来答案理解下文称到 "所有你需要做的"是:

写的近似cdf(b) - cdf(a)为

cdf(b) - cdf(a) = pdf(m)*(b - a)

其中m为,比如说,在时间间隔的中点[A,B]

我们可以尝试遵循他的建议,并根据箱子的中心点绘制两种获取pdf值的方法:

具有PDF功能

具有CDF功能:

import numpy as np

import matplotlib.pyplot as plt

from scipy import stats

# generate log-normal distributed set of samples

np.random.seed(42)

samples = np.random.lognormal(mean=1, sigma=.4, size=10000)

N_bins = 50

# make a fit to the samples

shape, loc, scale = stats.lognorm.fit(samples, floc=0)

x_fit = np.linspace(samples.min(), samples.max(), 100)

samples_fit = stats.lognorm.pdf(x_fit, shape, loc=loc, scale=scale)

# plot a histrogram with linear x-axis

fig, (ax1, ax2) = plt.subplots(1,2, figsize=(10,5), gridspec_kw={'wspace':0.2})

counts, bin_edges, ignored = ax1.hist(samples, N_bins, histtype='stepfilled', alpha=0.4,

label='histogram')

# calculate area of histogram (area under PDF should be 1)

area_hist = ((bin_edges[1:] - bin_edges[:-1]) * counts).sum()

# plot fit into histogram

ax1.plot(x

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值