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
4
votes
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 ...
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 ...
4
votes
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 ...
4
votes
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. ...
4
votes
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 ...
4
votes
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. ...
4
votes
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 ...
4
votes
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, ...
4
votes
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), ...
4
votes
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 ...
4
votes
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 ...
4
votes
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? ...
4
votes
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 ...
4
votes
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 ...
4
votes
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 ...
4
votes
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 ...
4
votes
1answer
435 views

Pick the best combination of n choose k models

Algorithm Let \$M_0\$ denote the null model which contains no predictors. This model simply predicts the sample mean of each observation. For \$k=1,2,\ldots,n\$: Fit all \$n \choose k\...
4
votes
1answer
508 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: ...
4
votes
1answer
76 views

Python program computing some statistics on Scottish geographic areas

This simple script computes some basic descriptive statistics, like mean, standard deviation, kurtosis, etc. on data column imported from a CSV file with use of ...
4
votes
1answer
193 views

General class for basic Statistical Measures mode, arithmetic mean,geometric mean, median , variance ,and stander division functions

I am trying to do general class for basic Statistical Measures mode, arithmetic mean,geometric mean, median , variance ,and stander division functions. I am looking for some general feedback on how I ...
4
votes
1answer
763 views

Analysis of call center employee performance

This code basically calculates a few metrics based on numerators and denominators and then it bins the data into quintiles. This is a common operation that I perform for various data sets. My issue is ...
4
votes
0answers
75 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 ...
4
votes
0answers
51 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, ...
4
votes
0answers
1k views

Pandas/Numpy statistical odds ratio test

I'm looking for a faster way to do odds ratio tests on a large dataset. I have about 1200 variables (see var_col) I want to test against each other for mutual exclusion/ co-occurrence. An odds ratio ...
4
votes
0answers
4k views

Calculate relationship between 2 categorical variables in a pandas Dataset with chi square test

I'm working on a Machine Learning project and I'm in Data Exploration step, and my dataset has both categorical and continuous attributes. I decided to compute a chi square test between 2 categorical ...
4
votes
1answer
253 views

Skew logistic distribution

I am trying to program a skew logistic distribution function to return the PDF, the CDF, and (later) the inverse CDF. Although there are several forms of skew logistic, this is for perhaps the most ...
4
votes
0answers
157 views

Vectorize Fisher's Exact Test

I have two data frames/ lists of data, humanSplit and ratSplit, and they are of the form ...
3
votes
2answers
435 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 ...
3
votes
3answers
166 views

Computing average duration per user from a large CSV file that doesn't fit in memory

We have a large log file which stores user interactions with an application. The entries in the log file follow the following schema: {userId, timestamp, actionType} where actionType is one of two ...
3
votes
3answers
1k views

Deviation and Variance

This assignment requires obtaining the deviation and variance of \$n\$ numbers stored in one single array. Is there any way to make this code more efficient? ...
3
votes
2answers
6k 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
3answers
754 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
2answers
2k 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 ...
3
votes
2answers
131 views

BiasedOptionChooser<T>: a class to do “weighted random choices”

I need to select "random" elements from a collection. Random is quoted because I must assign a weight to each element; elements with higher weights have a greater chance of being selected. To achieve ...
3
votes
3answers
111 views

A collection of vector functionals

I would like some feedback for a collection of what I call "vector functionals", by which I mean maps \$\ell\colon \mathbb{K}^{n} \to \mathbb{K}\$, where the field \$\mathbb{K} = \mathbb{R}\$ or \$\...
3
votes
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 ...
3
votes
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 ...
3
votes
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 ...
3
votes
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 ...
3
votes
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: ...
3
votes
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 ...
3
votes
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 ...
3
votes
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 ...
3
votes
1answer
3k views

Compute conditional median of PANDAS dataframe

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

1 2 3
4
5
8