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
1answer
4k 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 ...
2
votes
1answer
26 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 ...
2
votes
1answer
74 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 ...
2
votes
1answer
68 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 ...
2
votes
1answer
44 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: <...
2
votes
1answer
528 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 ...
2
votes
1answer
6k views

Create quantile slices from dataframe columns

I have the following, working code: ...
2
votes
1answer
54 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 ...
2
votes
1answer
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 ...
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
1answer
374 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
46 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 ...
2
votes
2answers
273 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 ...
2
votes
1answer
124 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. ...
2
votes
1answer
159 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 ...
2
votes
0answers
20 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 ...
2
votes
1answer
50 views

Select optimal piecewise regression fit

I'm making a program which fits a piecewise linear regression with up to 4-5 breakpoints in the data, and then deciding how many breakpoints is best to prevent over and underfitting. However, my code ...
2
votes
0answers
69 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 ...
2
votes
0answers
23 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
0answers
59 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 ...
2
votes
0answers
63 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 ...
2
votes
0answers
412 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 ...
2
votes
0answers
101 views

Module for statistics [closed]

Here is my module for statistics: ...
2
votes
0answers
91 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, ...
2
votes
3answers
112 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 ...
2
votes
0answers
43 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. ...
2
votes
0answers
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 ...
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
410 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. ...
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
2answers
2k views

Calculate median and quartile in C without sorting the array

Here's a piece of working code wrote in C to calculate the median without putting all values in an array and sorting them. It reads values from a file. ...
1
vote
2answers
117 views

Smearing estimate with Fortran

I wrote this Fortran module and I need its subroutines to run as fast as possible. My hope is to get some advice to optimize this code, and after having the serial version running as fast as it can ...
1
vote
1answer
231 views

Median of a Vector assignment

I've been reading Bjarne's Principles in Programming and was given some code to demonstrate the usage of vectors and how we can return specific values for certain functionality such as mean and median....
1
vote
2answers
555 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. ...
1
vote
2answers
71 views

Simple Linear Regression in C++

Python has amazing sci-kit learn library but I am building some projects on C++ with involves some machine learning algorithms. I found machine learning libraries in C++ involves more dependencies so ...
1
vote
1answer
75 views

Simulating data generating process correctly

My aim is to simulate the following model by means of a Monte Carlo simulation. I wonder if my R code is correct for generating the data. Could somebody check? The model: $$Y = \sum_{j=1}^{100} (...
1
vote
1answer
219 views

Using dplyr and pipes for logistic regression plotting

I have successfully created a plot of a binomial glm using example data. https://sciences.ucf.edu/biology/d4lab/wp-content/uploads/sites/125/2018/11/parasites.txt The predictors of the model include ...
1
vote
1answer
30 views

Creating the design matrices for a canonical correlation analysis

I have this code to generate symmetric matrices for testing how the design of the canonical correlation analysis I am performing works out. This is a extension of this solution Each row of the matrix ...
1
vote
1answer
62 views

Java Statistics: clinging to Static methods

I've been tooling around with a Statistical suite in Java, for use in a few machine learning projects (I know, 'ML in Java?'). I am looking for any improvements to be made here, with a specific focus ...
1
vote
2answers
117 views

Reducing array to average readings

Taking the payload below, I need to output the average of each reading. For example the readings for key 2 are 1, 4, 7. The average is (1+4+7)/3 = 4. The data is formatted in multi-dimensional ...
1
vote
1answer
78 views

Statistical Sample with Analytics Java

I've been playing with a statistical Sample object for an input/output model during the course of my machine learning class. I wanted to expand the functionality to add quadratic fit by least squares ...
1
vote
1answer
68 views

Basic cross-validation in R

We would like to perform n-fold non-stratified cross-validation on a model, say an lm or glm. We have a list of quality ...
1
vote
1answer
2k 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 ...
1
vote
1answer
2k views

Downsampling n-dimensional data from bins in one dimension

So I'm writing some code to perform a quite specific task given a large numpy array with N rows and 3 columns representing points in 3D. The 3D points are to be binned along one of the dimensions ...
1
vote
1answer
83 views

Get the most frequent number and least frequent duplicate in array

This code gets the most frequent number and least duplicate number in an array. How can I optimize it and improve its performance? ...
1
vote
1answer
642 views

Comparison of exponential smoothing and regression on a Lloyds bank's stock price data

What is one way to change it into a program that makes use of OOP concepts? I have always programmed this way and I feel that I would somehow need to improve on it. By the way, I have deliberately ...
1
vote
2answers
2k views

Finding unique pairs in lottery tickets

I was trying to solve one of the hackerrank practice questions. Could anyone please let me know how can I make this code much effective, in terms of time and space complexity? The Super Bowl ...
1
vote
1answer
23 views

Classifying counts of repeat visits per user for a website

I am trying to get number of times (or sessions) a user re-visited the website. What I'm trying to find out- Get the total number of users, number of sessions in the last 30days. I need to a pie ...
1
vote
1answer
49 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
70 views

Testing a chance-based class

So, chance, huh? Randomness. I'm looking into how I can test a class whose sole responsibility is to return weighted random results, that is, where there is a set probability of returning true. The ...