Re: eliminate values while caculating Mean[data]
- To: mathgroup at smc.vnet.net
- Subject: [mg91951] Re: eliminate values while caculating Mean[data]
- From: kazik.lakomy at gmail.com
- Date: Mon, 15 Sep 2008 03:38:51 -0400 (EDT)
- References: <gag2rl$3fq$1@smc.vnet.net>
Hello Pasha, I would generally recommend you to write your own functions, it's more customizable:) I wrote the function you need. Here it is: The name of your set of data is "Data" and looks like in your post, say: Data={1,2,3,4,5}; Value of "Summ" gives you a sum of all non-zero elements in "Data" and "NonZeroValuesCounter" gives you a number of non-zero entries in "Data". "Average" is what you want. Just paste the script below into Mathematica and run: Summ = 0; NonZeroValuesCounter = 0; For[index = 1, index <= Length[Data], index += 1, If[Data[[index]] != 0, Summ += Data[[index]]; NonZeroValuesCounter += 1]; ]; Average = Summ/NonZeroValuesCounter; Print["Summ: ", Summ, " NonZeroValuesCounter: ", NonZeroValuesCounter, " Average: ", Average] ------------- Have fun, best regards, Kazik