Questions tagged [scipy.stats]

297 questions
0
votes
0 answers

Estimating the "probability of a sample belonging to a distribution" using scipy.stats.gaussian_kde

I have fit KDEs in two different data sources and would like to get to a "score" that estimates how likely a new sample is to belong to data source 1 or 2. Assuming I fit the KDEs with something like this: data1 = np.random((5000))+1. data2 =…
f.leno
  • 151
  • 1
  • 7
0
votes
0 answers

Unexpected result from Kolmogorov-Smirnov test

I have this code to check the Kolmogorov-Smirnov test. But it gives the wrong result. What is the problem? import pandas import random import matplotlib import numpy import matplotlib.pyplot as plt datas = [0.3877, 0.3878, 0.3877, 0.3877, 0.3877,…
Dani K
  • 1
0
votes
1 answer

SciPy.Stats.Zscore appears to be calculating the z-score subtly incorrectly

I am trying to calculate z-scores for a dataset using scipy.stats, and am running into a very weird subtle error that I cannot figure out. The code is running, but appears to be producing data that is slightly off, which I am concerned is adversely…
rpe13002
  • 31
  • 2
0
votes
1 answer

SciPy Norm.cdf() in lambda function returns array instead of one observation

I inherited a VBA code that I want to convert to Python. Think of a suvrival matrix where : each row is a different product each column represent the age of the product I want to create a survival matrix of zeros, where I then apply the normal…
Phil P.
  • 7
  • 3
0
votes
0 answers

Decreasing Runtime of Scipy Statistical Computations

I have a 2-D Numpy array with a shape 2500, 200, where Scipy is to compute statistics (gamma CDF specifically) at each entry in the array. I've provided a random generation of floating point numbers for those aiming to run the code locally, note…
TornadoEric
  • 399
  • 3
  • 16
0
votes
1 answer

module 'scipy.stats' has no attribute 'cramervonmises_2samp'

I am trying to test whether two samples have the same distribution by using cramervonmises_2samp, in Juypter notebook, but I got this error "module 'scipy.stats' has no attribute 'cramervonmises_2samp'" when trying the example on page of…
Dora
  • 1
  • 1
0
votes
0 answers

How to convolve discrete distributions in scipy?

the goal is to have a function that takes as arguments two discrete distributions and outputs the distribution corresponding to the sum of an independent sample from each (so the pmf is the convolution of the individual ones). My current…
irh
  • 358
  • 2
  • 10
0
votes
0 answers

Kolmogorov-Smirnov test in Python with large dataset

I have a large dataset that looks something like this: genus R11P4_BS R13P1_BS R34P1_BS2 R34P3_BS2 R34P4_BS2 0 Abiotrophia 0.000000 3.214080 0.000000 0.002874 0.004310 1 Abyssicoccus …
0
votes
1 answer

Problems loading scipy.stats.tukey_hsd in Spyder

I have installed the package scipy.stats and now I want to use the tukey_hsd function in the package. I get this error message once I try to load it from scipy.stats import tukey_hsd ImportError: cannot import name 'tukey_hsd' from 'scipy.stats'…
Thomas
  • 441
  • 3
  • 16
0
votes
0 answers

Using curve_fit to fit a symbolic function defined out of the sum of functions from lists

I am very new to python and would like to try and fit a histogram to sums of an 'exponential like' and a 'normal like' distribution. In principle, I want to try this on known distributions, all built in with scipi.stats. The process is to be…
GaloisFan
  • 111
  • 5
0
votes
0 answers

Scipy Chi2 Probability Density Function Exploding

I am trying to plot a chi squared probability density function trained on some experimental data at different conditions in python. My code is shown below. import numpy as np import matplotlib.pyplot as plt import scipy.stats as ss …
iato
  • 356
  • 5
  • 16
0
votes
0 answers

Why are the rows in a table of random digits labelled?

We were looking at this in class and the - so far - unanswered question came up; why are the rows in this table labelled? We still have no idea why this is.
0
votes
1 answer

Plot gamma distribution scipy.stats python

I'm trying to plot a gamma distribution and I expect it to be normalized, but somehow, the values always diverge too much and I'm not getting the expected result. My code so far looks like this: from scipy.stats import gamma a,loc,scale =…
backer
  • 3
  • 2
0
votes
1 answer

python scipy.stats.binom error "Cannot cast scalar from dtype('int64') to dtype('int32') according to the rule 'safe'"

I'm trying to generate binomial distributions with large values of n, however if I input values larger than (2^32)/2-1 I get an error. E.g. if I run the following: from scipy.stats import binom binom.rvs(2147483648,0.5) I get this…
0
votes
1 answer

Spyder issues without anaconda distribution "distfit" package. Cannot change PATH

I am using python 3.11. I was setting up a remote development enviornment and the anaconda distribution was just messing everything up. In order to get it to work I had to uninstall the conda distribution. Now that I have gotten the remote…
d3hero23
  • 380
  • 1
  • 12