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
1
vote
2answers
2k 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
3k 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
3k 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
2answers
119 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
423 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
874 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
1answer
76 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
396 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
33 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
63 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
118 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
82 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
72 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

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
34 views

Simulation of Central Limiting Theorem (CLT)

The following is the simulation of Central Limiting Theorem from Statistics: ...
1
vote
1answer
200 views

Remove outliers from N dimensional data

I have created a function that will remove outliers from a series of data. Generally the data n dimensional. Loosely, an outlier is considered an outlier if it +/- deviates by 1.5 standard_deviation's ...
1
vote
1answer
244 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
658 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
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
74 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 ...
1
vote
1answer
56 views

VBA Macro to generate a report of mean values for each date

My Macro that I wrote is running really slowly and I'm not sure why. The Macro deletes the area, then reproduces one column of locations as a row, deleting any duplicates, then copy's across a column ...
1
vote
1answer
77 views

Counting standard deviation from parsed XML file

I wrote a method that calculates the average and standard deviation of sell currency exchange-course (ASK). But I think that it isn't the easiest way to define such behavior. In my opinion there is ...
1
vote
1answer
68 views

Solving for a seed value in R

I'm trying to reproduce a gbm model which was estimated without a set.seed value. To do so I need to determine what seed was ...
1
vote
1answer
492 views

Calculate and plot statistics on an R matrix

My goal is to iterate over a datamatrix, calculate mean, standard error of the mean, and then have a bar plot representing the 2 groups of my data matrix in R. My code below works as a for loop. ...
1
vote
1answer
77 views

ANOVA Using Continuous CDFs

I have a procedure for conducting ANOVA, 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 groups. Below is the R ...
1
vote
1answer
55 views

Certainty of two comparative values (A/B results certainty)

I'm trying to output the percentage of certainty of two comparatives data. Here's the resulting code: ...
1
vote
1answer
7k views
1
vote
3answers
331 views

Improve nested loop for bio-statistics calculation

I am doing a bio-statistics calculation and the following code works. However, can someone help to improve the messy nested loop? ...
1
vote
0answers
58 views

Find the median of two sorted arrays [closed]

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall ...
1
vote
0answers
34 views

Sortings stocks into quantiles based on their signal

This function sorts stocks into quantiles. To do so I used this function that accepts sig_df (dataframe with the timeseries of stocks signal) and number of ...
1
vote
0answers
31 views

Flagging out-of-stock items

I wrote a function that iterates over 3 parameters to spot out-of-stock items. To illustrate this I'll draw an example: suppose that the product 10 in store 2 for an offer named "super5" is following ...
1
vote
0answers
186 views

Linear Regression Model with Python 3

I am trying to create a python module calculating correlation and creating regression model for single independent variable and two independent variables. The program works correctly, I use lots of ...
1
vote
0answers
53 views

Lazy Statistics: XYSamples java

After previous review I chose to alter this project to use lazy evaluation. Looking for any and all improvement feedback. This project is meant to represent a two dimensional data set, i.e., single-...
1
vote
0answers
92 views

JSON file for storing means and standard deviation values per demographic group

I wrote an ad hoc script in Python 3 that calculates where the patient result reside with a specific demographic group within the Turkish population, but until now I stored the data in the python code ...
1
vote
0answers
84 views

Backward elimination of fixed effects using lme4

I am trying to write a function that used drop1.merMod from the lme4 package to automatically remove fixed effect terms until ...
1
vote
0answers
137 views

Monty Hall Problem in Javascript ES6 and React

Any suggestions for optimization are appreciated! ...
1
vote
0answers
102 views

Estimate Hidden Markov Model with both continuous and discrete observations, possible missing data

My code estimates a Hidden Markov Model (HMM) using the expectations-maximization (EM) algorithm. I followed https://www.princeton.edu/~rvan/orf557/hmm080728.pdf with modifications to allow for panel ...
1
vote
0answers
795 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
0answers
59 views

Simultaneous confidence interval

I recently read an article in which the authors present Algorithm 1 to compute a simultaneous confidence interval. I was interested in implementing Algorithm 1 in R here. The algorithm is freely ...
1
vote
0answers
55 views

Penalized logistic ridge regression

This code is for the penalized logistic regression that we should to choose \$\lambda\$ in regularization to control the trade off. I use the first function to estimate the \$\hat{\beta}\$ and the ...
1
vote
0answers
72 views

Numerical maximization procedure normal distribution

Firstly, I programmed this gaussian density as an R function which takes the parameters mean and variance (mean=4,sd=1) and ...
0
votes
3answers
723 views

Calculate median of a matrix

I am solving interview questions from here. Problem : Given a N cross M matrix in which each row is sorted, find the overall median of the matrix. Assume N*M is odd. Note: No extra memory is ...
0
votes
1answer
96 views

A simple Python graphing tool

I've written a primitive Python script which "draws graphs" based on a list. It works, but it's a lot of lines for what I am trying to reach. The idea of the script is to function as a module that can ...
0
votes
1answer
934 views

Median of two sorted arrays

The task is to find the median of two Arrays. I have an O(n) solution. Can it be written in a better time complexity? ...
0
votes
2answers
2k views

Program to find the mean, median, and mode of numbers

I was attempting to build a program using Ruby that asks the user to input at least three numbers, and it returns the mean, median, and mode of those numbers. A developer friend of mine glanced over ...
0
votes
1answer
40 views

Calculate the statistical mean of different files and save it into a CSV file

In this code I calculate the statistical functions of values from different files and save them into CSV files (one filer for each statistical function). ...
0
votes
1answer
50 views

Generating probability table of 2-character combinations from text file in Java

I have written a probability table generator in Java to help me generate randomized girl's names for the game I am making. It reads from a text file and creates a ...
0
votes
3answers
72 views

Top-10 lists of occupations, ranked by various attributes

In the code below, all pairs of functions are very similar: set function rankListId is different rankListName is different ...
0
votes
0answers
30 views

Block Bootstrap Estimation in Java - Part 3

This is an extension of Block Bootstrap Estimation in Java - Part 2. The text file text.txt can be found at https://drive.google.com/open?id=1vLBoNmFyh4alDZt1eoJpavuEwWlPZSKX (please download the file ...

1
4 5 6
7
8