statistics

How to get the correct answers from a permutation / combination problem?

How to get the correct answers from a permutation / combination problem? Question: Given the following input, I would like to implement a function, that calculates the amount of possible correct answers, without calculating each answer for computational reasons. I hope the function to look something like this: from itertools import combinations_with_replacement from itertools import …

Total answers: 1

Python assign covariance row wise calculation

Python assign covariance row wise calculation Question: I am trying to assign the covariance value to a column based on the dataframe I have. The df is ~400k records x 30+ columns. The two data series that act as inputs for COV() are all aligned as a single record (with ~400k records). I would like …

Total answers: 1

How can I code Vuong's statistical test in Python?

How can I code Vuong's statistical test in Python? Question: I need to implement Vuong’s test for non-nested models. Specifically, I have logistic-regression models that I would like to compare. I have found implementations in R and STATA online, but unfortunately I work in Python and am not familiar with those frameworks/languages. Also unfortunate is …

Total answers: 1

Creating sub columns in Pandas Dataframes for Summary Statistics

Creating sub columns in Pandas Dataframes for Summary Statistics Question: I am working with water quality data for both surface water locations and groundwater well locations. I would like to create a summary statistics table for all three of my parameters (pH, Temp, salinity) grouped by the location the samples were taken from (surface water …

Total answers: 2

Extended Describe Pandas and beyond

Extended Describe Pandas and beyond Question: I am new to python and pandas. My question is related to that question: Advanced Describe Pandas Is it possible to add some functions to reply by noobie like: geometric mean, weighted mean, harmonic mean, geometric standard deviation, etc. import pandas as pd def describex(data): data = pd.DataFrame(data) stats …

Total answers: 1

Is there a way to generate a lognormal distribution from a pre-defined normal distribution?

Is there a way to generate a lognormal distribution from a pre-defined normal distribution? Question: I have the code which generates a normal distribution as a pdf, centered at the mean 400, with st import numpy as np import matplotlib.pyplot as plt import scipy.stats muPrev, sigmaPrev = 400, 40. a = np.random.normal(muPrev, sigmaPrev, 100000) count, …

Total answers: 3

How to maintain decimals when dividing with numpy arrays in Python

How to maintain decimals when dividing with numpy arrays in Python Question: So, I was working on implementing my own version of the Statsitical Test of Homogeneity in Python where the user would submit a list of lists and the fuction would compute the corresponding chi value. One issue I found was that my function …

Total answers: 1

Adding mean and std to maringal plots in seaborn

Adding mean and std to jointplot margins Question: I have a seaborn.jointplot very similar to the figure I’ve attached (from the seaborn gallery). However, I wonder if it is possible to add e.g. a colored line to each of the marginal plots to mark the mean and a range marking for the interval of one …

Total answers: 1

Drawing line of regression onto scatter graph in python

Drawing line of regression onto scatter graph in python Question: I am trying to draw the line of regression onto a scatter graph. I have two functions: def place_y(x, slope, intercept): return slope * x + intercept def draw_line_of_regression(): """The line of regression can be used to predict further values""" import matplotlib.pyplot as plt # …

Total answers: 1