::Free Statistics and Forecasting Software::

v1.1.23-r3
 
  Black&White | Blue Theme | Normal Fontsize | Increase Fontsize | Decrease Fontsize | Toggle underline
Secure website (SSL) | Private
 
 


This software module is powered by R

:: Central Tendency - Free Statistics Software (Calculator) ::

All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.

This free online software (calculator) computes the following statistics: arithmetic mean, geometric mean, harmonic mean, quadratic mean, winsorized mean, trimmed mean, median, midrange, and midmean.

Click here to edit the underlying code of this R Module.

Enter (or paste) your data delimited by hard returns.

Send output to:
Data:
 
Sample Range:
(leave blank to include all observations)
From:
To:
Chart options
Width:
Height:
Title:
Y-axis minimum
Y-axis maximum

Click here to edit the underlying code of this R Module.





Source code of R module
1geomean <- function(x) {
2return(exp(mean(log(x))))
3}
4harmean <- function(x) {
5return(1/mean(1/x))
6}
7quamean <- function(x) {
8return(sqrt(mean(x*x)))
9}
10winmean <- function(x) {
11x <-sort(x[!is.na(x)])
12n<-length(x)
13denom <- 3
14nodenom <- n/denom
15if (nodenom>40) denom <- n/40
16sqrtn = sqrt(n)
17roundnodenom = floor(nodenom)
18win <- array(NA,dim=c(roundnodenom,2))
19for (j in 1:roundnodenom) {
20win[j,1] <- (j*x[j+1]+sum(x[(j+1):(n-j)])+j*x[n-j])/n
21win[j,2] <- sd(c(rep(x[j+1],j),x[(j+1):(n-j)],rep(x[n-j],j)))/sqrtn
22}
23return(win)
24}
25trimean <- function(x) {
26x <-sort(x[!is.na(x)])
27n<-length(x)
28denom <- 3
29nodenom <- n/denom
30if (nodenom>40) denom <- n/40
31sqrtn = sqrt(n)
32roundnodenom = floor(nodenom)
33tri <- array(NA,dim=c(roundnodenom,2))
34for (j in 1:roundnodenom) {
35tri[j,1] <- mean(x,trim=j/n)
36tri[j,2] <- sd(x[(j+1):(n-j)]) / sqrt(n-j*2)
37}
38return(tri)
39}
40midrange <- function(x) {
41return((max(x)+min(x))/2)
42}
43q1 <- function(data,n,p,i,f) {
44np <- n*p;
45i <<- floor(np)
46f <<- np - i
47qvalue <- (1-f)*data[i] + f*data[i+1]
48}
49q2 <- function(data,n,p,i,f) {
50np <- (n+1)*p
51i <<- floor(np)
52f <<- np - i
53qvalue <- (1-f)*data[i] + f*data[i+1]
54}
55q3 <- function(data,n,p,i,f) {
56np <- n*p
57i <<- floor(np)
58f <<- np - i
59if (f==0) {
60qvalue <- data[i]
61} else {
62qvalue <- data[i+1]
63}
64}
65q4 <- function(data,n,p,i,f) {
66np <- n*p
67i <<- floor(np)
68f <<- np - i
69if (f==0) {
70qvalue <- (data[i]+data[i+1])/2
71} else {
72qvalue <- data[i+1]
73}
74}
75q5 <- function(data,n,p,i,f) {
76np <- (n-1)*p
77i <<- floor(np)
78f <<- np - i
79if (f==0) {
80qvalue <- data[i+1]
81} else {
82qvalue <- data[i+1] + f*(data[i+2]-data[i+1])
83}
84}
85q6 <- function(data,n,p,i,f) {
86np <- n*p+0.5
87i <<- floor(np)
88f <<- np - i
89qvalue <- data[i]
90}
91q7 <- function(data,n,p,i,f) {
92np <- (n+1)*p
93i <<- floor(np)
94f <<- np - i
95if (f==0) {
96qvalue <- data[i]
97} else {
98qvalue <- f*data[i] + (1-f)*data[i+1]
99}
100}
101q8 <- function(data,n,p,i,f) {
102np <- (n+1)*p
103i <<- floor(np)
104f <<- np - i
105if (f==0) {
106qvalue <- data[i]
107} else {
108if (f == 0.5) {
109qvalue <- (data[i]+data[i+1])/2
110} else {
111if (f < 0.5) {
112qvalue <- data[i]
113} else {
114qvalue <- data[i+1]
115}
116}
117}
118}
119midmean <- function(x,def) {
120x <-sort(x[!is.na(x)])
121n<-length(x)
122if (def==1) {
123qvalue1 <- q1(x,n,0.25,i,f)
124qvalue3 <- q1(x,n,0.75,i,f)
125}
126if (def==2) {
127qvalue1 <- q2(x,n,0.25,i,f)
128qvalue3 <- q2(x,n,0.75,i,f)
129}
130if (def==3) {
131qvalue1 <- q3(x,n,0.25,i,f)
132qvalue3 <- q3(x,n,0.75,i,f)
133}
134if (def==4) {
135qvalue1 <- q4(x,n,0.25,i,f)
136qvalue3 <- q4(x,n,0.75,i,f)
137}
138if (def==5) {
139qvalue1 <- q5(x,n,0.25,i,f)
140qvalue3 <- q5(x,n,0.75,i,f)
141}
142if (def==6) {
143qvalue1 <- q6(x,n,0.25,i,f)
144qvalue3 <- q6(x,n,0.75,i,f)
145}
146if (def==7) {
147qvalue1 <- q7(x,n,0.25,i,f)
148qvalue3 <- q7(x,n,0.75,i,f)
149}
150if (def==8) {
151qvalue1 <- q8(x,n,0.25,i,f)
152qvalue3 <- q8(x,n,0.75,i,f)
153}
154midm <- 0
155myn <- 0
156roundno4 <- round(n/4)
157round3no4 <- round(3*n/4)
158for (i in 1:n) {
159if ((x[i]>=qvalue1) & (x[i]<=qvalue3)){
160midm = midm + x[i]
161myn = myn + 1
162}
163}
164midm = midm / myn
165return(midm)
166}
167(arm <- mean(x))
168sqrtn <- sqrt(length(x))
169(armse <- sd(x) / sqrtn)
170(armose <- arm / armse)
171(geo <- geomean(x))
172(har <- harmean(x))
173(qua <- quamean(x))
174(win <- winmean(x))
175(tri <- trimean(x))
176(midr <- midrange(x))
177midm <- array(NA,dim=8)
178for (j in 1:8) midm[j] <- midmean(x,j)
179midm
180bitmap(file="test1.png")
181lb <- win[,1] - 2*win[,2]
182ub <- win[,1] + 2*win[,2]
183if ((ylimmin == "") | (ylimmax == "")) plot(win[,1],type="b",main=main, xlab="j", pch=19, ylab="Winsorized Mean(j/n)", ylim=c(min(lb),max(ub))) else plot(win[,1],type="l",main=main, xlab="j", pch=19, ylab="Winsorized Mean(j/n)", ylim=c(ylimmin,ylimmax))
184lines(ub,lty=3)
185lines(lb,lty=3)
186grid()
187dev.off()
188bitmap(file="test2.png")
189lb <- tri[,1] - 2*tri[,2]
190ub <- tri[,1] + 2*tri[,2]
191if ((ylimmin == "") | (ylimmax == "")) plot(tri[,1],type="b",main=main, xlab="j", pch=19, ylab="Trimmed Mean(j/n)", ylim=c(min(lb),max(ub))) else plot(tri[,1],type="l",main=main, xlab="j", pch=19, ylab="Trimmed Mean(j/n)", ylim=c(ylimmin,ylimmax))
192lines(ub,lty=3)
193lines(lb,lty=3)
194grid()
195dev.off()
196load(file="createtable")
197a<-table.start()
198a<-table.row.start(a)
199a<-table.element(a,"Central Tendency - Ungrouped Data",4,TRUE)
200a<-table.row.end(a)
201a<-table.row.start(a)
202a<-table.element(a,"Measure",header=TRUE)
203a<-table.element(a,"Value",header=TRUE)
204a<-table.element(a,"S.E.",header=TRUE)
205a<-table.element(a,"Value/S.E.",header=TRUE)
206a<-table.row.end(a)
207a<-table.row.start(a)
208a<-table.element(a,hyperlink("http://www.xycoon.com/arithmetic_mean.htm", "Arithmetic Mean", "click to view the definition of the Arithmetic Mean"),header=TRUE)
209a<-table.element(a,arm)
210a<-table.element(a,hyperlink("http://www.xycoon.com/arithmetic_mean_standard_error.htm", armse, "click to view the definition of the Standard Error of the Arithmetic Mean"))
211a<-table.element(a,armose)
212a<-table.row.end(a)
213a<-table.row.start(a)
214a<-table.element(a,hyperlink("http://www.xycoon.com/geometric_mean.htm", "Geometric Mean", "click to view the definition of the Geometric Mean"),header=TRUE)
215a<-table.element(a,geo)
216a<-table.element(a,"")
217a<-table.element(a,"")
218a<-table.row.end(a)
219a<-table.row.start(a)
220a<-table.element(a,hyperlink("http://www.xycoon.com/harmonic_mean.htm", "Harmonic Mean", "click to view the definition of the Harmonic Mean"),header=TRUE)
221a<-table.element(a,har)
222a<-table.element(a,"")
223a<-table.element(a,"")
224a<-table.row.end(a)
225a<-table.row.start(a)
226a<-table.element(a,hyperlink("http://www.xycoon.com/quadratic_mean.htm", "Quadratic Mean", "click to view the definition of the Quadratic Mean"),header=TRUE)
227a<-table.element(a,qua)
228a<-table.element(a,"")
229a<-table.element(a,"")
230a<-table.row.end(a)
231for (j in 1:length(win[,1])) {
232a<-table.row.start(a)
233mylabel <- paste("Winsorized Mean (",j)
234mylabel <- paste(mylabel,"/")
235mylabel <- paste(mylabel,length(win[,1]))
236mylabel <- paste(mylabel,")")
237a<-table.element(a,hyperlink("http://www.xycoon.com/winsorized_mean.htm", mylabel, "click to view the definition of the Winsorized Mean"),header=TRUE)
238a<-table.element(a,win[j,1])
239a<-table.element(a,win[j,2])
240a<-table.element(a,win[j,1]/win[j,2])
241a<-table.row.end(a)
242}
243for (j in 1:length(tri[,1])) {
244a<-table.row.start(a)
245mylabel <- paste("Trimmed Mean (",j)
246mylabel <- paste(mylabel,"/")
247mylabel <- paste(mylabel,length(tri[,1]))
248mylabel <- paste(mylabel,")")
249a<-table.element(a,hyperlink("http://www.xycoon.com/arithmetic_mean.htm", mylabel, "click to view the definition of the Trimmed Mean"),header=TRUE)
250a<-table.element(a,tri[j,1])
251a<-table.element(a,tri[j,2])
252a<-table.element(a,tri[j,1]/tri[j,2])
253a<-table.row.end(a)
254}
255a<-table.row.start(a)
256a<-table.element(a,hyperlink("http://www.xycoon.com/median_1.htm", "Median", "click to view the definition of the Median"),header=TRUE)
257a<-table.element(a,median(x))
258a<-table.element(a,"")
259a<-table.element(a,"")
260a<-table.row.end(a)
261a<-table.row.start(a)
262a<-table.element(a,hyperlink("http://www.xycoon.com/midrange.htm", "Midrange", "click to view the definition of the Midrange"),header=TRUE)
263a<-table.element(a,midr)
264a<-table.element(a,"")
265a<-table.element(a,"")
266a<-table.row.end(a)
267a<-table.row.start(a)
268mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
269mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_1.htm","Weighted Average at Xnp",""),sep=" - ")
270a<-table.element(a,mylabel,header=TRUE)
271a<-table.element(a,midm[1])
272a<-table.element(a,"")
273a<-table.element(a,"")
274a<-table.row.end(a)
275a<-table.row.start(a)
276mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
277mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_2.htm","Weighted Average at X(n+1)p",""),sep=" - ")
278a<-table.element(a,mylabel,header=TRUE)
279a<-table.element(a,midm[2])
280a<-table.element(a,"")
281a<-table.element(a,"")
282a<-table.row.end(a)
283a<-table.row.start(a)
284mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
285mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_3.htm","Empirical Distribution Function",""),sep=" - ")
286a<-table.element(a,mylabel,header=TRUE)
287a<-table.element(a,midm[3])
288a<-table.element(a,"")
289a<-table.element(a,"")
290a<-table.row.end(a)
291a<-table.row.start(a)
292mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
293mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_4.htm","Empirical Distribution Function - Averaging",""),sep=" - ")
294a<-table.element(a,mylabel,header=TRUE)
295a<-table.element(a,midm[4])
296a<-table.element(a,"")
297a<-table.element(a,"")
298a<-table.row.end(a)
299a<-table.row.start(a)
300mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
301mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_5.htm","Empirical Distribution Function - Interpolation",""),sep=" - ")
302a<-table.element(a,mylabel,header=TRUE)
303a<-table.element(a,midm[5])
304a<-table.element(a,"")
305a<-table.element(a,"")
306a<-table.row.end(a)
307a<-table.row.start(a)
308mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
309mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_6.htm","Closest Observation",""),sep=" - ")
310a<-table.element(a,mylabel,header=TRUE)
311a<-table.element(a,midm[6])
312a<-table.element(a,"")
313a<-table.element(a,"")
314a<-table.row.end(a)
315a<-table.row.start(a)
316mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
317mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_7.htm","True Basic - Statistics Graphics Toolkit",""),sep=" - ")
318a<-table.element(a,mylabel,header=TRUE)
319a<-table.element(a,midm[7])
320a<-table.element(a,"")
321a<-table.element(a,"")
322a<-table.row.end(a)
323a<-table.row.start(a)
324mymid <- hyperlink("http://www.xycoon.com/midmean.htm", "Midmean", "click to view the definition of the Midmean")
325mylabel <- paste(mymid,hyperlink("http://www.xycoon.com/method_8.htm","MS Excel (old versions)",""),sep=" - ")
326a<-table.element(a,mylabel,header=TRUE)
327a<-table.element(a,midm[8])
328a<-table.element(a,"")
329a<-table.element(a,"")
330a<-table.row.end(a)
331a<-table.row.start(a)
332a<-table.element(a,"Number of observations",header=TRUE)
333a<-table.element(a,length(x))
334a<-table.element(a,"")
335a<-table.element(a,"")
336a<-table.row.end(a)
337a<-table.end(a)
338table.save(a,file="mytable.tab")
Top | Output | Charts | References | History | Feedback



Cite this software as:
Wessa, P., (2008), Central Tendency (v1.0.3) in Free Statistics Software (v1.1.23-r3), Office for Research Development and Education, URL http://www.wessa.net/rwasp_centraltendency.wasp/
The R code is based on :
Borghers, E, and P. Wessa, Statistics - Econometrics - Forecasting, Office for Research Development and Education, http://www.xycoon.com/
Top | Output | Charts | References | History | Feedback
Delete history
Server DateModuleCommand
Fri, 03 Jul 2009 15:16:16 -0600Start of session-
Top | Output | Charts | References | History | Feedback

Please, send us your feedback!
Overall rating
What do you think about the response time?
Rate the facility with which you interact with our software.
Is the output presented in an understandable (clear) form?
How did you find this website/module?
Do you have any comments or suggestions for our site?
Please enter the code that is displayed in this picture: captcha

To cite Wessa.net in publications use:
Wessa, P. (2009), Free Statistics Software, Office for Research Development and Education,
version 1.1.23-r3, URL http://www.wessa.net/

© Resa R&D, and the 'Office for Research, Development, and Education' - All rights reserved. Academic license for non-commercial use only.
This website is an intellectual and physical property of Resa R&D. This includes: html content, graphical illustrations (gif files), computer software, online or electronic documentation, associated media, and printed materials. The free use of the scientific content, services, and applications in this website is granted for non commercial use only. In any case, the source (url) should always be clearly displayed. Under no circumstances are you allowed to reproduce, copy or redistribute the design, layout, or any content of this website (for commercial use) including any materials contained herein without the express written permission of Resa R&D or the Office for Research, Development, and Education.

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, Resa R&D makes no warranties or representations as to the accuracy or completeness of such information (or software), and it assumes no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall Resa R&D be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.

Software Version : 1.1.23-r3
Algorithms & Software : Prof. dr. P. Wessa
Facilities : Resa R&D - Office for Research, Development, and Education
Server : www.wessa.net

Comments, Feedback & Errors | Privacy Policy | Statistics Resources | Wessa.net Home

 © Wessa.Net 2002-2009  
 
 

Home Page
Equation Plotter
Time Series Analysis (new)
Time Series Analysis (old)
Multiple Regression (new)
Multiple Regression (old)
Descriptive Statistics
Statistical Distributions
Hypothesis Testing
Statistics Education

Academic citations
Computations Archive
Search Computations
R Project
FAQ
About Wessa.net
Powered by Linux

Server status page
History list
Google
Web wessa.net



Resa R&D provides this service to the internet community free of charge. Support this project with your contribution.