We’re rewarding the question askers & reputations are being recalculated! Read more.

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.

Filter by
Sorted by
Tagged with
3
votes
1answer
156 views

Program which accepts grades and prints grade distribution

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 ...
3
votes
1answer
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 <...
3
votes
3answers
2k views

Finding unique pairs in lottery tickets

I was trying to solve one of the hackerrank practice questions. Could anyone please let me know how can I make this code much effective, in terms of time and space complexity? The Super Bowl ...
3
votes
1answer
486 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 ...
3
votes
1answer
372 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. ...
3
votes
1answer
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 ...
3
votes
1answer
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. ...
3
votes
2answers
538 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 ...
3
votes
0answers
63 views

Estimate area of cropped circle with Monte Carlo

I looking around and not finding anything, I developed a simple function for estimating the area of a possibly cropped circle inside a frame. It uses a very basic MC implementation. It is pretty fast ...
3
votes
0answers
73 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 ...
3
votes
0answers
29 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. ...
3
votes
0answers
48 views

Download and analyze PDFs of Congressional records

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, ...
3
votes
0answers
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 ...
3
votes
0answers
344 views

PCA, LDA and Logistic Regression

Based on the great blog by Joel Grus, I implemented LogisticRegression, PCA, and LDA. I'd appreciate feedback as I'm not sure that the logistic classifier is good enough (as it supposed to achieve ...
3
votes
0answers
2k views

A Simple K-Means Cluster Analyzer v0.1

[NOTE] This question can be depreciated in favor of version 0.2. This code works well. This my first attempt at creating a robust, computationally lean K-Means Cluster analyzer. I first saw this ...
3
votes
0answers
1k views

KS-Statistic in C++

Consider the MCG with parameters: a = 23, M = 10^8 + 1, and let the seed be 47594118. (This is the original MCG proposed by Lehmer in 1948.) Apply the Kolmogorov-Smirnov test to the first 1000 random ...
3
votes
0answers
230 views

Naive implementation of Naive Bayes in Haskell

A simple implementation of Naive Bayes, as I'm a Haskell beginner I've tried to put an emphasis on clarity and documentation. I've tried to incorporate the feedback from a similar question. This is ...
3
votes
0answers
138 views

Read in file, Filter out records, output results

I have been working on a project for some time and have let one Python file grow into a huge file that tries to do everything. The structure is pretty flat and I don't like it. I've used other ...
3
votes
0answers
163 views

Nonlinear Nonparametric Regression

I explain the nonlinear correlation coefficients in this paper and provided the code in this post. The nonlinear nonparametric regression is an extension of this work and its description can be found ...
3
votes
0answers
126 views

Correlation and Dependence

It is well known that 0 dependence implies 0 correlation, while 0 correlation does not imply 0 dependence. I have a paper here illustrating nonlinear correlation coefficients from relationship subsets ...
3
votes
0answers
148 views

Computing pairwise distance covariances for a symmetric matrix

I wrote a non-vectorized, non-parallel wrapper function for computing the pairwise distance covariances (Wikipedia) (original paper) in a data frame: ...
2
votes
4answers
130 views

Calculate min, max, mean and median out of array Version 2

This question is a follow up of: Calculate min, max, mean and median out of array I took all the suggestions an reworked the code. Like the description of the excercise suggests i only use one ...
2
votes
3answers
125 views

Printing a table of letter frequencies using Python

What is the recommended (standard, cleaner, more elegant, etc.) method in Python to get a string with all the alphabet letters? Here's three versions of code to generate a dictionary with keys as ...
2
votes
3answers
143 views

Statistical methods using PHP (mean, co/variance, standard deviation, skew, correlation)

Functionality This class has a list of statistical functions such as mean, variance, standard deviation, skewness, and it works okay. These functions are applied to arrays of charts data. It is an ...
2
votes
2answers
210 views

Given a list of words, find the most common initial character and other statistics

20 different words are inputted using a string array. A C++ program to display the alphabet which has occurred the maximum number of times as starting letter of a word in the list,and how many times ...
2
votes
2answers
730 views

Extracting price statistics from a CSV file

I got the following task to solve: ...
2
votes
2answers
1k views

Normal distribution array function

I have a function that produce an array with values that are Gaussian (normal) distribution. If you plot the values on a graph, it would look something like this: Is there any way to improve on the ...
2
votes
2answers
717 views

Row-wise mean imputation in R

Someone on SO asked how to fill in the NA's with row means. His example code was: ...
2
votes
1answer
117 views

Rolling mean lag function

I'm working in base R here, but would like to convert these functions to something more efficient in R (e.g. speed up processing with dplyr). This takes a while ...
2
votes
1answer
69 views

Mean of integers, ignoring the largest and smallest values

The code returns the mean of a list of integers, except ignoring the largest and smallest values in the list. If there are multiple copies of the smallest value, ignore just one copy, and likewise for ...
2
votes
1answer
3k views

Finding the percentile corresponding to a threshold

I need to find which percentile of a group of numbers is over a threshold value. Is there a way that this can be speed up? My implementation is much too slow for the intended application. In case this ...
2
votes
2answers
539 views

Binning and calculating a huge range of data

I have a code that I'm fairly certain does what I want. Bear with me as I explain what I'm doing: Imagine that there is 10 houses, where there can be one to an infinite number of persons. Each of ...
2
votes
1answer
46 views

Basic Single Header statistics and ml libray for C++ - Scikit-Learn like implementation

I am developing scikit-learn like implementation for C++ it is in the initial stage while developing I've started doubt myself that is this the correct implementation, since here accuracy is more ...
2
votes
2answers
200 views

Estimating the total production count from a few random serial numbers

This is basically my attempt to the German Tank Problem in which we are given a few serial numbers and expected to return an estimation of the total production count. Such as, if 4 tanks are captured ...
2
votes
2answers
190 views

Top K frequent elements

I am working on an interview question where I need to return the k most frequent elements given a non-empty array of integers. Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Here is my code: <...
2
votes
2answers
51 views

The importance of consistency in percentage returns when investing

It is said that Being consistent in percentage annual returns leads to larger amount over time. That is for any given principal, getting 20% successively for 2 years is better than 30% for first ...
2
votes
3answers
91 views

Speed up weighted average for Leela Chess Zero

Problem: Given a vector of about 40 values m with normal error sd compute the weighted average of the values weighted by the ...
2
votes
2answers
107 views

A bag of numbers in C++ for constant time statistics queries

(See the next iteration.) I have this simple "data structure" for storing numbers and querying the statistics on them (average, variance and standard deviation): numberbag.hpp ...
2
votes
1answer
273 views

Multiple files data processing in Clojure

I have made a small script which grabs data into a map from 80 CSV files and calculates some statistics like average, standard deviation etc. It's also adding some additional data to map from filename....
2
votes
1answer
1k views

Calculating exponential moving averages with multiples threads

I calculate the moving averages of a specific measure. However, multiples threads can access this class in order to compute the average. ...
2
votes
2answers
450 views

Calculating the statistical Mode(s) of a (possibly multi-modal) set of elements

I am trying to come up with the most performant way of calculating the statistical Modes of a std::vector, obeying two conditions: 1) my function should not ...
2
votes
2answers
104 views

Random distribution in Ruby

Below is a Ruby implementation of a random statistical event, based on a hash with the actual observed counts of outcomes. I'd be interested in feedback in particular on what techniques I might use ...
2
votes
1answer
62 views

Compute histrogram bins for a large data.frame fast

I know about apply, but I'm not sure how to write it so that it works for embedded for loops with if statements and so forth. It ...
2
votes
2answers
3k views

War card game simulator

My teacher wants us to create a program that runs n games of war and calculates the average number of battles, wars and double wars that occurred. He has very specific rules (not necessarily the ...
2
votes
1answer
247 views

Check ordinary least squares calculation for correctness

I've written ordinary least squares fitting of market data for learning purposes, so performance is not an issue. I'd like a reviewer to look at correctness and programming flaws, if any, in the code:...
2
votes
2answers
204 views

Calculating the posterior distribution in multivariate Gaussian processes

Matlab profiler throws this horrible bottleneck which is called 700000 times: ...
2
votes
2answers
49 views

Calculating p-value for Welch's t-test

I am attempting to translate some of my Perl code to Ruby, from http://rosettacode.org/wiki/Welch%27s_t-test I am a very very beginner with Ruby, but I have verified that this is producing the ...
2
votes
2answers
86 views

Generate a large block diagonal covariance matrix with exponential decay

I am implementing Kalman filtering in R. Part of the problem involves generating a really huge error covariance block-diagonal matrix (dim: 18000 rows x 18000 columns = 324,000,000 entries). We denote ...
2
votes
1answer
198 views

Welford's online variance calculation algorithm for vectors

I'm developing a face recognizing application using the face_recognition Python library. The faces are encoded as 128-dimension floating-point vectors. In addition to this, each named known person ...
2
votes
2answers
78 views

Application to monitor device power levels for deviations

I have a high performance, computation intensive application that runs on a Centos 7 machine with Python 2.7.5. I'll try to explain what the application does: The application runs an infinite loop, ...