Questions tagged [scipy.stats]
297 questions
0
votes
1 answer
How does scipy.stats.binned_statistic map the sequence of bin edges to the data on which the statistic will be computed?
Take the following example from the documentation:
rng = np.random.default_rng(seed=3576)
windspeed = 8 * rng.random(500)
boatspeed = .3 * windspeed**.5 + .2 * rng.random(500)
bin_means, bin_edges, binnumber = stats.binned_statistic(windspeed,
…

neverreally
- 45
- 6
0
votes
2 answers
Not sure Kolmogorov Smirnov Test is working as it should
changed the code with the Gaussian args considering Sam Masons comment. The results are still wrong, since I know from QQ-plots the data is probably a decent Gaussian. I will try to post my updated code and attach the data file too. Perhaps it's…

NotAnotherName
- 11
- 3
0
votes
1 answer
Obtaining percentages from a 2d density plot
I've got a 2d kde plot with contours overlying a hexbin plot. I would like to set the contours and have them show as percentages. An example would be having the contours aligned with the 90% probability or 50% probability. Is there a simple method…

Scott
- 61
- 7
0
votes
1 answer
Calculating p-value with Python. One-tailed or two-tailed?
I'm using this function to calculate the p-value of an experiment I'm running. I'm not sure if it's one-tailed or two-tailed. How can I infer this from the code? Thanks
from scipy import stats
def get_pvalue(con_conv, test_conv, con_size,…

cloudycider
- 37
- 6
0
votes
1 answer
How to create an array in Pyspark with normal distribution with scipy.stats with UDF (or any other way)?
I currently working on migrate Python scripts to PySpark, I have this Python script that works fine:
### PYTHON
import pandas as pd
import scipy.stats as st
def fnNormalDistribution(mean,std, n):
box = list(eval('st.norm')(*[mean,std]).rvs(n))
…

ImNotAPanda
- 37
- 4
0
votes
1 answer
How to get the Sigma of a Rayleigh distribution in python scipy.stats
Calling
rayleigh_args = stats.rayleigh.fit(num_list)
Returns a tuple of 2 values e.g. (-320.34, 360.77).
Where I can use it to get the CDF or PDF of the distribution for a given value.
I can't find what each of those values represents.
In addition,…

George T
- 44
- 4
0
votes
0 answers
Problem with choice of distribution and right stat test
I have specific data about troubles on a plant. To analyze it, I decided to use fitter and find best distribution that fits my data. After using kstest for the best fit, I saw this strange result:
KstestResult(statistic=0.9866071428571429,…

S L
- 1
- 1
0
votes
1 answer
Can one create a distribution characterizing the multiplication of two distributions in Python?
I have two distributions and I would like to know the properties of the multiplication of these distributions.
For example, if I had the distribution of properties velocity and time, I want the characteristics of the probability distribution of…

ramzeek
- 2,226
- 12
- 23
0
votes
1 answer
Cannot import name 'threshold' from scipy.stats
I am trying to use function threshold from scipy package.
from scipy.stats import threshold
I_t=threshold(I, threshmin=2, threshmax=400, newval=-1) # I is an array containing image data
However, i am getting an error message saying
cannot import…

vashista
- 105
- 7
0
votes
0 answers
excel result and stats test are not the same for p-value
I'm trying to get the same result from this excel table, indicating that there's a link between the wight and the result (after going to the gym)
The result on the excel shows the p-value as 1.28% (for 2 tails) and 0.64% for 1 tail.
Given
weight =…

ProcolHarum
- 721
- 3
- 17
0
votes
0 answers
Curve fitting scipy.stats.multivariate_normal
I am trying to curve fit a 2D multivariate normal distribution to an image. The approach here works, however I want to parametrize the result with a covariance matrix, like in scipy.stats.multivariate_normal.
Here is my code:
def mvnorm(data_tuple,…

gopromaster
- 11
- 3
0
votes
0 answers
the mean and standard deviation aren't the same as those of the input data i provided after sampling
I have a log-normal mean and a standard deviation. after i converted them to the underlying normal distribution's parameters mu and sigma, I sampled from the log-normal distribution however when i take the mean and standard deviation of this…

codebreaker12
- 1
- 2
0
votes
1 answer
Custom pdf with parameters and support with scipy
I want to build a custom pdf using the rv_continuous class; such a pdf should depend on a couple of parameters, l1, l2, l3 in the example below. This is my attempt:
k=1
class estimated_pdf(scipy.stats.rv_continuous):
def _get_support(self, l1,…

Emanuele Giordano
- 101
- 1
0
votes
2 answers
SciPy error: RuntimeWarning: overflow encountered in _beta_ppf
My SciPy version is 1.7.3 and I'm running on an Apple M1 chip (not sure if it's relevant). My Python version is 3.9.11, installed via Annaconda.
I get the error message…

ramund
- 185
- 11
0
votes
1 answer
How to generate random number of lognormal distribution using scipy.stats lognorm with mean and standard deviation already known
I want to generate a random number of lognormal distribution using the scipy.stats lognorm. I have mean and standard deviation already give.
from scipy.stats import lognorm
sigma = 5
mean = 0
randomNumber = lognorm.rvs(sigma,…

Umair Mayo
- 43
- 7