Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
2 votes
2 answers
63 views

Can I make my percolation in python function more efficient?

We've been tasked with finding out how many randomly distributed discs with radius = 1 it takes to form a chain of discs from the left side to the other of a square with side length = sqrt(n), and ...
2 votes
1 answer
45 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 ...
4 votes
2 answers
391 views

Plot number of concurrent jobs on time axel

Description: Calculate the number of concurrently running jobs for any given minute during a day. Each Job is scheduled to run X ...
4 votes
2 answers
78 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
2 answers
182 views

Finding crude death rate and age-standardized death rates from data

How can I improve this code's readability and function, for finding crude death rate and age specific death rate? Given are the death rates from chronic pulmonary obstructive disease in 2019, the ...
3 votes
1 answer
80 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 ...
2 votes
1 answer
145 views

First order hidden Markov model with Viterbi algorithm in Java

Introduction A first order HMM (hidden Markov model) is a tuple \$(H, \Sigma, T, E, \mathbb{P})\$, where \$H = \{1, \ldots, \vert H \vert\}\$ is the set of hidden states, \$\Sigma\$ is the set of ...
5 votes
4 answers
2k views

Calculate odds of winning (UK) Lottery jackpot

I am interested in calculating odds of winning UK Lottery. The format is that 6 numbers from 1-59 are drawn. I am interested only (at this stage) in the odds of winning the jackpot (matching six balls)...
13 votes
3 answers
463 views

Compute mean and variance, incrementally

I have previously reviewed code that computes standard deviation using the mathematical formula E(x²) - E(x)², and warned against the use of this formula because floating-point precision is severely ...
5 votes
1 answer
210 views

A simple probabilistic AI for generating random sentences in Java

Motivation I have this repository. It contains a program that analyzes an input text file and builds a word graph: in the graph, each node represents a word in the analyzed text. Now, if there are two ...
1 vote
0 answers
43 views

A JavaFX program to find out the mouse refresh rate v3

(This post is the continuation of A JavaFX program to find out the mouse refresh rate v2.) After taking @J_H's suggestions into account, I ended up here: ...
3 votes
1 answer
60 views

A JavaFX program to find out the mouse refresh rate v2

(See the continuation of this post in A JavaFX program to find out the mouse refresh rate v3.) (This post is a continuation of A JavaFX program to find out the mouse refresh rate.) After adopting the ...
2 votes
1 answer
82 views

A JavaFX program to find out the mouse refresh rate

(See the next version here.) Intro I have this tiny JavaFX program that shows a 800x600 pixel canvas. You are supposed to drag the mouse within the canvas. When you are done dragging, the program will ...
3 votes
2 answers
3k views

Kotlin function which counts standard deviation

Here is the code. The code should counts the standard deviation for double array, but also for Int arrays. ...
5 votes
2 answers
1k 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: ...
2 votes
0 answers
50 views

Plot ellipse hypothesis plots with confidence intervals for multiple models

I have developed a function to graphically plot between two predictors of interest their confidence interval regions on an ellipse. It states whether the null hypotheses have been accepted for the one-...
1 vote
0 answers
28 views

ADO wiki stats generator charting

I'm planning on adding an automated process to generate some stats once a week from a git repository, generates a markdown file with some stats, but looking for some suggestions for generating some ...
3 votes
1 answer
235 views

Calculate median and mode in Rust

I am reading the Rust book. I am on chapter 8; this is the assignment: Given a list of integers, use a vector and return the median (when sorted, the value in the middle position) and mode (the value ...
34 votes
2 answers
36k views

Calculate mean, median, and mode in Rust

I'm learning Rust using The Rust Programming Language. I'm trying the assignment at the end of chapter 8 — Hash Maps. The task is: Given a list of integers, use a vector and return the mean (...
1 vote
1 answer
72 views

Container that orders its elements based on their frequency

I was inspired by Find the K most-frequent values in a vector, and originally posted an early version of this in an answer. The aim is to have a container that maintains values ordered by their ...
2 votes
1 answer
77 views

Calculating median value from a list of numbers

I am learning Rust and I would like to get some feedback around my solution to calculate the median value from a list of integers. I believe the logic is correct as my tests pass, but I'm concerned ...
2 votes
4 answers
1k views

Calculate the median value of combining two sorted lists

I have solved a leetcode problem (Median of Two Sorted Arrays), and I came up with two solutions. Solution 1 ...
2 votes
1 answer
77 views

Estimate an average duration of every game state in a football match given implied goals for home and away teams

What my program does I'm trying to estimate for how many minutes in average a football(soccer) match will be in different game states depending on implied goals of both teams. Problem domain For our ...
7 votes
1 answer
206 views

Command-line correlation calculator in Java

I have this Java program that asks for a name of the file containing data rows in the format $$ x_1\ y_1 \\ x_2\ y_2 \\ \vdots \\ x_n\ y_n $$, and outputs on the command line the Pearson correlation ...
5 votes
1 answer
339 views

Calculate mode in Rust

I'm new to Rust and still getting used to the ownership model. I'm done with chapter 8 of the book and was trying to solve this exercise: Given a list of integers, use a vector and return the [...] ...
2 votes
1 answer
790 views

Calculating Spearman Correlation from scratch

Over the week, I was assigned to create a function in a Jupyter notebook that satisfies the Spearman Correlation formula without the use of any packages e.g. Numpy, Pandas. Below are the rules of the ...
1 vote
1 answer
83 views

Java - Select the maximum integers from sliding windows over an array

So I have the following algorithm. Given an array A[0 ... n - 1] and the window length w, compute all the windows ...
0 votes
1 answer
47 views

Identify IRC users with largest vocabulary ignoring links and short words

I wrote this script to figure out which users have the largest vocabulary on my irc server. I would like to see if there's any way to clarify what I consider a very quick script. It outputs a CSV ...
9 votes
3 answers
5k views

Computing a simple moving average on an array in C++

I have just started to learn C++ and wanted to improve my function. I am making a basic statistical API and am calculating an SMA (simple moving average) for some data. This function provides the ...
7 votes
7 answers
1k views

A probability distribution function, to be called repeatedly during numerical integration

I am trying to speed up as much a possible this function in C++. As I explained in another post, Implementing multidimensional integral for a custom function in C++, this function will be used inside ...
2 votes
3 answers
518 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 ...
14 votes
5 answers
49k views

Chi Square Independence Test for Two Pandas DF columns

I want to calculate the scipy.stats.chi2_contingency() for two columns of a pandas DataFrame. The data is categorical, like this: ...
2 votes
1 answer
968 views

Most frequent element in an array, return lowest if multiple

I have been learning C++ for the past 2 weeks. Following is a problem I solved from Hackerrank. I am somewhat unsure if it's the correct way to solve this, even though I got the desired output. How ...
5 votes
1 answer
900 views

Find the running median with 2 heaps

I wrote code to solve the running median challenge using 2 heaps, and I'd appreciate any and all feedback. Here is the problem: You have a list of numbers and are scanning them one by one. ...
10 votes
6 answers
2k views

Median Calculator

This is just a simple median calculator that calculates the median for a given array/list. ...
1 vote
1 answer
694 views

Exponentially-weighted moving mean and standard deviation of an irregularly-spaced weighted time series

The following numpy/python function computes exponentially-weighted moving mean and standard deviation of an irregularly-spaced weighted time series. I want to make it faster by getting rid of the ...
1 vote
1 answer
289 views

Implementation of a beta-binomial test in Python

I have been unable to find a Python function for performing beta-binomial test. There is, however, a binomial test function in the scipy.stats.binomtest and I have ...
5 votes
1 answer
771 views

Monte-carlo simulation code - simple exercise

I created a quick monte-carlo simulation which seems to do what I want (simple version below). The code basically simulates a Poisson distribution, say this results in a simulation of ...
1 vote
0 answers
29 views

Statistical bootstrapping in Python - is my code correct?

I wonder if my code for bootstrapping in Python is correctly coded or if there are logical flaws in it. It uses a 95% confidence interval. The code basically does the following for two datasets that ...
0 votes
1 answer
37 views

Obtaining statistics from each batch

I fully admit that the code below is long and ugly. What's happening is that in the validation section of this machine learning model (used for text recognition), I would like to obtain the character ...
2 votes
0 answers
244 views

Mean, median and mode GUI

This program takes x numbers and displays the mean, median and mode. My goal here was to use classes and class properties the best i could to make the code shorter (honestly i may have just made it ...
4 votes
1 answer
676 views

Function to calculate the GC content variation in a sequence

I came across this BMC Genomics paper: Analysis of intra-genomic GC content homogeneity within prokaryotes And I implemented some Python functions to make this available as part of a personal project. ...
3 votes
0 answers
78 views

Python program that analyzes a corpus for randomword generation

I play a lot of old-school western CRPGs, and most of them (if not all) require the player to generate an avatar at the start of a new game, including naming the character (with names that will never ...
6 votes
5 answers
2k views

Mean and Variance for Math Library

Taking forward the code written for the math library I'm developing. I wrote templatized functions for mean and variance. std::accumulate() (or summation in ...
8 votes
2 answers
5k views

Generating Latin hypercube samples with numpy

I wrote some code to generate Latin hypercube samples for interpolation over high-dimensional parameter spaces. Latin hypercubes are essentially collections of points on a hypercube that are placed on ...
1 vote
2 answers
1k views

Java simple stats program

This is a simple Java program I made that takes in any number, and when it gets to 0, it returns the quantity of the numbers, the min, max, sum, and average of the numbers. Are there any ways how I ...
1 vote
0 answers
40 views

Python 3 script for statistiscal analysis of English vocabulary

This is a Python 3 script that statistically analyzes 105,230 words with a total of 913,935 characters, its results will be used for pseudoword generation purposes. You will need this file for it to ...
5 votes
1 answer
298 views

Linear Regression in Haskell

After quite some time away from Haskell I am trying to brush up. To do so I am writing some basic linear regression functionality. The code produces the output expected. In essence I am trying to ...
5 votes
1 answer
2k views

Rolling z-score function in R

I have written a rolling z-score function myself. Is my implementation of rolling z-score function correct? ...
1 vote
1 answer
1k views

T-test Independence for a Pandas DataFrame

I want to calculate the scipy.stats.ttest_ind() for numeric columns in a pandas DataFrame with the binary target variable. ...

1
2 3 4 5
8