mean

What's the quickest way to get the mean of a set of numbers from the command line?

Using any tools which you would expect to find on a nix system (in fact, if you want, msdos is also fine too), what is the easiest/fastest way to calculate the mean of a set of numbers, assuming you have them one per line in a stream or file? ...

Why does isNaN(" ") equal false

Hi, all. I have a quick question (I hope!). In JS, why does isNaN(" ") evaluate to false, but isNaN(" x") evaluate to true? I'm performing numerical operations on a text input field, and am checking if the field is null, "", or NaN. When someone types a handful of spaces into the field, my validation fails on all three, and I'm co...

How to calculate mean based on number of votes/scores/samples/etc?

For simplicity say we have a sample set of possible scores {0, 1, 2}. Is there a way to calculate a mean based on the number of scores without getting into hairy lookup tables etc for a 95% confidence interval calculation? dreeves posted a solution to this here: How can I calculate a fair overall game score based on a variable number o...

How to use numpy with 'None' value in python?

Hello everybody, i'm a pretty new user of python and numpy, so i hope my question won't annoy you. Well, i'd like to calculate the mean of an array in python in this form : Matrice = [1, 2, None] I'd just like to have my None value ignored by the numpy.mean calculation but i can't figure out how to do it. If anybody can help me tha...

Weighted average of angles

I want to calculate the weighted mean of a set of angles. In this Question, there's an answer how to calculate the mean as shown in this page. Now I'm trying to figure out how to calculate the weighted average. That is, for each angle there is a weight (the weights sum up to 1) 0.25, 0 degrees 0.5, 20 degrees 0.25, 90 degrees The we...

SSRS Chart w/Series and Mean

Hi all, I have a chart I'm making in SSRS. My database is returning data like this: Period Name, Question, Answer, Count, Mean, Median Nov 09, Can Haz Chezbrgr, Yes, 5, 4, 3.1 Nov 09, Can Haz Chezbrgr, No, 3, 4, 3.1 Nov 09, Can Haz Chezbrgr, DK, 2, 4, 3.1 Period Name is the primary grouping, question is the same for all rows. Answe...

How should I perform this binning and averaging in MATLAB?

I am trying to perform a binning average. I am using the code: Avg = mean(reshape(a,300,144,27)); AvgF = squeeze(Avg); The last line gets rid of singleton dimensions. So as can be seen I am averaging over 300 points. It works fine except for times when I have a total number of points not equal to a multiple of 144*300. Is there any ...

Matlab loops for a function

Hi, I am trying to make a loop to redo a Matlab function 1000 times. Here's the program d = unifrnd (0,10,[10,1]); c = d.^(-2); a = round(unifrnd(0,1,[1,10]); e = a*c btotal = e+1 SIR = 1/btotal What I want is to iterate this function 1000 times, each time the value of SIR will vary due to the random number generated. For every iterat...

How can I calculate the mean of all months until now?

I have a column with a value for each month, like: 1,2,3,...,12. And I have a row with 12 cells (each corresponding to a month). And I have another cell that says the current month. My question is: How can I calculate the mean of the values until the current month? I was doing something like « =MEAN(IF(S4>S16;D4:O4;IF(S4>S15;D4:N4; IF(...

Reducing Mean Square Error

The topic of mine is face recognition using artificial neural networks using MATLAB code. I tried my work by taking the images from web and started implementing the program by using neural networks. By typing nprtool command in MATLAB ,i started training, testing and validating the images from database. When i started to calculate the...

Mean filter in MATLAB without loops or signal processing toolbox

I need to implement a mean filter on a data set, but I don't have access to the signal processing toolbox. Is there a way to do this without using a for loop? Here's the code I've got working: x=0:.1:10*pi; noise=0.5*(rand(1,length(x))-0.5); y=sin(x)+noise; %generate noisy signal a=10; %specify moving window siz...

Quality questionnaire php mysql graphipcs

Hi, i'm making a questionnaire about a service quality, its contains the options (poor, regular, good, very good). It's contains 6 questions (radio button) and a suggestion box (textbox). In the table of the database i created 6 rows for questions, 1 for suggestion and 1 for date (a friend of mine tole me to use this but i didn't get why...

When to use geometric vs arithmetic mean?

So I guess this isn't technically a code question, but it's something that I'm sure will come up for other folks as well as myself while writing code, so hopefully it's still a good one to post on SO. The Google has directed me to plenty of nice lengthy explanations of when to use one or the other as regards financial numbers, and thing...

Image similarity and k-mean clustering ...

Hi I'm playing a little bit with image similarity. In fact i'm playing with image retrieval system. Ideally i wanna to create some kind of image index that I can query to get similar images. My current thought is to store some kind of ImageDescriptor into index and each descriptor can have different features in it, e.g. k-mean-cluster-...

"average length of the sequences in a fasta file": Can you improve this Erlang code ?

I'm trying to get the mean length of fasta sequences using Erlang. A fasta file looks like this >title1 ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATCGATCATATA ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATCTCGTACGC >title2 ATCGATCGCATCGATGCTACGATCTCGTACGC ATGACTAGCTAGCAGCGATCGACCGTCGTACGC ATCGATCGCATCGATGCTACGATC...

How to find the mean/average of a sound in Nyquist

I'm trying to write a simple measurement plug-in for Audacity and it's about as much fun as pounding rocks against my skull. All I want to do is take a chunk of audio and find the average of all the samples (the chunk's DC offset) so that I can present it as a number to the user, and so that I can subtract the DC offset from the samples...

Element-wise mean in R

In R, I have two vectors: a <- c(1, 2, 3, 4) b <- c(NA, 6, 7, 8) How do I find the element-wise mean of the two vectors, removing NA, without a loop? i.e. I want to get the vector of (1, 4, 5, 6) I know the function mean(), I know the argument na.rm = 1. But I don't know how to put things together. To be sure, in reality I have th...

An accurate running statistical mean of a large array of bytes

I have a two dimensional array of bytes which looks like this: int n = 100000; int d = 128; byte[][] samples = new byte[n][d] /* proceed to fill samples with some delicious data */ byte[] mean = new byte[d]; findMean(mean,samples); My findMean function proceeds to fill mean such that: mean[k] = mean(samples[:][k]) Simple enough so ...

calculating means of many matrices in numpy

I have many csv files which each contain roughly identical matrices. Each matrix is 11 columns by either 5 or 6 rows. The columns are variables and the rows are test conditions. Some of the matrices do not contain data for the last test condition, which is why there are 5 rows in some matrices and six rows in other matrices. My appli...