> "Here is a program that hopefully will help wit the analysis and
of correlated data and the production of nice scatter plots":




with(stats):
with(stats[statplots]):
Convert:=proc(data)
local hap,hap1,d,j1,j2,j3,mean;
hap:=[];
hap1:=[];
d:=[];
for j1 from 1 to nops(data)
do
hap:=[op(hap),data[j1][2]];
od;
mean := nops(data)*describe[mean](hap);
for j2 from 1 to nops(data)
do
hap1:=[op(hap1), hap[j2]/mean];
od;
for j3 from 1 to nops(data)
do
d:=[op(d), [data[j3][1],hap1[j3]]];
od;
d;
end:
Bargraph:=proc(data,xmin,xmax,k)
local sorteddata,dx,graphicslist,f:
sorteddata:=[]:
dx:=(xmax-xmin)/k:
graphicslist:=[]:
sorteddata:=sort(data):
if ((op(1,sorteddata)<xmin) or (op(nops(sorteddata),sorteddata)>xmax))
then
lprint(`Note: some data values lie outside the user-defined interval.`):
fi:
f:=proc(k,sorteddata,xmin,dx,xmax)
local i,j,currentupperlim,leng,index,counter,result,finallist,q,numb,
linelist:
linelist:=[]: finallist:=[]:
index:=1:
leng:=nops(sorteddata):
currentupperlim:=xmin+dx:
result:=[]:
for q from 1 to leng do
if ((op(q,sorteddata)>=xmin) and (op(q,sorteddata)<=xmax))
then finallist:=[op(finallist),op(q,sorteddata)]
fi:
od:
numb:=nops(finallist):
for i from 1 to k do
counter:=0:
while ((index<=numb) and (op(index,finallist)<=currentupperlim)) do
counter:=counter+1:
index:=index+1:
od:
result:=[op(result),counter]:
currentupperlim:=currentupperlim+dx:
od:
for j from 1 to k do
linelist:=[op(linelist),[xmin + (j-1)*dx,0]]:
linelist:=[op(linelist),[xmin + (j-1)*dx,op(j,result)/leng]]:
linelist:=[op(linelist),[xmin + j*dx,op(j,result)/leng]]:
linelist:=[op(linelist),[xmin + j*dx,0]]:
od:
plot(linelist,style=LINE);
end:
f(k,sorteddata,xmin,dx,xmax):
end:Areabargraph:=proc(data,xmin,xmax,k)
local sorteddata, dx, lines,graphicslist, f:
sorteddata:=[]:
dx:=(xmax-xmin)/k:
lines:=[]:
graphicslist:=[]:
sorteddata:=sort(data):
if ((op(1,sorteddata)<xmin) or (op(nops(sorteddata),sorteddata)>xmax))
then
lprint(`Note: some data values lie outside the user-defined interval.`)
fi:
f:=proc(k,sorteddata,xmin,dx,xmax,lines::evaln)
local i,j,currentupperlim,leng,index,counter,result,
finallist,q,numb,linelist:
finallist:=[]:
linelist:=[]:
index:=1:
leng:=nops(sorteddata):
currentupperlim:=xmin+dx:
result:=[]:
for q from 1 to leng do
if ((op(q,sorteddata)>=xmin) and (op(q,sorteddata)<=xmax))
then finallist:=[op(finallist),op(q,sorteddata)]
fi:
od:
numb:=nops(finallist):
for i from 1 to k do
counter:=0:
while ((index<=numb) and (op(index,finallist)<=currentupperlim)) do
counter:=counter+1:
index:=index+1:
od:
result:=[op(result),counter]:
currentupperlim:=currentupperlim+dx:
od:
for j from 1 to k do
linelist:=[op(linelist),[xmin + (j-1)*dx,0]]:
linelist:=[op(linelist),[xmin + (j-1)*dx,op(j,result)/(leng*dx)]]:
linelist:=[op(linelist),[xmin + j*dx,op(j,result)/(leng*dx)]]:
linelist:=[op(linelist),[xmin + j*dx,0]]:
od:
lines:=linelist:
end:
f(k,sorteddata,xmin,dx,xmax,lines):
plot(lines,style=LINE);
end:




Mine:=proc(L,n)
local k,R;
R:=[];
for k from 1 to nops(L) do
R:=[op(R),[L[k][n],1]];
od:
R;
end:


Mine2:=proc(L,n)
local k,R;
R:=[];
for k from 1 to nops(L) do
R:=[op(R),L[k][n]];
od:
R;
end:





AveIt:=proc(L,K)
local k,R;
R:=[];
for k from 1 to nops(L)
do
R:=[op(R),1/2*(L[k]+K[k])];
od;
R;
end:

Fuzz:=proc(L,H,E1)
local L1,H1,k1,R,k2;
L1:=[];
H1:=[];
for k1 from 1 to nops(L)
do
R:=E1*stats[random, uniform[0,1]](1);
L1:=[op(L1),L[k1]+R];
od;
for k2 from 1 to nops(L)
do
R:=E1*stats[random, uniform[0,1]](1);
H1:=[op(H1),H[k2]+R];
od;
[L1,H1];
end:

Analysis:=proc(L)
local m,v,sd,k,S,i,j,l;
m:=0;
v:=0;
sd:=0;
for k from 1 to nops(L)
do
m:=m+L[k];
od;
m:=evalf(m/nops(L));
for i from 1 to nops(L)
do
v:=v+(L[i]-m)^2;
od;
v:=evalf(v/nops(L));
sd:=evalf(sqrt(v));
[m,v,sd];
end:


Analysis2:=proc(L,H)
local cov,cor,st,ml,mh,sl,sh,Al,Ah,k;
cov:=0;
cor:=0;
st:=0;
Al:=Analysis(L);
Ah:=Analysis(H);
ml:=Al[1];
mh:=Ah[1];
sl:=Al[3];
sh:=Ah[3];
for k from 1 to nops(L)
do
cov:=cov+(L[k]-ml)*(H[k]-mh);
od;
cov:=cov/nops(L);
cor:=cov/(sl*sh);
st:=cor^2;
[cov,cor,st];
end:


"Here is a program no analyze pairs of potentially correlated data":

Scatter:=proc(B,type)
local ml,mh,sl,sh,cor,str,Al,Ah,A,F,L,H;
L:=Mine2(B,1):;
H:=Mine2(B,2):;
Al:=Analysis(L);
Ah:=Analysis(H);
A:=Analysis2(L,H);
if A[2] <= 0 then
sl:= - (Ah[3]/Al[3]);
else
sl:= (Ah[3]/Al[3]);
fi;
lprint("the first set of data has mean",Al[1],"and standard deviation",Al[3]);
lprint("the second set of dat has mean",Ah[1],"and standard deviation",Ah[3]);
lprint("the correlation of the second on the first is",A[2]):
lprint("while the strength of this correlation is",evalf(100*A[3]),"percent"):
if type=Whole
then
F:=Fuzz(L,H,.5):
else;
F:=[L,H]:
fi;
lprint("Here is the scatter plot, where the black line is the is the regression line of the second set of data on the first and the blue line is the
standard deviation line.");
plots[display](
{scatterplot(F[1],F[2],color=red),
plot((A[2]*(sl))*(x-Al[1])+Ah[1], x=min(op(L))-1..max(op(L))+1,color=black),
plot((sl)*(x-Al[1])+Ah[1], x=min(op(L))-1..max(op(L))+1,color=blue)
}, view = [min(op(L))-1..max(op(L))+1, min(op(H))-1..max(op(H))+1], axes=frame,color=red
);
end:

Warning, these names have been redefined: anova, describe, fit, importdata, random, statevalf, statplots, transform

Warning, these names have been redefined: boxplot, histogram, scatterplot, xscale, xshift, xyexchange, xzexchange, yscale, yshift, yzexchange, zscale, zshift

> "To enter your data you may enter a list of pairs as follows. ":


Example:=[
[12,7],
[8,10],
[5,8],
[10,9],
[12,10],
[4,8],
[11,8],
[5,10],
[7,6],
[12,10],
[8,7],
[12,11],
[9,6],
[8,7],
[8,9],
[12,10],
[6,5],
[10,11],
[8,11],
[7,8],
[7,7],
[9,7],
[10,10],
[9,9],
[7,3],
[8,9],
[8,8],
[10,8],
[7,10],
[10,9],
[9,10],
[8,8],
[11,7],
[7,9],
[10,8],
[10,7],
[9,9],
[9,9],
[10,8]
];

Example := [[12, 7], [8, 10], [5, 8], [10, 9], [12,...
Example := [[12, 7], [8, 10], [5, 8], [10, 9], [12,...
Example := [[12, 7], [8, 10], [5, 8], [10, 9], [12,...

> "Notice that the correlation and regression line are given for the second set of data on the first. Meaning if you want to know the average score
on the second exam of someone who received a score of x on the first exam you look at the x value on the horizontal axis and use the regression
line. The strength of the correlation can be interpreted
as the percentage of the of the variation of the second data that can be explained by its 'linear' relationship to the first set of data. To see
the scatter plot, and some relevant information, you type in Scatter(YourList,Whole) if your data is amprised of whole numbers, and where YourList refers to the list of data pairs as entered above. If not your not using whole numbers type Scatter(YourList,Not). For
example...":


Scatter(Exams,Whole);

"the first set of data has mean", 8.769230769, "and standard deviation", 2.005908432

"the second set of dat has mean", 8.358974359, "and standard deviation", 1.686859919

"the correlation of the second on the first is", .2821287072

"while the strength of this correlation is", 7.959660743, "percent"

"Here is the scatter plot, where the black line is the is the regression line of the second set of data on the first and the blue line is the\nstandard deviation line."

[Maple Plot]

> Scatter(Exams,Not);

"the first set of data has mean", 8.769230769, "and standard deviation", 2.005908432

"the second set of dat has mean", 8.358974359, "and standard deviation", 1.686859919

"the correlation of the second on the first is", .2821287072

"while the strength of this correlation is", 7.959660743, "percent"

"Here is the scatter plot, where the black line is the is the regression line of the second set of data on the first and the blue line is the\nstandard deviation line."

[Maple Plot]

>