# 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.

353 questions
Filter by
Sorted by
Tagged with
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 ...
253 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:...
204 views

### Calculating the posterior distribution in multivariate Gaussian processes

Matlab profiler throws this horrible bottleneck which is called 700000 times: ...
59 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 ...
90 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 ...
304 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 ...
55 views

### Regularised regression code

I wrote some code to do regularised linear regression and it works, but I don't like the fact that I've had to double call the functions when plotting, nor the fact that I've sliced those calls to get ...
49 views

### Counts and average code

Using the columns 4 and 2 will create a report like the output file showed below. My code works fine but I believe it can be done shorter. I have a doubt in the part of the split: ...
46 views

### Query for stddev of number of stars per chatroom message

I am learning SQL today, so I decided to practice by writing some queries for The Nineteenth Byte Data Explorer. This is a PostgreSQL database about messages from The Nineteenth Byte chatroom, created ...
69 views

### A value set data structure for rapid statistics queries in Java

(See the next iteration.) This question is an elaboration of my question. Just like the previous implementation, all operations (except clear) run in exact or ...
212 views

### Calculating average stock prices using producer/consumer with async

Task: calculate average price for each stock, using input data, which consists of stock id (int) and its price (float). It's important to detect jumps in prices, therefore need to keep correct ...
711 views

### Order statistics without sorting in expected linear time in Java

Given an unsorted array of integers $A$, the $i$th order statistic of $A$ is the $i$th smallest element of $A$. For example, $0$th order statistics of $A$ is the minimum of $A$; \\$(|A| ...
2k views

### Read in file, and then compute class mean, median, max, min, class averages & update file

The application is designed to read in class results of individual students from a single text file, and then manipulate the data to give information such as class mean, median, max, min, individual ...
3k views

### Compute the mean, variance and standard deviation of all pairs, triplets and sets of four

My code sample for finding the mean for the case of pairs is: ...
46 views

### Matrix to calculate effects using delta method

I have written some code to calculate effects using the Delta method. I have a dataframe dpcp with variables x1, ...
414 views

### Optimize matlab triple for loop

I have a large matrix samples, I want to make another matrix sampleProb which is the same size, but modified as below: ...
5k views

### Computing average grades for students in a class

I wrote up a simple averages calculator for student grades, based on this daily programming challenge. First, the script asks for the file name for the text file containing the student names and ...
31 views

### Statistical function which computes the average work time in different months

It's a task from a Ruby-course, in which I'm currently enrolled: Ruby Course - Page Precisely it's one of the assignments for the first week. Following idea: Your are given a list in which finished ...
62 views

### Manual Regression Tree using Python

I wrote a code to create a regression tree for a synthetic train data of size Np. The idea is, first I have the source node (which consists of all set of points) ...
91 views

### Incrementing time in a discrete-event simulation of a supermarket queue

A method has been written that increments time in minutes that simulates how much time it takes to process item in a supermarket queue and if there is an empty queue, skip it and loops around to find ...
79 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, ...
76 views

### dplyr — tidyverse, pipes, correlation, same variable across time “a” “b”

Have a look at this dataset. The"a" and "b" are used to make possible differentiate when the same variable was measured. In this case X1a and X1b access the same variable, but "a" was (suppose..) in ...
48 views

### Grade of Service Probability Function Python

Consider the following typical probability scenario: I defined this function to handle that scenario, I'm curious if Python has a more efficient method to handle this, or if this is the best way: <...
609 views

### Simulation study in R with two variables and 10000 iterations

The generic version of what I am trying to do is to conduct a simulation study where I manipulate a few variables to see how that impacts a result. I'm having some speed issues with R. The latest ...
8k views

### Create quantile slices from dataframe columns

I have the following, working code: ...
60 views

### A C stack with minimum and maximum values

I have this C stack implementation that knows its minimum and maximum values: minmax_stack.h ...
1k views

### Method to return statistics from a collection with O(1) time and space

I have a DelayQueue, and the goal is to collect statistical information from the collection in O(1) time and space from ...
40 views

### A value set data structure for rapid statistics queries in Java - follow-up

(See the previous iteration.) Now all operations of the data structure work in exact constant time, yet it came with the price: the state of this set maybe non-sensical. A user may end up with the ...
403 views

### Parzen Window Density Estimation in C#

Is my implementation correct (it is matching this result)? How can I improve this code? ...
49 views

### Distributed (asynchronous) averaging

This code simulates a distributed averaging protocol. There is a network of nodes, and at the clicks of a Poisson process: A random node wakes up Transmits it's current average to all the nodes it is ...
275 views

### Standard deviation of hourly temperatures of 2 days

It seems that when I program in Lisp my brain goes on auto pilot and I end up solving the problem somehow. I don't even think I just do and it works out. That said, this is some horrible Lisp code ...
639 views

### Calculate AB significance with Control and Treatment Objects

I am working on an AB tool in JavaScript using the following: Calculate the Conversion rate based on the conversions divided by the hits. Calculate the Z Score by passing in the control and treatment ...
127 views

### Compute logistic regression on tweet objects

Is my approach good to naming variables and exception handling? I would like to make this code more robust and maintainable. I need advice on exception handling, var naming and comments. ...
161 views

### How to reduce runtime of gene data processing program?

This program takes a huge data set as input, processes it, calculates and then writes the output to an array. Most calculations may be quite simple, such as summation. In the input file, there are ...
38 views

### Using python to estimate the range of unstructured data

I have unstructured input-output data, f=f(x). I want to estimate the range of f as a function of x, given limited sampled. So, I tried to discretize the data use small bins in x to estimate the ...
71 views

### Bias-corrected percentile Bootstrapping Optimization

I have never posted to this forum, but was referred here. I need some help printing key iterations as well as optimizing my code for run time. If someone had some time to help/explain how to correct ...
24 views

### Simple data analysis for forecasting

This Python script extracts data from txt files containing raw numerical data, notably the increase average, the relative evolution and the standard deviation of ...
60 views

### Simple linear regression of two variables

This is the code I built to implement a simple linear regression to check the impact of variable A on B. I am not interested in predicting that's why the statistical approach is important for me to ...
77 views

### Regression on Pandas DataFrame

I am working on the following assignment and I am a bit lost: Build a regression model that will predict the rating score of each product based on attributes which correspond to some very common ...
103 views

### Rolling mean lag function for multiple variables

Thanks to @josliber's help (Rolling mean lag function), I was able to speed up a rolling mean function for different groups and rollmean lengths. Now I'd like to add to this function the ability to ...
440 views

### A Simple K-Means Cluster Analyzer v0.2

This code is a revision of a previous post and works well. This my first attempt at creating a robust, computationally lean K-Means Cluster analyzer. I first saw this algorithm in an intermediate ...
103 views

### Module for statistics [closed]

Here is my module for statistics: ...
96 views

### Getting the math right for a Hidden Markov Model in Java

In an effort to learn and use hidden markov models, I am writing my own code to implement them. I am using this wiki article to help with my work. I do not wish to resort to pre-written libraries, ...
132 views

### Average of multiple vectors with different length

I have several profiles that are in form of mappings (id,value) and I need to find average between that profiles (values). The issue is that not all profile consist ...
46 views

### MCMC Metropolis Hastings for German Tank Puzzle

I have implemented the following MCMC algorithm for the german tank puzzle found here I just want to make sure everything is legit and that I am not getting the right answer by chance. ...
89 views

### Survey adjusted contingency table with Taylor Series linearization

I am an R programmer who is learning C++/Rcpp. I wrote some code to recreate survey adjusted contingency tables a la SAS's surveyfreq procedure using Taylor Series linearization to generate standard ...
2k views

### Standard deviation in one pass in C++

(See the next iteration.) I have this template function for computing standard deviation in one pass over the data. The underlying math is here. coderodde_sd.h: ...
517 views

### General Java class to find mode

I am trying to make general class to find mode. I am looking for some general feedback on how I can improve the structure and efficiency of my code. ...
1k views

### Play With Numbers Programming Challenge (mean value of subarrays)

I'm trying to solve this Play With Numbers. I have passed the test cases but, I kept getting time limit exceeded. Can someone help me improve its performance in order to pass the time limit, please? ...