🌐
SciPy
docs.scipy.org › doc › scipy › reference › stats.html
Statistical functions (scipy.stats) — SciPy v1.17.0 Manual
They can also be interpreted or ... on the mean or median of differences between paired observations). These tests are often used to assess whether there is a relationship (e.g. linear) between paired observations in multiple samples or among the coordinates of multivariate observations.
🌐
SciPy
docs.scipy.org › doc › scipy-0.8.x › reference › generated › scipy.stats.mean.html
scipy.stats.mean — SciPy v0.8 Reference Guide (DRAFT)
September 2, 2010 - scipy.stats.mean(a, axis=0)¶ · Returns the arithmetic mean of m along the given dimension. That is: (x1 + x2 + .. + xn) / n · Notes · scipy.stats.mean is deprecated; please update your code to use numpy.mean. Please note that: numpy.mean axis argument defaults to None, not 0 ·
🌐
SciPy
docs.scipy.org › doc › scipy › tutorial › stats.html
Statistics (scipy.stats) — SciPy v1.17.0 Manual
Descriptive statistics · T-test and KS-test · Tails of the distribution · Special tests for normal distributions · Comparing two samples · Comparing means · Kolmogorov-Smirnov test for two samples ks_2samp · Resampling and Monte Carlo Methods · Introduction ·
🌐
SciPy
docs.scipy.org › doc › scipy-0.7.x › reference › generated › scipy.stats.mean.html
scipy.stats.mean — SciPy v0.7 Reference Guide (DRAFT)
scipy.stats.mean(a, axis=0)¶ · Returns the arithmetic mean of m along the given dimension. That is: (x1 + x2 + .. + xn) / n · scipy.stats.hmean · scipy.stats.cmedian · Show Source · Edit page · index · modules | next | previous | Numpy and Scipy Documentation » ·
🌐
TutorialsPoint
tutorialspoint.com › scipy › scipy_stats.htm
SciPy - Stats
SciPy Stats is a module within the SciPy library in Python specifically designed for statistical analysis. SciPy is a powerful library used for scientific and numerical computations and the scipy.stats module provides a wide range of statistical
🌐
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.tmean.html
tmean — SciPy v1.17.0 Manual
scipy.stats.tmean(a, limits=None, inclusive=(True, True), axis=None, *, nan_policy='propagate', keepdims=False)[source]# Compute the trimmed mean.
🌐
SciPy
scipy.github.io › devdocs › reference › generated › scipy.stats.Normal.mean.html
mean — SciPy v1.18.0.dev Manual
scipy.stats.Normal. Normal.mean(*, method=None)[source]# Mean (raw first moment about the origin) Parameters: method{None, ‘formula’, ‘transform’, ‘quadrature’, ‘cache’} Method used to calculate the raw first moment. Not all methods are available for all distributions.
🌐
GeeksforGeeks
geeksforgeeks.org › python › scipy-stats-mean-function-python
sciPy stats.mean() function | Python - GeeksforGeeks
February 10, 2019 - scipy.stats.mean(array, axis=0) function calculates the arithmetic mean of the array elements along the specified axis of the array (list in python).
🌐
SciPy
docs.scipy.org › doc › scipy-1.16.1 › reference › generated › scipy.stats.rv_continuous.mean.html
mean — SciPy v1.16.1 Manual
scipy.stats.rv_continuous. rv_continuous.mean(*args, **kwds)[source]# Mean of the distribution. Parameters: arg1, arg2, arg3,…array_like · The shape parameter(s) for the distribution (see docstring of the instance object for more information) locarray_like, optional ·
🌐
SciPy
docs.scipy.org › doc › scipy-1.8.0 › tutorial › stats.html
Statistics (scipy.stats) — SciPy v1.8.0 Manual
To learn more about the random ... in SciPy, see non-uniform random number sampling tutorial and quasi monte carlo tutorial · All continuous distributions take loc and scale as keyword parameters to adjust the location and scale of the distribution, e.g., for the standard normal distribution, the location is the mean and the scale is the standard deviation. >>> norm.stats(loc=3, scale=4, ...
Find elsewhere
🌐
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.pmean.html
pmean — SciPy v1.17.0 Manual
This mean is also called generalized mean or Hölder mean, and must not be confused with the Kolmogorov generalized mean, also called quasi-arithmetic mean or generalized f-mean [3]. ... Input array, masked array or object that can be converted to an array. ... Exponent. Must be finite. ... If an int, the axis of the input along which to compute the statistic.
🌐
Python Guides
pythonguides.com › scipy-stats
Scipy Stats: Statistical Analysis In Python
June 20, 2025 - Before getting in, let’s make sure you have Scipy installed. It’s easy: ... Let’s start with the basics. Descriptive statistics help us understand the main features of our data. ... # Sample ages of customers ages = [24, 32, 45, 32, 56, 28, 37, 42, 32, 41] # Calculate mean mean_age = np.mean(ages) mean_age_scipy = stats.tmean(ages) # Calculate median median_age = np.median(ages) median_age_scipy = stats.mstats.mquantiles(ages, 0.5)[0] # Calculate mode (with keepdims=True to return array) mode_age = stats.mode(ages, keepdims=True) # Output print(f"Mean age: {mean_age}") print(f"Median age: {median_age}") print(f"Mode age: {mode_age.mode[0]} (occurs {mode_age.count[0]} times)")
Top answer
1 of 1
3

The scipy.stats.lognorm lognormal distribution is parameterised in a slightly unusual way, in order to be consistent with the other continuous distributions. The first argument is the shape parameter, which is your sigma. That's followed by the loc and scale arguments, which allow shifting and scaling of the distribution. Here you want loc=0.0 and scale=exp(mu). So to compute the mean, you want to do something like:

>>> import numpy as np
>>> from scipy.stats import lognorm
>>> mu = 0.4104857306
>>> sigma = 3.4070874277012617
>>> lognorm.mean(sigma, 0.0, np.exp(mu))
500.0000010889041

Or more clearly: pass the scale parameter by name, and leave the loc parameter at its default of 0.0:

>>> lognorm.mean(sigma, scale=np.exp(mu))
500.0000010889041

As @coldspeed says in his comment, your expected value for the standard deviation doesn't look right. I get:

>>> lognorm.std(sigma, scale=np.exp(mu))
165831.2402402415

and I get the same value calculating by hand.

To double check that these parameter choices are indeed giving the expected lognormal, I created a sample of a million deviates and looked at the mean and standard deviation of the log of that sample. As expected, those give me back values that look roughly like your original mu and sigma:

>>> samples = lognorm.rvs(sigma, scale=np.exp(mu), size=10**6)
>>> np.log(samples).mean()  # should be close to mu
0.4134644116056518
>>> np.log(samples).std(ddof=1)  # should be close to sigma
3.4050012251732285

In response to the edit: you've got the formula for the variance of a lognormal slightly wrong - you need to replace the exp(sigma**2 - 1) term with (exp(sigma**2) - 1). If you do that, and rerun the fsolve computation, you get:

sigma = 0.9444564779275075
mu = 5.768609079062494

And with those values, you should get the expected mean and standard deviation:

>>> from scipy.stats import lognorm
>>> import numpy as np
>>> sigma = 0.9444564779275075
>>> mu = 5.768609079062494
>>> lognorm.mean(sigma, scale=np.exp(mu))
499.9999999949592
>>> lognorm.std(sigma, scale=np.exp(mu))
599.9999996859631

Rather than using fsolve, you could also solve analytically for sigma and mu, given the desired mean and standard deviation. This gives you more accurate results, more quickly:

>>> mean = 500.0
>>> var = 600.0**2
>>> sigma = np.sqrt(np.log1p(var/mean**2))
>>> mu = np.log(mean) - 0.5*sigma*sigma
>>> mu, sigma
(5.768609078769636, 0.9444564782482624)
>>> lognorm.mean(sigma, scale=np.exp(mu))
499.99999999999966
>>> lognorm.std(sigma, scale=np.exp(mu))
599.9999999999995
🌐
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.norm.html
scipy.stats.norm — SciPy v1.17.0 Manual
scipy.stats.norm = <scipy.stats._continuous_distns.norm_gen object>[source]# A normal continuous random variable. The location (loc) keyword specifies the mean. The scale (scale) keyword specifies the standard deviation.
🌐
SciPy
docs.scipy.org › doc › scipy › reference › generated › scipy.stats.describe.html
describe — SciPy v1.17.0 Manual
>>> import numpy as np >>> from scipy import stats >>> a = np.arange(10) >>> stats.describe(a) DescribeResult(nobs=10, minmax=(0, 9), mean=4.5, variance=9.166666666666666, skewness=0.0, kurtosis=-1.2242424242424244) >>> b = [[1, 2], [3, 4]] >>> stats.describe(b) DescribeResult(nobs=2, minmax=(array([1, 2]), array([3, 4])), mean=array([2., 3.]), variance=array([2., 2.]), skewness=array([0., 0.]), kurtosis=array([-2., -2.]))
🌐
Delft Stack
delftstack.com › home › api › scipy › scipy stats mean
SciPy stats.mean Function | Delft Stack
January 30, 2023 - The scipy.stats.mean function of the SciPy library helps calculate the arithmetic mean of the elements of a given array.
🌐
SciPy
scipy.github.io › devdocs › tutorial › stats.html
Statistics (scipy.stats) — SciPy v1.18.0.dev Manual
In this tutorial, we discuss many, but certainly not all, features of scipy.stats. The intention here is to provide a user with a working knowledge of this package.
🌐
Readthedocs
elephant.readthedocs.io › en › v0.9.0 › _modules › scipy › stats › stats.html
scipy.stats.stats — Elephant 0.9.0 documentation
See Also -------- numpy.mean : Arithmetic average numpy.average : Weighted average gmean : Geometric mean Notes ----- The harmonic mean is computed over a single dimension of the input array, axis=0 by default, or all values in the array if axis=None. float64 intermediate and return values ...
🌐
GeeksforGeeks
geeksforgeeks.org › scipy-stats
SciPy - Stats - GeeksforGeeks
April 28, 2025 - There is a wide range of probability functions. ... A continuous random variable is a probability distribution when the random variable X can have any value. The mean is defined by the location (loc) keyword.
🌐
Readthedocs
elephant.readthedocs.io › en › v0.7.0 › _modules › scipy › stats › stats.html
scipy.stats.stats — Elephant 0.7.0 documentation
See Also -------- numpy.mean : Arithmetic average numpy.average : Weighted average gmean : Geometric mean Notes ----- The harmonic mean is computed over a single dimension of the input array, axis=0 by default, or all values in the array if axis=None. float64 intermediate and return values ...