What is the meaning of mu, loc and size in the scipy.stats.poisson?

时间:2018-01-23 19:17:20

标签: python scipy statistics

This Poisson doc page explains the function. The problem is that if you are not familiar with these, you can't understand what they mean. For example, I want to know where to put the mean, where the standard deviation, and where the sample size. It says that mu is a shape parameter. This doesn't help me.

In this example:

np.random.seed(6)

population_ages1 = stats.poisson.rvs(loc=18, mu=35, size=150000)
population_ages2 = stats.poisson.rvs(loc=18, mu=10, size=100000)
population_ages = np.concatenate((population_ages1, population_ages2))

minnesota_ages1 = stats.poisson.rvs(loc=18, mu=30, size=30)
minnesota_ages2 = stats.poisson.rvs(loc=18, mu=10, size=20)
minnesota_ages = np.concatenate((minnesota_ages1, minnesota_ages2))

print( population_ages.mean() )
print( minnesota_ages.mean() )

Output:

43 39

What do loc, mu and size stand for?

2 个答案:

答案 0 :(得分:3)

These are documented well enough in the common literature: location, mu, and the page you cited -- "well enough" is assuming that you're familiar enough with the field's vocabulary to work your way through the technical docs.

  • loc is the N-dimensional reference point of the distribution, that centroid being chosen appropriately to the function. For this application, it's simply the left end of the desired distribution (scalar). This defaults to 0, and is only changed if your application starts at something other than 0.
  • mu is the mean of the function.
  • size is the sample size.

The Poisson distribution has only the one shape parameter: mu. The variance, mean, and frequency are lock-stepped to each other.

答案 1 :(得分:1)

UHXW正在询问这些参数的简单含义。 Prune的答案可以简化。

loc就像分布中的最低x值,mu就像分布中的中值。看着 https://www.datacamp.com/community/tutorials/probability-distributions-python

统一函数通过loc和scale参数在指定间隔之间生成统一连续变量。 loc和loc + scale之间的分布是恒定的。 size参数描述随机变量的数量。如果要保持可重复性,请包括分配给数字的random_state参数。