# Questions tagged [statistics]

Consider whether your question would be better asked at CrossValidated, a Stack Exchange site for probability, statistics, data analysis, data mining, and machine learning. Code Review questions on statistics should be about implementation and working program review, not about theoretical discussions of statistics or research design.

326 questions
Filter by
Sorted by
Tagged with
937 views

### Pandas/Numpy statistical odds ratio test

I'm looking for a faster way to do odds ratio tests on a large dataset. I have about 1200 variables (see var_col) I want to test against each other for mutual exclusion/ co-occurrence. An odds ratio ...
234 views

### Skew logistic distribution

I am trying to program a skew logistic distribution function to return the PDF, the CDF, and (later) the inverse CDF. Although there are several forms of skew logistic, this is for perhaps the most ...
148 views

### Vectorize Fisher's Exact Test

I have two data frames/ lists of data, humanSplit and ratSplit, and they are of the form ...
434 views

### My (early stage) statistics homework assistant

I wanted to share my code for others to critique. This program is something I started while struggling with homework problems in my Statistics course, and after getting the ball rolling, I decided to ...
121 views

### Computing average duration per user from a large CSV file that doesn't fit in memory

We have a large log file which stores user interactions with an application. The entries in the log file follow the following schema: {userId, timestamp, actionType} where actionType is one of two ...
1k views

### Deviation and Variance

This assignment requires obtaining the deviation and variance of $n$ numbers stored in one single array. Is there any way to make this code more efficient? ...
5k views

### Computing the standard deviation of a Number array in Java

(See the next iteration.) I have this funky class method for computing standard deviation from an array of Number objects using the Stream API: StandardDeviation....
540 views

### Standard deviation in one pass in C++ - follow-up

(See the previous and initial iteration.) This time, I use tag dispatching in order to make sure that non-random access iterators are not put into a std::distance, ...
107 views

335 views

### In a list of pairs, replace snds with median of all snds with the same fst

Given is a list of pairs. I want to replace the second element of all pairs with the median of the second elements of all pairs with the same first element. For example: ...
362 views

### Input data from file, calculating average by a function

I want to thank you guys firstly for your previous comments and feedback. Really appreciate it. I am learning C with school at the moment, but I plan to be "fluent" in C at the end of august of this ...
1k views

### Compute conditional median of PANDAS dataframe

I am new to Python/Pandas. Consider the following code: ...
2k views

### Median of numbers stored in array

Problem is to calculate median of numbers. My idea is : Fill array of integer with numbers using Arraymake() function copy the address into a pointer created in <...
1k views

Below is my solution to Climbing the Leaderboard on HackerRank: Alice is playing an arcade game and wants to climb to the top of the leaderboard. Can you help her track her ranking as she beats ...
8k views

### Building a histogram array in PHP

I'm visualizing my stored data in an histogram similar to this one: However, I'm sure that my code smells a lot! So I'd like to have your opinion on how to make it better. ...
77 views

### Constructing a cumulative distribution function from a histogram

During some running process, a histogram of values shall be build up. When done, the CDF shall be derived from it and used to get the quantiles for some values. My current implementation looks as ...
81 views

### Plots of prior and posterior distributions for a model

I have an exercise that ask to plot the prior and posterior distribution in the Poisson-Gamma model. I did it (I think it's correct) inspired in the answer of this question https://stats.stackexchange....
114 views

### Computing the standard deviation of a Number array in Java - follow-up

(See the first and initial iteration.) Now I make only one pass over the data in order to compute the standard deviation of the input Numbers, and that's how: \...
179 views

### Nonlinear Scaling Normalization

I have a procedure for normalizing variables, the details of which can be viewed in this white paper. I would like to be able to make the routine scalable to handle any number of variables. Below is ...
284 views

### Confidence score calculation

I was looking for a way to calculate a score 'x' for each pair of elements in two separate arrays. The goal of the code is to return an output array containing the score for each entry in the input ...
418 views

### Hamiltonian Monte Carlo in Scala

I'm writing a program in Scala to perform Hamiltonian Monte Carlo (HMC), coupled with Gibbs sampling of some variables. The algorithm, with the modifications such as perturbing epsilon and l and ...
86 views

### Calculate mean and standard error of a generator in Python

The goal of the following code is to calculate the mean and the standard error of vectors of randomly-generated numbers. I am looking for feedback both on the correctness of the calculation, and on ...
62 views

### Generating random number from a binomial distribution

In my application of Monte Carlo simulation, the crucial part is to generate a random number from a binomial distribution with parameters n = size and p = 0.5. Here is my current implementation ...
69 views

### Evaluating association strengths of items

I have a list of animals with their counts: ...
267 views

### Eloquent Javascript exercise: find average age from ancestors array per century

I solved an exercise from the book "Eloquent Javascript". I want to share with you guys the solution. The exercise is from chapter 5. Summing up, I have to find the average age from the ancestors ...
386 views

### IMAP Mailbox Daily Average Volume Statistics Generator

Because my job needed something like this, I created a Python script that'll connect to an IMAP server, get all the emails, and then calculate the very rough daily average of emails received to the ...
719 views

### Checking literary works for Zipf's Law

I wrote a Python script that, given a literary work in text file format, takes it apart, makes a word list, counts how many times each words appears in the literary work, and then checks if it follows ...
720 views

### Arithmetic quiz with class database and score analysis

I have done this quiz project and I have tried as hard as I could when I was writing to make it user friendly to read. Could you help me on improving and making it more user friendly please. ...
2k views

### Basic Java statistics class

I noticed there's some code on StackOverflow that is, to put it mildly, suboptimal. I'm posting here to see if we can provide a better solution. Here's a proposal for fixing it. The approach is to ...
75 views

### Optimization for calculating statistics

I have collected a large amount of data about the train network in my country. Now, I am writing some code that calculates the average amount of delay on the entire train network, for each day, in a ...
4k views

### Help improve my my python code for Exponential Smoothing Sumitted to Statsmodel

I just submitted this pull request to statsmodels (a Python toolkit for statistical and econometric modeling). It adds support for exponential smoothing of time ...
91 views

### Groovy script to get average price per group from different data arrays

I've been trying to learn Groovy lately and I tried to solve a problem which involves designing a routine that will calculate the average Product price per Group. I have the following data: ...
37 views

### Sample size, P-values (its relationship), and data visualization with plots. ggplot and T test

We know that P-values (within t-test context as an example..) is highly sensitive to sample size. A larger sample will yield a smaller p-value remaining everything else constant. On the other hand, ...
90 views

I'm doing the MOOC Java course (CTRL+F "distribution"): The input of the program is a set of exam scores of a course. Each score is an integer. When -1 is entered, the program stops asking for ...
68 views

### Statistics and calculations

I went through a series of lessons in data science using pandas and numpy. I have attempted to replicate some of the more common algorithms based on maths forumlas and psuedocode, except for the <...
449 views

### R - Outlier Detection Algorithm

I am trying to implement an algorithm for detecting outliers in R and I am pretty new to the language. The outlier algorithm is described in this paper in detail on page 10-11, but to summarize it ...
321 views

### Monte Carlo Simulation of P-Value

I'm testing Python 3 code to perform a Monte Carlo simulation based on the result of an statistical test. I currently have the result of the statistical test in a pandas dataframe, like this. ...
1k views

### Normalizing data over a distribution

I have a list X containg the data performed by different users N so the the number of the ...
51 views

### Determine column averages

I'm trying to write terse Perl code to calculate the average of each column in a file. The file can have >= 1 columns. ...
525 views

### Specialized version of the cross correlation function

I am writing a specialized version of the cross correlation function as used in neuroscience. The function below is supposed to take a time series data and ask how ...
26 views

### Simple Kivy App for Bootstrap Algorithm

I have a very simlpe app built using Kivy, for performing bootstrap algorithm (statistics). We must input some samples in the form x1,x2,...,xn (these will be ...
19 views

### TensorFlow regressor to predict probability of winning, given a current score

This is a TensorFlow regressor that tells me that if you get x score, you will have x% to win a game in x game(game is not important). Doing this as a project to learn tensorflow. ...
46 views

This is built with Python 2.7.15. The goal of this script is to count the number of words spoken by each Senator on the floor of Congress between given dates. It pulls from the Congressional Record, ...
50 views

### 'Weighted sample' from overlapping categories

I wish to write a function, that will sample from various (potentially overlapping) categories $C_1, C_2, \ldots C_k$, such that the sampled values are in the ratio $r_1:r_2:\ldots: r_k$ or as ...