Domino: Difference between revisions
From NARS2000
Jump to navigationJump to search
(inserted examples for monadic and dyadic domino-matrix inverse-quad divide) |
m (wording) |
||
Line 23: | Line 23: | ||
Homes ⍝The first row of variable/matrix Homes has nested column headers, with 22 data rows: | Homes ⍝The first row of variable/matrix Homes has nested column headers, with 22 data rows: | ||
⍝Col#'s 1 2 3 4 5 6 7 8 | ⍝Col#'s 1 2 3 4 5 6 7 8 | ||
Property SqFt #Bedrooms #FullBaths #HalfBaths YrsAgoBuilt Price Predicted Price ⍝Note | Property SqFt #Bedrooms #FullBaths #HalfBaths YrsAgoBuilt Price Predicted Price ⍝Note: Predicted Price col(8) is not yet calculated! | ||
A 2149 3 2 1 15 469.9 0 | A 2149 3 2 1 15 469.9 0 | ||
B 2410 4 3 1 13 523.5 0 | B 2410 4 3 1 13 523.5 0 | ||
Line 47: | Line 47: | ||
V 3835 3 3 1 6 982.5 0 | V 3835 3 3 1 6 982.5 0 | ||
RegrCoeffs←(1↓Homes[;7])⌹1,(1 0↓Homes[;2 3 4 5 6]) ⍝Calc | ⍝Note just below that because the first row of Homes has column headers(text) - they must be dropped from ⌹'s least-squares data fit. | ||
⍴RegrCoeffs | RegrCoeffs←(1↓Homes[;7])⌹1,(1 0↓Homes[;2 3 4 5 6]) ⍝Calc regr. coeff's using Home Prices(col 7, dep var Y) vs. all indep vars(X's, cols 2-6) | ||
⍴RegrCoeffs ⍝Note '⌹1,' just above means add extra coeff. for Y-intercept; plus cols(2-6)=5 indep X-type vars; RegrCoeffs has 6 elements. | |||
6 | 6 | ||
RegrCoeffs | RegrCoeffs | ||
234.9773005 0.1495539775 ¯41.70990009 80.27420326 16.19671155 ¯7.019567895 | 234.9773005 0.1495539775 ¯41.70990009 80.27420326 16.19671155 ¯7.019567895 | ||
Homes[1+⍳22;8]←(1,Homes[1+⍳22;2 3 4 5 6])+.×RegrCoeffs ⍝Use inner product +.× to | Homes[1+⍳22;8]←(1,Homes[1+⍳22;2 3 4 5 6])+.×RegrCoeffs ⍝Use inner product +.× to calc predicted prices for 22 data rows, place in col 8. | ||
Homes ⍝The following is what variable Homes looks like; with Predicted Prices calculated and inserted back into matrix Homes: | Homes ⍝The following is what variable Homes looks like; with Predicted Prices calculated and inserted back into matrix Homes: |
Revision as of 20:44, 3 March 2015
⌹ — Matrix Inverse or Division — Keystroke ALT+SHIFT+= — Character 9017
Note: The symbol is created by ALT+SHIFT+=; ALT+= will produce Divide (÷)
Usage
Examples
⌹ Monadic Example - Matrix Inverse for a square matrix:
Z ⍝Variable and matrix Z has 3 rows and 3 columns of numbers, as follows: 1 2 3 0 1 4 5 6 0 ⌹Z ⍝The mathmatical inverse of matrix Z (domino Z) is also a 3-row by 3-col numeric matrix, as follows: ¯24 18 5 20 ¯15 ¯4 ¯5 4 1
⌹ Dyadic Example - Matrix Division - Least Squares Curve Fitting - Multiple Regression using Non-Square Data Matrix:
⍴Homes ⍝Global variable Homes is a 23 row by 8 column matrix: 23 8 Homes ⍝The first row of variable/matrix Homes has nested column headers, with 22 data rows: ⍝Col#'s 1 2 3 4 5 6 7 8 Property SqFt #Bedrooms #FullBaths #HalfBaths YrsAgoBuilt Price Predicted Price ⍝Note: Predicted Price col(8) is not yet calculated! A 2149 3 2 1 15 469.9 0 B 2410 4 3 1 13 523.5 0 C 2530 4 3 0 12 535 0 D 2502 3 2 0 12 569.999 0 E 2600 5 2 1 17 588 0 F 2586 4 3 1 6 589 0 G 2836 3 2 1 12 599.9 0 H 3300 4 2 1 10 615 0 I 3000 4 3 0 11 659 0 J 2723 3 2 1 12 665 0 K 2800 4 3 1 18 729 0 L 3700 5 3 1 4 767 0 M 3900 4 3 1 19 799.9 0 N 3840 6 4 1 6 945 0 O 2185 3 2 0 12 515 0 P 2600 4 3 0 12 579.5 0 Q 4220 5 3 1 18 645.9 0 R 2136 3 2 0 14 505 0 S 2530 3 2 1 13 539.9 0 T 2724 3 2 0 12 634.9 0 U 2896 4 3 0 7 750 0 V 3835 3 3 1 6 982.5 0 ⍝Note just below that because the first row of Homes has column headers(text) - they must be dropped from ⌹'s least-squares data fit. RegrCoeffs←(1↓Homes[;7])⌹1,(1 0↓Homes[;2 3 4 5 6]) ⍝Calc regr. coeff's using Home Prices(col 7, dep var Y) vs. all indep vars(X's, cols 2-6) ⍴RegrCoeffs ⍝Note '⌹1,' just above means add extra coeff. for Y-intercept; plus cols(2-6)=5 indep X-type vars; RegrCoeffs has 6 elements. 6 RegrCoeffs 234.9773005 0.1495539775 ¯41.70990009 80.27420326 16.19671155 ¯7.019567895 Homes[1+⍳22;8]←(1,Homes[1+⍳22;2 3 4 5 6])+.×RegrCoeffs ⍝Use inner product +.× to calc predicted prices for 22 data rows, place in col 8. Homes ⍝The following is what variable Homes looks like; with Predicted Prices calculated and inserted back into matrix Homes: Property SqFt #Bedrooms #FullBaths #HalfBaths YrsAgoBuilt Price Predicted Price A 2149 3 2 1 15 469.9 502.6906976 B 2410 4 3 1 13 523.5 594.3277247 C 2530 4 3 0 12 535 603.0970583 D 2502 3 2 0 12 569.999 560.3452438 E 2600 5 2 1 17 588 472.6806055 F 2586 4 3 1 6 589 669.7862 G 2836 3 2 1 12 599.9 626.4929838 H 3300 4 2 1 10 615 668.2152651 I 3000 4 3 0 11 659 680.4069957 J 2723 3 2 1 12 665 609.5933844 K 2800 4 3 1 18 729 617.5559364 L 3700 5 3 1 4 767 808.7185666 M 3900 4 3 1 19 799.9 775.0457438 N 3840 6 4 1 6 945 854.1812909 O 2185 3 2 0 12 515 512.9366329 P 2600 4 3 0 12 579.5 613.5658367 Q 4220 5 3 1 18 645.9 788.2126844 R 2136 3 2 0 14 505 491.5693522 S 2530 3 2 1 13 539.9 573.7098988 T 2724 3 2 0 12 634.9 593.5462268 U 2896 4 3 0 7 750 692.9316536 V 3835 3 3 1 6 982.5 898.289018
See Also | ||
System Commands | System Variables and Functions | Operators |
Keyboard | ||||||||||||||
Alt+Shift | ⍪ | ≡ | ≢ | ⍒ | ⍋ | ⌽ | ⍉ | ⊖ | ⍟ | ⍱ | ⍲ | ⍠ | ⌹ | |
Alt | ⋄ | ¨ | ¯ | < | ≤ | ∅ | ≥ | > | ≠ | ∨ | ∧ | × | ÷ | |
Shift | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | _ | + | |
Key | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | |
Alt+Shift | ⍷ | √ | ⍨ | ⍸ | ⍥ | ⍣ | ⍞ | ⍬ | ⊣ | |||||
Alt | ? | ⍵ | ∊ | ⍴ | § | ↑ | ↓ | ⍳ | ○ | π | ← | → | ⊢ | |
Shift | Q | W | E | R | T | Y | U | I | O | P | { | } | | | |
Key | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | |
Alt+Shift | ∫ | ∂ | ⌻ | ⍢ | ⍙ | ⍤ | ⍫ | ⌷ | ||||||
Alt | ⍺ | ⌈ | ⌊ | ∞ | ∇ | ∆ | ∘ | ‼ | ⎕ | ⍎ | ⍕ | |||
Shift | A | S | D | F | G | H | J | K | L | : | " | |||
Key | a | s | d | f | g | h | j | k | l | ; | ' | |||
Alt+Shift | ⊆ | ⊇ | χ | ⍡ | ⍭ | ⊙ | ||||||||
Alt | ⊂ | ⊃ | ∩ | ∪ | ⊥ | ⊤ | ⍦ | ⍝ | ⍀ | ⌿ | ||||
Shift | Z | X | C | V | B | N | M | < | > | ? | ||||
Key | z | x | c | v | b | n | m | , | . | / |
NARS 2000 Lang Tool Bar |
← | → | + | - | × | ÷ | * | ⍟ | ⌹ | ○ | ! | ? | √ | | | ⌈ | ⌊ | ⊥ | ⊤ | ⊣ | ⊢ | |||
≡ | ≢ | < | ≤ | = | ≥ | > | ≠ | ∨ | ∧ | ⍱ | ⍲ | ↑ | ↓ | ⊂ | ⊃ | ⌷ | ⍋ | ⍒ | |||||
⍳ | ∊ | ⍸ | ⍷ | ∪ | ∩ | ⊆ | ⊇ | ~ | § | π | .. | , | ⍪ | ⍴ | ⌽ | ⊖ | ⍉ | ||||||
/ | \ | ⌿ | ⍀ | ⊙ | ¨ | ⍨ | ⍤ | ⍣ | ⍡ | ⍥ | ⍦ | . | ∘ | ⍠ | ‼ | ⌻ | ∂ | ∫ | ⍞ | ⎕ | ⍎ | ⍕ | |
⋄ | ⍝ | ∇ | ∆ | ⍙ | _ | ⍺ | ⍵ | ¯ | ⍬ | ∞ | ∅ | ||||||||||||
Second Row | i j k | i j k l | g | p | r | v | x |
[[Category:Mouse Group {{{1}}}|{{{2}}}]]