Anonymous user
Statistics/Normal distribution: Difference between revisions
m
→{{header|REXX}}: changed comments, somplified some functions.
(Added FreeBASIC) |
m (→{{header|REXX}}: changed comments, somplified some functions.) |
||
Line 1,761:
end /*j*/
!.=0
say 'number of data points = ' aa(n )
say ' minimum = ' aa(mn )
say ' maximum = ' aa(mx )
say ' arithmetic mean = ' aa(s/n)
say ' standard deviation = ' aa(sqrt(ss/n - (s/n)**2) )
parse value scrSize() with sd sw .
sdE=sd-4 /*the effective (useable) screen depth.*/
swE=sw-1 /* " " " " width.*/
$=1 / max(1,mx-mn) * sdE /*$ is used for scaling depth of histo*/
do i=1 for n; ?=trunc((#.i-mn) * $) /*calculate the relative line.*/
f=swE/?mx
▲f=swE/?mx /*limit graph to 1 screen*/
▲ if _>noise then say copies('─', trunc(_*f)) /*display the histogram. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────*/
Line 1,786 ⟶ 1,784:
e: e =2.7182818284590452353602874713526624977572470936999595749669676277240766303535; return e
pi: pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862; return pi
rand: return random(
r2r: return arg(1) // (
.sincos: parse arg z,_,i; x=x*x; p=z; do k=2 by 2; _=-_*x/(k*(k+i)); z=z+_; if z=p then leave; p=z; end; return z
ln: procedure; parse arg x,f; call e; ig=x>1.5; is=1-2*(ig\==1); ii=0; xx=x; return .
.
xx=izz;ii=ii+is*2**k;end; x=x*e**-ii-1;z=0;_=-1;p=z; do k=1;_=-_*x;z=z+_/k;if z=p then leave;p=z;end; return z+ii
|