1 | var R = require("./rlab");
|
2 | var c = console;
|
3 |
|
4 | var x = R.samples(R.steps(0,100, 10), 10, {replace:true}).value();
|
5 | c.log("x=", x);
|
6 |
|
7 | var x = R.samples(R.steps(1,6), 10, {replace:false}).value();
|
8 | c.log("x=%j max=%d min=%d mean=%d", x, R.max(x), R.min(x), R.mean(x));
|
9 |
|
10 | c.log("cov(x,x)=", R.cov(x,x).toFixed(2));
|
11 | c.log("cor(x,x)=", R.cor(x,x).toFixed(2));
|
12 | c.log("factorial(10)=", R.factorial(10));
|
13 | c.log("lfactorial(10)=", R.lfactorial(10).toFixed(2));
|
14 | c.log("choose(5,2)=", R.choose(5,2));
|
15 | c.log("lchoose(5,2)=", R.lchoose(5,2).toFixed(2));
|
16 | c.log("permutation(5,2)=", R.permutation(5,2));
|
17 |
|
18 | c.log("runif(10, -5, -1)=", R.runif(10, -5, -1).str());
|
19 | c.log("dunif(-3, -5, -1)=", R.dunif(-3, -5, -1));
|
20 | c.log("punif(-3, -5, -1)=", R.punif(-3, -5, -1));
|
21 | c.log("qunif(0.5, -5, -1)=", R.qunif(0.5, -5, -1));
|
22 |
|
23 | var x = R.rnorm(10, 0, 1);
|
24 | c.log("x.str()=", x.str());
|
25 | c.log("x.sortBy()=", x.sortBy().str());
|
26 |
|
27 | c.log("str(x)=", R.str(x.value()));
|
28 |
|
29 | c.log("rbinom(10, 5, 0.5)=", R.rbinom(10,5,0.5));
|
30 | c.log("dbinom(4, 5, 0.5)=", R.dbinom(4,5,0.5));
|
31 | c.log("dbinom(5, 5, 0.5)=", R.dbinom(5,5,0.5));
|
32 | c.log("pbinom(4, 5, 0.5)=", R.pbinom(4,5,0.5));
|
33 | c.log("qbinom(0.9, 5, 0.5)=", R.qbinom(0.9,5,0.5));
|
34 |
|
35 | c.log("sd(x)=", x.sd().toFixed(2));
|
36 |
|
37 | var t1=R.ttest({x:x.value(), mu:0} );
|
38 | R.report(t1);
|
39 |
|
40 |
|