2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,13 +1,13 @@
|
|||
;Task:
|
||||
Given a set of data vectors in the following format:
|
||||
|
||||
<math>y = \{ y_1, y_2, ..., y_n \}\,</math>
|
||||
<math>y = \{ y_1, y_2, ..., y_n \}\,</math>
|
||||
|
||||
<math>X_i = \{ x_{i1}, x_{i2}, ..., x_{in} \}, i \in 1..k\,</math>
|
||||
<math>X_i = \{ x_{i1}, x_{i2}, ..., x_{in} \}, i \in 1..k\,</math>
|
||||
|
||||
Compute the vector <math>\beta = \{ \beta_1, \beta_2, ..., \beta_k \}</math> using
|
||||
[[wp:Ordinary least squares|ordinary least squares]] regression using the following equation:
|
||||
Compute the vector <math>\beta = \{ \beta_1, \beta_2, ..., \beta_k \}</math> using [[wp:Ordinary least squares|ordinary least squares]] regression using the following equation:
|
||||
|
||||
<math>y_j = \Sigma_i \beta_i \cdot x_{ij} , j \in 1..n</math>
|
||||
<math>y_j = \Sigma_i \beta_i \cdot x_{ij} , j \in 1..n</math>
|
||||
|
||||
You can assume <i>y</i> is given to you as a vector (a one-dimensional array),
|
||||
and <i>X</i> is given to you as a two-dimensional array (i.e. matrix).
|
||||
You can assume <i> y </i> is given to you as a vector (a one-dimensional array), and <i> X </i> is given to you as a two-dimensional array (i.e. matrix).
|
||||
<br><br>
|
||||
|
|
|
|||
16
Task/Multiple-regression/Perl-6/multiple-regression.pl6
Normal file
16
Task/Multiple-regression/Perl-6/multiple-regression.pl6
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use Clifford;
|
||||
my @height = <1.47 1.50 1.52 1.55 1.57 1.60 1.63 1.65 1.68 1.70 1.73 1.75 1.78 1.80 1.83>;
|
||||
my @weight = <52.21 53.12 54.48 55.84 57.20 58.57 59.93 61.29 63.11 64.47 66.28 68.10 69.92 72.19 74.46>;
|
||||
|
||||
my $w = [+] @weight Z* @e;
|
||||
|
||||
my $h0 = [+] @e[^@weight];
|
||||
my $h1 = [+] @height Z* @e;
|
||||
my $h2 = [+] (@height X** 2) Z* @e;
|
||||
|
||||
my $I = $h0∧$h1∧$h2;
|
||||
my $I2 = ($I·$I.reversion).Real;
|
||||
|
||||
say "α = ", ($w∧$h1∧$h2)·$I.reversion/$I2;
|
||||
say "β = ", ($w∧$h2∧$h0)·$I.reversion/$I2;
|
||||
say "γ = ", ($w∧$h0∧$h1)·$I.reversion/$I2;
|
||||
Loading…
Add table
Add a link
Reference in a new issue