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

360 questions
Filter by
Sorted by
Tagged with
1answer
67 views

### Average calculator with filters

I am a beginner in Java and I have a hobby project to create a tool for statistical calculations. Users can upload csv with results of a survey. The responses stored in a ...
2answers
2k views

### Find median of two sorted arrays

Problem statement There are two sorted arrays nums1 and nums2 of size m and ...
1answer
379 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 ...
1answer
393 views

### Bernoulli trials using a condition in a vectorized operation

I was wondering how to vectorize the following code instead of using the for-loop and still be able to check for a condition. ...
1answer
50 views

### Kernel based conditional increments of many stochastic processes

I have written this function is part of a research project that involves analyzing time-series data from stochastic processes. We have a small number (from 1 to 3) of independent observations of a ...
1answer
168 views

### Evaluate joint probability density function of a Markov random field

The following code evaluates probability mass function for all possible states of a model. ...
1answer
77 views

### Entropy calculation function in Haskell

I've written a function in Haskell for calculating the entropy of a collection. I'd like feedback on how the function could be rewritten to be more flexible/reusable, and also how to profile the ...
1answer
63 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, ...
1answer
270 views

### Averaging accumulator template with overflow detection/prevention

This is a class/template I just wrote for my embedded project (IAR EW ARM - Cortex/ARM7TDMI - Atmel SAM7, SAM4, SAMG). I am gathering data from CAN BUS (FMS), e.g. Engine Revolutions (Per Minute), ...
1answer
125 views

### Calculating difference statistics over a moving window

I'd like to calculate some statistics of given data (frequencies of difference among elements on various distances in percent multiplied by 10) using moving window within that data. Is it possible to ...
1answer
83 views

### Find line of best fit

This is an update of Test thousands of combinations quickly. I have a physical robot which has a function, turn(degrees). For different robots, there will be small differences in the accuracy of the ...
1answer
6k views

### Calculate “average”, “median” and “percentile” from a long array

I have this method which calculates the average, median and percentile information given a long array of numbers. Is there any better and efficient way to do the same? ...
1answer
81 views

### Vectorizing Two Sample Kolmogorov-Smirnov test

I'm implementing the Two-sample Kolmogorov-Smirnov test in MATLAB. I must admit I know very little of formal statistics and was simply trying to implement the description in wikipedia's page. Right ...
1answer
54 views

### Generic Timing Class - Follow Up

I wrote a class which can time and compare functions. I already posted it here once before, and got great suggestions from @rolfl, which I have added to my code. my original question can be found ...
1answer
2k views

### Averages and standard deviations for a Knn application

I'm working on a small command line application in c# where data is read from a CSV file along with a query and KNN is calculated for the query based on the data. My problem isn't the algorithm at ...
1answer
855 views

### Code correctness and refinement for quantile normalization

The below code is still far from feature complete, but am looking to have some of the sections critiqued to learn better idioms or adjustments (e.g. - yet to be implemented: handling of csv files with ...
1answer
435 views

1answer
72 views

### Find median of two sorted arrays, with complexity of min(log(m),log(n))

I wrote a program which gets two sorted arrays a and b (with sizes m and ...
4answers
167 views

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

(See the 2nd/previous iteration.) I essentially removed all the type conversion trickery and have this: numberbag.hpp ...
2answers
821 views

### Real time graph simulation of dice tossing

When tossing a dice many many time all numbers tend to appear the same number of times, but if the number of throws is small then some numbers may appear more or less often than others, even ...
2answers
336 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 ...
3answers
383 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: ...
1answer
639 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 ...
3answers
94 views

### Linear Regression Class in Python

I have recently been brushing up on my statistics and calculus and wanted to implement Linear Regression, the code will be for a calculus/statistics library I am working on (I know there are libraries ...
2answers
104 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 ...
1answer
3k views

### Compute conditional median of PANDAS dataframe

I am new to Python/Pandas. Consider the following code: ...
1answer
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 <...
1answer
3k views

### Finding the 20th percentile pixel of an image using a histogram instead of std::sort

I have a 2-dimensional matrix (an image) in which I need to find the 20th percentile value. My first attempt was to sort the values and then index using ...
1answer
2k views

### HackerRank: Climbing the Leaderboard

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 ...
1answer
149 views

### Statistics Calculator for Listed and Grouped Data

I made a statistics calculator based on raw data for my Edexcel IAL Statistics 1 course which I'm going to use in my calculator's MicroPython. I would like some suggestions for ways to further improve ...
2answers
115 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 ...
1answer
131 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....