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
7
votes
3answers
3k views

Compute mean, variance and standard deviation of CSV number file

I've written my first C++ application this week and I wanted to see if there's anything that aren't up to standards or better ways to do what I'm currently doing. For the goal of the exercise, let's ...
10
votes
4answers
185 views

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

(See the previous iteration.) (See the next iteration.) I have a simple "data structure" for storing numbers and querying the statistics on them (average, variance and standard deviation). Now I ...
4
votes
2answers
815 views

Calculate Geometric and Arithmetic Mean

I am trying to make general class to calculate Geometric mean using exponential of the arithmetic mean of logarithms , and Arithmetic Mean. I am looking for some general feedback on how I can improve ...
44
votes
3answers
5k views

Benchmarking things in C#

I needed a better way to benchmark code, because, well, rewriting the same benchmarking code every time I need it is just...well...unpleasant. So, here's a class which does just that, it runs an <...
43
votes
8answers
6k views

Prettify math formula in code

I have a function to calculate the normal distribution in Python: ...
11
votes
3answers
2k views

Calculate min, max, mean and median out of array

Another C exercise: Write a function that takes an array of 'ints' as its input and finds the smallest and largest elements. It should also compute the median and mean. Use a ...
4
votes
2answers
2k views

Find median of two sorted arrays

Problem statement There are two sorted arrays nums1 and nums2 of size m and ...
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 ...
2
votes
0answers
381 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 ...
5
votes
2answers
115 views

Estimating the number of tanks based on a sample of serial numbers

I created code that was supposed to determine how well my system of guessing is. The scenario is that there are n amount of tanks. Each tank is uniquely numbered 1 to n. Seven of these tanks are ...
4
votes
3answers
304 views

Estimating the number of tanks based on a sample of serial numbers 2.0

There was some confusion with the code I had posted in my previous version of this question and there was some good advice from @Oscar Smith. The explanation is the same; please give improvements for ...
3
votes
2answers
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 ...
2
votes
4answers
116 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 ...
4
votes
2answers
264 views

Simple and efficient data structure for standard deviation queries in Java

I have this data structure to which the user can add number or remove them, both in constant time. Also, there is a \$O(1)\$ operation for querying the standard deviation of the current contents of ...
3
votes
3answers
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, ...
3
votes
1answer
178 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 ...
3
votes
2answers
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....
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
2answers
247 views

Generic sliding average in C++

I tried hard to come up with a function template computing a sliding average. A sliding average over data \$x_1, x_2, \dots, x_n\$ with window length \$k \leq n\$ is a sequence \$y_1, y_2, \dots, y_{n ...
3
votes
1answer
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: \...
2
votes
1answer
115 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
368 views

Parzen Window Density Estimation in C#

Is my implementation correct (it is matching this result)? How can I improve this code? ...
2
votes
1answer
39 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 ...
2
votes
2answers
68 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 ...
1
vote
1answer
48 views

Statistical Sample with Analysis Java (Round 2)

Looking for any feedback on improvements that could be made to this class. I am attempting to represent a 2-dimensional data set(one variable input, one variable output). I have included all ...
1
vote
2answers
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? ...
1
vote
0answers
704 views

PHP rating function for getting the average value of column

I created a function to add and return the average rating. Rating Function ...
1
vote
2answers
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: ...
1
vote
3answers
398 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. ...
0
votes
1answer
96 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 ...