File:  [Research Unix] / researchv10dc / vol2 / grap / boyhts3.g
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Dan Cross

.G1
label left "Heights in Feet" "(Median and" "fifth percentiles)"
label bot "Heights of Boys in U.S., ages 2 to 18"
cmpft = 30.48  # Centimeters per foot
minx = 1e12; maxx = -1e12
n = sigx = sigx2 = sigy = sigxy = 0
copy "boyhts.d" thru {
	line from $1, $2/cmpft to $1, $4/cmpft
	ty = $3/cmpft
	bullet at $1,ty
	n = n+1
	sigx = sigx+$1; sigx2 = sigx2+$1*$1
	sigy = sigy+ty; sigxy = sigxy+$1*ty
	minx = min(minx,$1); maxx = max(maxx,$1)
}
# Calculate least squares fit and draw it
slope = (n*sigxy - sigx*sigy) / (n*sigx2 - sigx*sigx)
inter = (sigy - slope*sigx) / n
line from minx, slope*minx+inter to maxx, slope*maxx+inter
.G2

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.