Questions tagged [scipy.stats]
297 questions
8
votes
4 answers
How to speed up the agg of pandas groupby bins?
I have created different bins for each column and grouped the DataFrame based on these.
import pandas as pd
import numpy as np
np.random.seed(100)
df = pd.DataFrame(np.random.randn(100, 4), columns=['a', 'b', 'c', 'value'])
# for simplicity, I use…

zxdawn
- 825
- 1
- 9
- 19
8
votes
1 answer
norm.ppf vs norm.cdf in python's scipy.stats
so i have pasted my complete code for your reference, i want to know what's the use of ppf and cdf here? can you explain it? i did some research and found out that ppf(percent point function) is an inverse of CDF(comulative distribution function)
if…

Pushpak Ruhil
- 176
- 1
- 1
- 9
7
votes
3 answers
How to compute the percentiles from a normal distribution in python?
Problem Statement - A random variable X is N(25, 4). Find the indicated percentile for X:
a. The 10th percentile
b. The 90th percentile
c. The 80th percentile
d. The 50th percentile
Attempt 1
My code:
import numpy as np
import math
import…

MVKXXX
- 193
- 1
- 2
- 11
7
votes
1 answer
What is the point of norm.fit in scipy?
Im generating a random sample of data and plotting its pdf using scipy.stats.norm.fit to generate my loc and scale parameters.
I wanted to see how different my pdf would look like if I just calculated the mean and std using numpy without any actual…

José Manuel Valladares
- 73
- 1
- 1
- 4
4
votes
1 answer
does scipy.stats.permutation_test really exist?
scipy documentation describes a module [scipy.stats.permutation_test].1
when I try using this module in Jupyter Notebook, as shown below, I get:
"AttributeError: module 'scipy.stats' has no attribute 'permutation_test'".
Looking at all the…

PeterG
- 41
- 2
4
votes
1 answer
How to use scipy.stats.maxwell to find temperature?
I have speed data of many particles to which I want to fit the Maxwellian curve. I am trying to use the fit method from scipy.stats.maxwell to fit to my data and extract the temperature of the system from that.
From the documentation, I am unable to…

Babaji
- 398
- 1
- 4
- 18
4
votes
1 answer
scipy.stats.bootstrap not importing, python
I have tried pip install scipy and everything appears fine, going through the path I opened the files and couldn't find any mention of the bootstrap library despite it being on their website:…

kedoink
- 81
- 1
- 7
4
votes
1 answer
What is the parameter a in scipy.stats.gamma library
I am trying to fit Gamma CDF using scipy.stats.gamma but I do not know what exactly is the a parameter and how the location and scale parameters are calculated. Different literatures give different ways to calculate them and its very frustrating. I…

Vishal singh rajpoot
- 113
- 1
- 8
4
votes
3 answers
Csr matrix: How to replace missing value with np.nan instead of 0?
It seems that csr_matrix fill missing value with 0 in default. So how to fill the missing value with np.nan?
from scipy.sparse import csr_matrix
row = np.array([0, 0, 1, 2, 2, 2])
col = np.array([0, 2, 2, 0, 1, 2])
data = np.array([0, 2, 3, 4, 5,…

rosefun
- 1,797
- 1
- 21
- 33
3
votes
1 answer
Incompatible shape error when using tf.map_fn to apply a python function on tensors
While building some code to train a tensorflow deep model, I am using tensorflow tf.map_fn and tf.py_function as a wrapper to apply a scipy python function as a loss function mapping each 2 rows of a batch of 2 probability vectors p and q of shape…

Othmane
- 1,094
- 2
- 17
- 33
3
votes
1 answer
importing qmc as submodule in scipy
When I write from scipy.stats import qmc I face Import Error in Jupyter notebook:
ImportError: cannot import name 'qmc' from 'scipy.stats' (C:\winapps\Anaconda3\lib\site-packages\scipy\stats\__init__.py)
I want to do Halton sampling, how can I…

saeed
- 29
- 1
- 4
3
votes
1 answer
Adding dictionary values sequentially to scipy function
I want to calculate p-value for each key of a dictionary and create a table for the (keys | p-value).
Example dictionary:
mydict = {
'a': [100, 5, 4, 3],
'b': [66, 0, 75, 12],
'c': [56, 11, 80, 0]}
How can I insert the 4 value of each key in order…

Alakeedi
- 31
- 2
3
votes
1 answer
How to calculate 95% confidence level of Fourier transform in Python?
After calculating the Fast Fourier Transform (FFT) of a time series in Python/Scipy, I am trying to plot the 95% confidence level that for which the power spectrum is different from red or white noise, but haven't found a straightforward way to do…

paulo
- 43
- 4
3
votes
1 answer
Unexpected confidence interval using scipy
I calculated a 95% confidence interval using scipy and the result is different to what I was expecting.
I am solving a problem where someone rolled a die 20K times and observed 3,932 sixes. I am being asked to build a 95% confidence interval for the…

Arturo Sbr
- 5,567
- 4
- 38
- 76
3
votes
1 answer
How to find percentage of values above the second standard deviation in python?
Problem statement - Suppose a variable X has a bell-shaped distribution with a mean of 150 and a standard deviation of 20.
a. What percentage of X values lies above 190?
My code so far:
import numpy as np
import math
import…

MVKXXX
- 193
- 1
- 2
- 11