diff options
-rw-r--r-- | examples/pinv.hs | 13 | ||||
-rw-r--r-- | examples/pinv.ipynb | 722 |
2 files changed, 728 insertions, 7 deletions
diff --git a/examples/pinv.hs b/examples/pinv.hs index 7de50b8..6f093b4 100644 --- a/examples/pinv.hs +++ b/examples/pinv.hs | |||
@@ -1,20 +1,19 @@ | |||
1 | import Numeric.LinearAlgebra | 1 | import Numeric.LinearAlgebra |
2 | import Graphics.Plot | ||
3 | import Text.Printf(printf) | 2 | import Text.Printf(printf) |
4 | 3 | ||
5 | expand :: Int -> Vector Double -> Matrix Double | 4 | expand :: Int -> Vector R -> Matrix R |
6 | expand n x = fromColumns $ map (x^) [0 .. n] | 5 | expand n x = fromColumns $ map (x^) [0 .. n] |
7 | 6 | ||
8 | polynomialModel :: Vector Double -> Vector Double -> Int | 7 | polynomialModel :: Vector R -> Vector R -> Int |
9 | -> (Vector Double -> Vector Double) | 8 | -> (Vector R -> Vector R) |
10 | polynomialModel x y n = f where | 9 | polynomialModel x y n = f where |
11 | f z = expand n z <> ws | 10 | f z = expand n z #> ws |
12 | ws = expand n x <\> y | 11 | ws = expand n x <\> y |
13 | 12 | ||
14 | main = do | 13 | main = do |
15 | [x,y] <- (toColumns . readMatrix) `fmap` readFile "data.txt" | 14 | [x,y] <- toColumns <$> loadMatrix "data.txt" |
16 | let pol = polynomialModel x y | 15 | let pol = polynomialModel x y |
17 | let view = [x, y, pol 1 x, pol 2 x, pol 3 x] | 16 | let view = [x, y, pol 1 x, pol 2 x, pol 3 x] |
18 | putStrLn $ " x y p 1 p 2 p 3" | 17 | putStrLn $ " x y p 1 p 2 p 3" |
19 | putStrLn $ format " " (printf "%.2f") $ fromColumns view | 18 | putStrLn $ format " " (printf "%.2f") $ fromColumns view |
20 | mplot view | 19 | |
diff --git a/examples/pinv.ipynb b/examples/pinv.ipynb new file mode 100644 index 0000000..532b8d0 --- /dev/null +++ b/examples/pinv.ipynb | |||
@@ -0,0 +1,722 @@ | |||
1 | { | ||
2 | "cells": [ | ||
3 | { | ||
4 | "cell_type": "code", | ||
5 | "execution_count": 1, | ||
6 | "metadata": { | ||
7 | "collapsed": true | ||
8 | }, | ||
9 | "outputs": [], | ||
10 | "source": [ | ||
11 | "import Numeric.LinearAlgebra" | ||
12 | ] | ||
13 | }, | ||
14 | { | ||
15 | "cell_type": "code", | ||
16 | "execution_count": 2, | ||
17 | "metadata": { | ||
18 | "collapsed": true | ||
19 | }, | ||
20 | "outputs": [], | ||
21 | "source": [ | ||
22 | "import IHaskell.Display" | ||
23 | ] | ||
24 | }, | ||
25 | { | ||
26 | "cell_type": "code", | ||
27 | "execution_count": 3, | ||
28 | "metadata": { | ||
29 | "collapsed": false | ||
30 | }, | ||
31 | "outputs": [], | ||
32 | "source": [ | ||
33 | ":ext FlexibleInstances\n", | ||
34 | "\n", | ||
35 | "dec = 3\n", | ||
36 | "\n", | ||
37 | "instance IHaskellDisplay (Matrix C) where\n", | ||
38 | " display m = return $ Display [html (\"<p>$$\"++(latexFormat \"bmatrix\" . dispcf dec) m++\"$$</p>\")]\n", | ||
39 | "\n", | ||
40 | "instance IHaskellDisplay (Matrix R) where\n", | ||
41 | " display m = return $ Display [html (\"<p>$$\"++ (latexFormat \"bmatrix\" . dispf dec) m++\"$$</p>\")]" | ||
42 | ] | ||
43 | }, | ||
44 | { | ||
45 | "cell_type": "code", | ||
46 | "execution_count": 4, | ||
47 | "metadata": { | ||
48 | "collapsed": true | ||
49 | }, | ||
50 | "outputs": [], | ||
51 | "source": [ | ||
52 | "import Graphics.SVG\n", | ||
53 | "data RawSVG = RawSVG String\n", | ||
54 | "instance IHaskellDisplay RawSVG where\n", | ||
55 | " display (RawSVG s) = return $ Display [html $ \"<div style=\\\"width:600px\\\">\"++ s ++ \"</div>\"]\n", | ||
56 | "\n", | ||
57 | "lplot = RawSVG . hPlot" | ||
58 | ] | ||
59 | }, | ||
60 | { | ||
61 | "cell_type": "markdown", | ||
62 | "metadata": {}, | ||
63 | "source": [ | ||
64 | "# least squares polynomial model" | ||
65 | ] | ||
66 | }, | ||
67 | { | ||
68 | "cell_type": "code", | ||
69 | "execution_count": 5, | ||
70 | "metadata": { | ||
71 | "collapsed": false | ||
72 | }, | ||
73 | "outputs": [], | ||
74 | "source": [ | ||
75 | "expand :: Int -> Vector R -> Matrix R\n", | ||
76 | "expand n x = fromColumns $ map (x^) [0 .. n]\n", | ||
77 | "\n", | ||
78 | "polynomialModel :: Vector R -> Vector R -> Int -> (Vector R -> Vector R)\n", | ||
79 | "polynomialModel x y n = f\n", | ||
80 | " where\n", | ||
81 | " f z = expand n z #> ws\n", | ||
82 | " ws = expand n x <\\> y" | ||
83 | ] | ||
84 | }, | ||
85 | { | ||
86 | "cell_type": "code", | ||
87 | "execution_count": 6, | ||
88 | "metadata": { | ||
89 | "collapsed": true | ||
90 | }, | ||
91 | "outputs": [], | ||
92 | "source": [ | ||
93 | "[x,y] <- toColumns <$> loadMatrix \"data.txt\"" | ||
94 | ] | ||
95 | }, | ||
96 | { | ||
97 | "cell_type": "code", | ||
98 | "execution_count": 7, | ||
99 | "metadata": { | ||
100 | "collapsed": false | ||
101 | }, | ||
102 | "outputs": [ | ||
103 | { | ||
104 | "data": { | ||
105 | "text/plain": [ | ||
106 | "[0.9,2.1,3.1,4.0,4.9,6.1,7.0,7.9,9.1,10.2]" | ||
107 | ] | ||
108 | }, | ||
109 | "metadata": {}, | ||
110 | "output_type": "display_data" | ||
111 | }, | ||
112 | { | ||
113 | "data": { | ||
114 | "text/plain": [ | ||
115 | "[1.1,3.9,9.2,51.8,25.3,35.7,49.4,3.6,81.5,99.5]" | ||
116 | ] | ||
117 | }, | ||
118 | "metadata": {}, | ||
119 | "output_type": "display_data" | ||
120 | } | ||
121 | ], | ||
122 | "source": [ | ||
123 | "x\n", | ||
124 | "y" | ||
125 | ] | ||
126 | }, | ||
127 | { | ||
128 | "cell_type": "code", | ||
129 | "execution_count": 8, | ||
130 | "metadata": { | ||
131 | "collapsed": false | ||
132 | }, | ||
133 | "outputs": [ | ||
134 | { | ||
135 | "data": { | ||
136 | "text/html": [ | ||
137 | "<style>/*\n", | ||
138 | "Custom IHaskell CSS.\n", | ||
139 | "*/\n", | ||
140 | "\n", | ||
141 | "/* Styles used for the Hoogle display in the pager */\n", | ||
142 | ".hoogle-doc {\n", | ||
143 | " display: block;\n", | ||
144 | " padding-bottom: 1.3em;\n", | ||
145 | " padding-left: 0.4em;\n", | ||
146 | "}\n", | ||
147 | ".hoogle-code {\n", | ||
148 | " display: block;\n", | ||
149 | " font-family: monospace;\n", | ||
150 | " white-space: pre;\n", | ||
151 | "}\n", | ||
152 | ".hoogle-text {\n", | ||
153 | " display: block;\n", | ||
154 | "}\n", | ||
155 | ".hoogle-name {\n", | ||
156 | " color: green;\n", | ||
157 | " font-weight: bold;\n", | ||
158 | "}\n", | ||
159 | ".hoogle-head {\n", | ||
160 | " font-weight: bold;\n", | ||
161 | "}\n", | ||
162 | ".hoogle-sub {\n", | ||
163 | " display: block;\n", | ||
164 | " margin-left: 0.4em;\n", | ||
165 | "}\n", | ||
166 | ".hoogle-package {\n", | ||
167 | " font-weight: bold;\n", | ||
168 | " font-style: italic;\n", | ||
169 | "}\n", | ||
170 | ".hoogle-module {\n", | ||
171 | " font-weight: bold;\n", | ||
172 | "}\n", | ||
173 | ".hoogle-class {\n", | ||
174 | " font-weight: bold;\n", | ||
175 | "}\n", | ||
176 | "\n", | ||
177 | "/* Styles used for basic displays */\n", | ||
178 | ".get-type {\n", | ||
179 | " color: green;\n", | ||
180 | " font-weight: bold;\n", | ||
181 | " font-family: monospace;\n", | ||
182 | " display: block;\n", | ||
183 | " white-space: pre-wrap;\n", | ||
184 | "}\n", | ||
185 | "\n", | ||
186 | ".show-type {\n", | ||
187 | " color: green;\n", | ||
188 | " font-weight: bold;\n", | ||
189 | " font-family: monospace;\n", | ||
190 | " margin-left: 1em;\n", | ||
191 | "}\n", | ||
192 | "\n", | ||
193 | ".mono {\n", | ||
194 | " font-family: monospace;\n", | ||
195 | " display: block;\n", | ||
196 | "}\n", | ||
197 | "\n", | ||
198 | ".err-msg {\n", | ||
199 | " color: red;\n", | ||
200 | " font-style: italic;\n", | ||
201 | " font-family: monospace;\n", | ||
202 | " white-space: pre;\n", | ||
203 | " display: block;\n", | ||
204 | "}\n", | ||
205 | "\n", | ||
206 | "#unshowable {\n", | ||
207 | " color: red;\n", | ||
208 | " font-weight: bold;\n", | ||
209 | "}\n", | ||
210 | "\n", | ||
211 | ".err-msg.in.collapse {\n", | ||
212 | " padding-top: 0.7em;\n", | ||
213 | "}\n", | ||
214 | "\n", | ||
215 | "/* Code that will get highlighted before it is highlighted */\n", | ||
216 | ".highlight-code {\n", | ||
217 | " white-space: pre;\n", | ||
218 | " font-family: monospace;\n", | ||
219 | "}\n", | ||
220 | "\n", | ||
221 | "/* Hlint styles */\n", | ||
222 | ".suggestion-warning { \n", | ||
223 | " font-weight: bold;\n", | ||
224 | " color: rgb(200, 130, 0);\n", | ||
225 | "}\n", | ||
226 | ".suggestion-error { \n", | ||
227 | " font-weight: bold;\n", | ||
228 | " color: red;\n", | ||
229 | "}\n", | ||
230 | ".suggestion-name {\n", | ||
231 | " font-weight: bold;\n", | ||
232 | "}\n", | ||
233 | "</style><p>$$\\begin{bmatrix}\n", | ||
234 | "1.000 & 0.900 & 0.810\n", | ||
235 | "\\\\\n", | ||
236 | "1.000 & 2.100 & 4.410\n", | ||
237 | "\\\\\n", | ||
238 | "1.000 & 3.100 & 9.610\n", | ||
239 | "\\\\\n", | ||
240 | "1.000 & 4.000 & 16.000\n", | ||
241 | "\\\\\n", | ||
242 | "1.000 & 4.900 & 24.010\n", | ||
243 | "\\\\\n", | ||
244 | "1.000 & 6.100 & 37.210\n", | ||
245 | "\\\\\n", | ||
246 | "1.000 & 7.000 & 49.000\n", | ||
247 | "\\\\\n", | ||
248 | "1.000 & 7.900 & 62.410\n", | ||
249 | "\\\\\n", | ||
250 | "1.000 & 9.100 & 82.810\n", | ||
251 | "\\\\\n", | ||
252 | "1.000 & 10.200 & 104.040\n", | ||
253 | "\\end{bmatrix}$$</p>" | ||
254 | ] | ||
255 | }, | ||
256 | "metadata": {}, | ||
257 | "output_type": "display_data" | ||
258 | } | ||
259 | ], | ||
260 | "source": [ | ||
261 | "expand 2 x" | ||
262 | ] | ||
263 | }, | ||
264 | { | ||
265 | "cell_type": "code", | ||
266 | "execution_count": 9, | ||
267 | "metadata": { | ||
268 | "collapsed": true | ||
269 | }, | ||
270 | "outputs": [], | ||
271 | "source": [ | ||
272 | "pol = polynomialModel x y\n", | ||
273 | "view = [x, y, pol 1 x, pol 2 x, pol 3 x]" | ||
274 | ] | ||
275 | }, | ||
276 | { | ||
277 | "cell_type": "code", | ||
278 | "execution_count": 10, | ||
279 | "metadata": { | ||
280 | "collapsed": false | ||
281 | }, | ||
282 | "outputs": [ | ||
283 | { | ||
284 | "data": { | ||
285 | "text/plain": [ | ||
286 | " x y p 1 p 2 p 3" | ||
287 | ] | ||
288 | }, | ||
289 | "metadata": {}, | ||
290 | "output_type": "display_data" | ||
291 | }, | ||
292 | { | ||
293 | "data": { | ||
294 | "text/plain": [ | ||
295 | " 0.90 1.10 -3.41 7.70 -6.99\n", | ||
296 | " 2.10 3.90 6.83 9.80 15.97\n", | ||
297 | " 3.10 9.20 15.36 13.39 25.09\n", | ||
298 | " 4.00 51.80 23.04 18.05 28.22\n", | ||
299 | " 4.90 25.30 30.72 24.05 28.86\n", | ||
300 | " 6.10 35.70 40.96 34.16 29.68\n", | ||
301 | " 7.00 49.40 48.64 43.31 33.17\n", | ||
302 | " 7.90 3.60 56.32 53.82 41.60\n", | ||
303 | " 9.10 81.50 66.57 69.92 64.39\n", | ||
304 | "10.20 99.50 75.95 86.80 101.01" | ||
305 | ] | ||
306 | }, | ||
307 | "metadata": {}, | ||
308 | "output_type": "display_data" | ||
309 | } | ||
310 | ], | ||
311 | "source": [ | ||
312 | "import Text.Printf\n", | ||
313 | "\n", | ||
314 | "putStrLn \" x y p 1 p 2 p 3\"\n", | ||
315 | "putStrLn $ format \" \" (printf \"%.2f\") $ fromColumns view" | ||
316 | ] | ||
317 | }, | ||
318 | { | ||
319 | "cell_type": "code", | ||
320 | "execution_count": 11, | ||
321 | "metadata": { | ||
322 | "collapsed": false | ||
323 | }, | ||
324 | "outputs": [], | ||
325 | "source": [ | ||
326 | "t = linspace 100 (minElement x, maxElement x)" | ||
327 | ] | ||
328 | }, | ||
329 | { | ||
330 | "cell_type": "code", | ||
331 | "execution_count": 12, | ||
332 | "metadata": { | ||
333 | "collapsed": false | ||
334 | }, | ||
335 | "outputs": [ | ||
336 | { | ||
337 | "data": { | ||
338 | "text/html": [ | ||
339 | "<style>/*\n", | ||
340 | "Custom IHaskell CSS.\n", | ||
341 | "*/\n", | ||
342 | "\n", | ||
343 | "/* Styles used for the Hoogle display in the pager */\n", | ||
344 | ".hoogle-doc {\n", | ||
345 | " display: block;\n", | ||
346 | " padding-bottom: 1.3em;\n", | ||
347 | " padding-left: 0.4em;\n", | ||
348 | "}\n", | ||
349 | ".hoogle-code {\n", | ||
350 | " display: block;\n", | ||
351 | " font-family: monospace;\n", | ||
352 | " white-space: pre;\n", | ||
353 | "}\n", | ||
354 | ".hoogle-text {\n", | ||
355 | " display: block;\n", | ||
356 | "}\n", | ||
357 | ".hoogle-name {\n", | ||
358 | " color: green;\n", | ||
359 | " font-weight: bold;\n", | ||
360 | "}\n", | ||
361 | ".hoogle-head {\n", | ||
362 | " font-weight: bold;\n", | ||
363 | "}\n", | ||
364 | ".hoogle-sub {\n", | ||
365 | " display: block;\n", | ||
366 | " margin-left: 0.4em;\n", | ||
367 | "}\n", | ||
368 | ".hoogle-package {\n", | ||
369 | " font-weight: bold;\n", | ||
370 | " font-style: italic;\n", | ||
371 | "}\n", | ||
372 | ".hoogle-module {\n", | ||
373 | " font-weight: bold;\n", | ||
374 | "}\n", | ||
375 | ".hoogle-class {\n", | ||
376 | " font-weight: bold;\n", | ||
377 | "}\n", | ||
378 | "\n", | ||
379 | "/* Styles used for basic displays */\n", | ||
380 | ".get-type {\n", | ||
381 | " color: green;\n", | ||
382 | " font-weight: bold;\n", | ||
383 | " font-family: monospace;\n", | ||
384 | " display: block;\n", | ||
385 | " white-space: pre-wrap;\n", | ||
386 | "}\n", | ||
387 | "\n", | ||
388 | ".show-type {\n", | ||
389 | " color: green;\n", | ||
390 | " font-weight: bold;\n", | ||
391 | " font-family: monospace;\n", | ||
392 | " margin-left: 1em;\n", | ||
393 | "}\n", | ||
394 | "\n", | ||
395 | ".mono {\n", | ||
396 | " font-family: monospace;\n", | ||
397 | " display: block;\n", | ||
398 | "}\n", | ||
399 | "\n", | ||
400 | ".err-msg {\n", | ||
401 | " color: red;\n", | ||
402 | " font-style: italic;\n", | ||
403 | " font-family: monospace;\n", | ||
404 | " white-space: pre;\n", | ||
405 | " display: block;\n", | ||
406 | "}\n", | ||
407 | "\n", | ||
408 | "#unshowable {\n", | ||
409 | " color: red;\n", | ||
410 | " font-weight: bold;\n", | ||
411 | "}\n", | ||
412 | "\n", | ||
413 | ".err-msg.in.collapse {\n", | ||
414 | " padding-top: 0.7em;\n", | ||
415 | "}\n", | ||
416 | "\n", | ||
417 | "/* Code that will get highlighted before it is highlighted */\n", | ||
418 | ".highlight-code {\n", | ||
419 | " white-space: pre;\n", | ||
420 | " font-family: monospace;\n", | ||
421 | "}\n", | ||
422 | "\n", | ||
423 | "/* Hlint styles */\n", | ||
424 | ".suggestion-warning { \n", | ||
425 | " font-weight: bold;\n", | ||
426 | " color: rgb(200, 130, 0);\n", | ||
427 | "}\n", | ||
428 | ".suggestion-error { \n", | ||
429 | " font-weight: bold;\n", | ||
430 | " color: red;\n", | ||
431 | "}\n", | ||
432 | ".suggestion-name {\n", | ||
433 | " font-weight: bold;\n", | ||
434 | "}\n", | ||
435 | "</style><div style=\"width:600px\"><?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n", | ||
436 | "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='0 0 600 400' >\n", | ||
437 | "\n", | ||
438 | "<g style='text-anchor:middle'>\n", | ||
439 | "<text x='300.000' y='30.000' style='font-size:14.0px'> polynomial models </text>\n", | ||
440 | "\n", | ||
441 | "</g>\n", | ||
442 | "\n", | ||
443 | "<g style='fill:white; stroke:none; stroke-width:1.0'>\n", | ||
444 | "<rect x='70.000' y='50.000' width='490.000' height='300.000' />\n", | ||
445 | "\n", | ||
446 | "</g>\n", | ||
447 | "\n", | ||
448 | "<g style='stroke:black;stroke-width:0.1;stroke-dasharray:2'>\n", | ||
449 | "<path d = 'M 144.961 350.000 144.961 50.000 ' />\n", | ||
450 | "<path d = 'M 240.758 350.000 240.758 50.000 ' />\n", | ||
451 | "<path d = 'M 336.554 350.000 336.554 50.000 ' />\n", | ||
452 | "<path d = 'M 432.351 350.000 432.351 50.000 ' />\n", | ||
453 | "<path d = 'M 528.148 350.000 528.148 50.000 ' />\n", | ||
454 | "\n", | ||
455 | "<path d = 'M 70.000 317.304 560.000 317.304 ' />\n", | ||
456 | "<path d = 'M 70.000 279.118 560.000 279.118 ' />\n", | ||
457 | "<path d = 'M 70.000 240.932 560.000 240.932 ' />\n", | ||
458 | "<path d = 'M 70.000 202.745 560.000 202.745 ' />\n", | ||
459 | "<path d = 'M 70.000 164.559 560.000 164.559 ' />\n", | ||
460 | "<path d = 'M 70.000 126.373 560.000 126.373 ' />\n", | ||
461 | "<path d = 'M 70.000 88.186 560.000 88.186 ' />\n", | ||
462 | "<path d = 'M 70.000 50.000 560.000 50.000 ' />\n", | ||
463 | "\n", | ||
464 | "\n", | ||
465 | "</g>\n", | ||
466 | "\n", | ||
467 | "\n", | ||
468 | "<defs> <clipPath id='clip7000050000490000300000'>\n", | ||
469 | "<rect x='70.000' y='50.000' width='490.000' height='300.000' />\n", | ||
470 | "</clipPath> </defs>\n", | ||
471 | "<g clip-path='url(#clip7000050000490000300000)'>\n", | ||
472 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
473 | "<path d = 'M 92.273 277.018 149.751 271.672 197.649 261.552 240.758 180.215 283.866 230.812 341.344 210.955 384.453 184.798 427.561 272.244 485.039 123.509 537.727 89.141 ' />\n", | ||
474 | "\n", | ||
475 | "</g>\n", | ||
476 | "\n", | ||
477 | "<g style='fill:red; stroke:none; stroke-width:1.0'>\n", | ||
478 | "<circle cx='92.273' cy='277.018' r='3.000' />\n", | ||
479 | "<circle cx='149.751' cy='271.672' r='3.000' />\n", | ||
480 | "<circle cx='197.649' cy='261.552' r='3.000' />\n", | ||
481 | "<circle cx='240.758' cy='180.215' r='3.000' />\n", | ||
482 | "<circle cx='283.866' cy='230.812' r='3.000' />\n", | ||
483 | "<circle cx='341.344' cy='210.955' r='3.000' />\n", | ||
484 | "<circle cx='384.453' cy='184.798' r='3.000' />\n", | ||
485 | "<circle cx='427.561' cy='272.244' r='3.000' />\n", | ||
486 | "<circle cx='485.039' cy='123.509' r='3.000' />\n", | ||
487 | "<circle cx='537.727' cy='89.141' r='3.000' />\n", | ||
488 | "\n", | ||
489 | "\n", | ||
490 | "</g>\n", | ||
491 | "\n", | ||
492 | "\n", | ||
493 | "<g style='fill:none; stroke:blue; stroke-width:1.0'>\n", | ||
494 | "<path d = 'M 92.273 285.630 96.772 284.099 101.272 282.569 105.771 281.038 110.271 279.508 114.770 277.977 119.270 276.447 123.770 274.916 128.269 273.385 132.769 271.855 137.268 270.324 141.768 268.794 146.267 267.263 150.767 265.732 155.266 264.202 159.766 262.671 164.265 261.141 168.765 259.610 173.264 258.079 177.764 256.549 182.264 255.018 186.763 253.488 191.263 251.957 195.762 250.426 200.262 248.896 204.761 247.365 209.261 245.835 213.760 244.304 218.260 242.774 222.759 241.243 227.259 239.712 231.758 238.182 236.258 236.651 240.758 235.121 245.257 233.590 249.757 232.059 254.256 230.529 258.756 228.998 263.255 227.468 267.755 225.937 272.254 224.406 276.754 222.876 281.253 221.345 285.753 219.815 290.253 218.284 294.752 216.753 299.252 215.223 303.751 213.692 308.251 212.162 312.750 210.631 317.250 209.100 321.749 207.570 326.249 206.039 330.748 204.509 335.248 202.978 339.747 201.448 344.247 199.917 348.747 198.386 353.246 196.856 357.746 195.325 362.245 193.795 366.745 192.264 371.244 190.733 375.744 189.203 380.243 187.672 384.743 186.142 389.242 184.611 393.742 183.080 398.242 181.550 402.741 180.019 407.241 178.489 411.740 176.958 416.240 175.427 420.739 173.897 425.239 172.366 429.738 170.836 434.238 169.305 438.737 167.775 443.237 166.244 447.736 164.713 452.236 163.183 456.736 161.652 461.235 160.122 465.735 158.591 470.234 157.060 474.734 155.530 479.233 153.999 483.733 152.469 488.232 150.938 492.732 149.407 497.231 147.877 501.731 146.346 506.230 144.816 510.730 143.285 515.230 141.754 519.729 140.224 524.229 138.693 528.728 137.163 533.228 135.632 537.727 134.102 ' />\n", | ||
495 | "\n", | ||
496 | "</g>\n", | ||
497 | "\n", | ||
498 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
499 | "\n", | ||
500 | "\n", | ||
501 | "</g>\n", | ||
502 | "\n", | ||
503 | "\n", | ||
504 | "<g style='fill:none; stroke:green; stroke-width:1.0'>\n", | ||
505 | "<path d = 'M 92.273 264.421 96.772 264.272 101.272 264.094 105.771 263.889 110.271 263.655 114.770 263.393 119.270 263.103 123.770 262.786 128.269 262.440 132.769 262.066 137.268 261.663 141.768 261.233 146.267 260.775 150.767 260.288 155.266 259.774 159.766 259.231 164.265 258.661 168.765 258.062 173.264 257.435 177.764 256.780 182.264 256.097 186.763 255.386 191.263 254.647 195.762 253.880 200.262 253.084 204.761 252.261 209.261 251.409 213.760 250.530 218.260 249.622 222.759 248.686 227.259 247.722 231.758 246.730 236.258 245.710 240.758 244.662 245.257 243.586 249.757 242.482 254.256 241.349 258.756 240.189 263.255 239.000 267.755 237.784 272.254 236.539 276.754 235.266 281.253 233.966 285.753 232.637 290.253 231.280 294.752 229.894 299.252 228.481 303.751 227.040 308.251 225.571 312.750 224.073 317.250 222.548 321.749 220.994 326.249 219.412 330.748 217.802 335.248 216.165 339.747 214.499 344.247 212.805 348.747 211.082 353.246 209.332 357.746 207.554 362.245 205.747 366.745 203.913 371.244 202.050 375.744 200.160 380.243 198.241 384.743 196.294 389.242 194.319 393.742 192.316 398.242 190.285 402.741 188.226 407.241 186.139 411.740 184.024 416.240 181.880 420.739 179.709 425.239 177.509 429.738 175.281 434.238 173.026 438.737 170.742 443.237 168.430 447.736 166.090 452.236 163.722 456.736 161.326 461.235 158.902 465.735 156.449 470.234 153.969 474.734 151.460 479.233 148.924 483.733 146.359 488.232 143.766 492.732 141.145 497.231 138.496 501.731 135.819 506.230 133.114 510.730 130.381 515.230 127.620 519.729 124.831 524.229 122.013 528.728 119.168 533.228 116.294 537.727 113.392 ' />\n", | ||
506 | "\n", | ||
507 | "</g>\n", | ||
508 | "\n", | ||
509 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
510 | "\n", | ||
511 | "\n", | ||
512 | "</g>\n", | ||
513 | "\n", | ||
514 | "\n", | ||
515 | "<g style='fill:none; stroke:brown; stroke-width:1.0'>\n", | ||
516 | "<path d = 'M 92.273 292.464 96.772 287.916 101.272 283.574 105.771 279.435 110.271 275.493 114.770 271.744 119.270 268.182 123.770 264.803 128.269 261.602 132.769 258.574 137.268 255.714 141.768 253.018 146.267 250.480 150.767 248.096 155.266 245.861 159.766 243.770 164.265 241.818 168.765 240.000 173.264 238.312 177.764 236.749 182.264 235.305 186.763 233.976 191.263 232.757 195.762 231.644 200.262 230.630 204.761 229.713 209.261 228.886 213.760 228.145 218.260 227.485 222.759 226.901 227.259 226.389 231.758 225.943 236.258 225.558 240.758 225.230 245.257 224.955 249.757 224.726 254.256 224.540 258.756 224.391 263.255 224.274 267.755 224.185 272.254 224.120 276.754 224.072 281.253 224.037 285.753 224.010 290.253 223.987 294.752 223.963 299.252 223.933 303.751 223.891 308.251 223.833 312.750 223.755 317.250 223.651 321.749 223.517 326.249 223.347 330.748 223.137 335.248 222.882 339.747 222.578 344.247 222.218 348.747 221.799 353.246 221.316 357.746 220.763 362.245 220.137 366.745 219.431 371.244 218.642 375.744 217.764 380.243 216.792 384.743 215.723 389.242 214.550 393.742 213.269 398.242 211.875 402.741 210.364 407.241 208.730 411.740 206.969 416.240 205.075 420.739 203.044 425.239 200.872 429.738 198.552 434.238 196.081 438.737 193.454 443.237 190.665 447.736 187.710 452.236 184.584 456.736 181.283 461.235 177.800 465.735 174.132 470.234 170.274 474.734 166.220 479.233 161.966 483.733 157.507 488.232 152.839 492.732 147.956 497.231 142.853 501.731 137.526 506.230 131.970 510.730 126.180 515.230 120.151 519.729 113.879 524.229 107.358 528.728 100.583 533.228 93.550 537.727 86.254 ' />\n", | ||
517 | "\n", | ||
518 | "</g>\n", | ||
519 | "\n", | ||
520 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
521 | "\n", | ||
522 | "\n", | ||
523 | "</g>\n", | ||
524 | "\n", | ||
525 | "\n", | ||
526 | "<g style='fill:none; stroke:gray; stroke-width:1.0'>\n", | ||
527 | "<path d = 'M 92.273 277.015 96.772 108.390 101.272 6.475 105.771 -44.591 110.271 -58.019 114.770 -44.689 119.270 -13.449 123.770 28.619 128.269 75.953 132.769 124.297 137.268 170.498 141.768 212.329 146.267 248.336 150.767 277.694 155.266 300.082 159.766 315.578 164.265 324.561 168.765 327.634 173.264 325.547 177.764 319.145 182.264 309.311 186.763 296.934 191.263 282.868 195.762 267.912 200.262 252.787 204.761 238.125 209.261 224.460 213.760 212.222 218.260 201.737 222.759 193.228 227.259 186.824 231.758 182.561 236.258 180.396 240.758 180.214 245.257 181.837 249.757 185.041 254.256 189.561 258.756 195.107 263.255 201.373 267.755 208.048 272.254 214.828 276.754 221.419 281.253 227.554 285.753 232.993 290.253 237.531 294.752 241.006 299.252 243.296 303.751 244.329 308.251 244.075 312.750 242.556 317.250 239.835 321.749 236.021 326.249 231.260 330.748 225.734 335.248 219.654 339.747 213.254 344.247 206.785 348.747 200.506 353.246 194.677 357.746 189.553 362.245 185.374 366.745 182.357 371.244 180.689 375.744 180.519 380.243 181.953 384.743 185.046 389.242 189.798 393.742 196.149 398.242 203.976 402.741 213.095 407.241 223.253 411.740 234.137 416.240 245.374 420.739 256.537 425.239 267.148 429.738 276.695 434.238 284.634 438.737 290.410 443.237 293.466 447.736 293.268 452.236 289.317 456.736 281.178 461.235 268.503 465.735 251.055 470.234 228.741 474.734 201.640 479.233 170.040 483.733 134.469 488.232 95.733 492.732 54.957 497.231 13.618 501.731 -26.407 506.230 -62.807 510.730 -92.788 515.230 -113.039 519.729 -119.686 524.229 -108.253 528.728 -73.622 533.228 -9.996 537.727 89.136 ' />\n", | ||
528 | "\n", | ||
529 | "</g>\n", | ||
530 | "\n", | ||
531 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
532 | "\n", | ||
533 | "\n", | ||
534 | "</g>\n", | ||
535 | "\n", | ||
536 | "\n", | ||
537 | "\n", | ||
538 | "\n", | ||
539 | "</g>\n", | ||
540 | "\n", | ||
541 | "<g style='fill:none; stroke:black; stroke-width:1.5'>\n", | ||
542 | "<rect x='70.000' y='50.000' width='490.000' height='300.000' />\n", | ||
543 | "\n", | ||
544 | "</g>\n", | ||
545 | "\n", | ||
546 | "<g style='text-anchor:middle'>\n", | ||
547 | "<text x='144.961' y='366.000' style='font-size:12.0px'> 2 </text>\n", | ||
548 | "<text x='240.758' y='366.000' style='font-size:12.0px'> 4 </text>\n", | ||
549 | "<text x='336.554' y='366.000' style='font-size:12.0px'> 6 </text>\n", | ||
550 | "<text x='432.351' y='366.000' style='font-size:12.0px'> 8 </text>\n", | ||
551 | "<text x='528.148' y='366.000' style='font-size:12.0px'> 10 </text>\n", | ||
552 | "\n", | ||
553 | "<text x='315.000' y='382.000' style='font-size:12.0px'> </text>\n", | ||
554 | "\n", | ||
555 | "</g>\n", | ||
556 | "\n", | ||
557 | "<g style='text-anchor:end'>\n", | ||
558 | "<text x='62.000' y='320.304' style='font-size:12.0px'> -20 </text>\n", | ||
559 | "<text x='62.000' y='282.118' style='font-size:12.0px'> 0 </text>\n", | ||
560 | "<text x='62.000' y='243.932' style='font-size:12.0px'> 20 </text>\n", | ||
561 | "<text x='62.000' y='205.745' style='font-size:12.0px'> 40 </text>\n", | ||
562 | "<text x='62.000' y='167.559' style='font-size:12.0px'> 60 </text>\n", | ||
563 | "<text x='62.000' y='129.373' style='font-size:12.0px'> 80 </text>\n", | ||
564 | "<text x='62.000' y='91.186' style='font-size:12.0px'> 100 </text>\n", | ||
565 | "<text x='62.000' y='53.000' style='font-size:12.0px'> 120 </text>\n", | ||
566 | "\n", | ||
567 | "</g>\n", | ||
568 | "\n", | ||
569 | "<g style='text-anchor:middle'>\n", | ||
570 | "<g transform='matrix(1,0,0,1,30.0,199.99999999999997)'>\n", | ||
571 | "<g transform='rotate(-90.0)'>\n", | ||
572 | "<g transform='matrix(1,0,0,1,-30.0,-199.99999999999997)'>\n", | ||
573 | "<text x='30.000' y='200.000' style='font-size:12.0px'> </text>\n", | ||
574 | "\n", | ||
575 | "</g>\n", | ||
576 | "\n", | ||
577 | "\n", | ||
578 | "</g>\n", | ||
579 | "\n", | ||
580 | "\n", | ||
581 | "</g>\n", | ||
582 | "\n", | ||
583 | "\n", | ||
584 | "</g>\n", | ||
585 | "\n", | ||
586 | "\n", | ||
587 | "<g style='stroke:black; stroke-width:1'>\n", | ||
588 | "<path d = 'M 144.961 350.000 144.961 344.000 ' />\n", | ||
589 | "<path d = 'M 240.758 350.000 240.758 344.000 ' />\n", | ||
590 | "<path d = 'M 336.554 350.000 336.554 344.000 ' />\n", | ||
591 | "<path d = 'M 432.351 350.000 432.351 344.000 ' />\n", | ||
592 | "<path d = 'M 528.148 350.000 528.148 344.000 ' />\n", | ||
593 | "\n", | ||
594 | "<path d = 'M 70.000 317.304 79.800 317.304 ' />\n", | ||
595 | "<path d = 'M 70.000 279.118 79.800 279.118 ' />\n", | ||
596 | "<path d = 'M 70.000 240.932 79.800 240.932 ' />\n", | ||
597 | "<path d = 'M 70.000 202.745 79.800 202.745 ' />\n", | ||
598 | "<path d = 'M 70.000 164.559 79.800 164.559 ' />\n", | ||
599 | "<path d = 'M 70.000 126.373 79.800 126.373 ' />\n", | ||
600 | "<path d = 'M 70.000 88.186 79.800 88.186 ' />\n", | ||
601 | "<path d = 'M 70.000 50.000 79.800 50.000 ' />\n", | ||
602 | "\n", | ||
603 | "\n", | ||
604 | "</g>\n", | ||
605 | "\n", | ||
606 | "\n", | ||
607 | "\n", | ||
608 | "<g style='fill:#fcfcff;stroke:gray'>\n", | ||
609 | "<rect x='89.500' y='44.600' width='113.600' height='122.400' />\n", | ||
610 | "\n", | ||
611 | "</g>\n", | ||
612 | "\n", | ||
613 | "<defs> <clipPath id='clip995004460030800122400'>\n", | ||
614 | "<rect x='99.500' y='44.600' width='30.800' height='122.400' />\n", | ||
615 | "</clipPath> </defs>\n", | ||
616 | "<g clip-path='url(#clip995004460030800122400)'>\n", | ||
617 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
618 | "<path d = 'M 94.500 65.000 114.900 65.000 135.300 65.000 ' />\n", | ||
619 | "\n", | ||
620 | "</g>\n", | ||
621 | "\n", | ||
622 | "<g style='fill:red; stroke:none; stroke-width:1.0'>\n", | ||
623 | "<circle cx='94.500' cy='65.000' r='3.000' />\n", | ||
624 | "<circle cx='114.900' cy='65.000' r='3.000' />\n", | ||
625 | "<circle cx='135.300' cy='65.000' r='3.000' />\n", | ||
626 | "\n", | ||
627 | "\n", | ||
628 | "</g>\n", | ||
629 | "\n", | ||
630 | "\n", | ||
631 | "<g style='fill:none; stroke:blue; stroke-width:1.0'>\n", | ||
632 | "<path d = 'M 94.500 85.400 114.900 85.400 135.300 85.400 ' />\n", | ||
633 | "\n", | ||
634 | "</g>\n", | ||
635 | "\n", | ||
636 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
637 | "\n", | ||
638 | "\n", | ||
639 | "</g>\n", | ||
640 | "\n", | ||
641 | "\n", | ||
642 | "<g style='fill:none; stroke:green; stroke-width:1.0'>\n", | ||
643 | "<path d = 'M 94.500 105.800 114.900 105.800 135.300 105.800 ' />\n", | ||
644 | "\n", | ||
645 | "</g>\n", | ||
646 | "\n", | ||
647 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
648 | "\n", | ||
649 | "\n", | ||
650 | "</g>\n", | ||
651 | "\n", | ||
652 | "\n", | ||
653 | "<g style='fill:none; stroke:brown; stroke-width:1.0'>\n", | ||
654 | "<path d = 'M 94.500 126.200 114.900 126.200 135.300 126.200 ' />\n", | ||
655 | "\n", | ||
656 | "</g>\n", | ||
657 | "\n", | ||
658 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
659 | "\n", | ||
660 | "\n", | ||
661 | "</g>\n", | ||
662 | "\n", | ||
663 | "\n", | ||
664 | "<g style='fill:none; stroke:gray; stroke-width:1.0'>\n", | ||
665 | "<path d = 'M 94.500 146.600 114.900 146.600 135.300 146.600 ' />\n", | ||
666 | "\n", | ||
667 | "</g>\n", | ||
668 | "\n", | ||
669 | "<g style='fill:none; stroke:none; stroke-width:1.0'>\n", | ||
670 | "\n", | ||
671 | "\n", | ||
672 | "</g>\n", | ||
673 | "\n", | ||
674 | "\n", | ||
675 | "\n", | ||
676 | "</g>\n", | ||
677 | "\n", | ||
678 | "<text x='140.300' y='68.000' style='font-size:12.0px'> data </text>\n", | ||
679 | "<text x='140.300' y='88.400' style='font-size:12.0px'> degree 1 </text>\n", | ||
680 | "<text x='140.300' y='108.800' style='font-size:12.0px'> degree 2 </text>\n", | ||
681 | "<text x='140.300' y='129.200' style='font-size:12.0px'> degree 3 </text>\n", | ||
682 | "<text x='140.300' y='149.600' style='font-size:12.0px'> degree 9 </text>\n", | ||
683 | "\n", | ||
684 | "\n", | ||
685 | "\n", | ||
686 | "\n", | ||
687 | "</svg>\n", | ||
688 | "</div>" | ||
689 | ] | ||
690 | }, | ||
691 | "metadata": {}, | ||
692 | "output_type": "display_data" | ||
693 | } | ||
694 | ], | ||
695 | "source": [ | ||
696 | "lplot\n", | ||
697 | " [ plotMark x y \"none\" 1 circles \"red\" 3 \"data\"\n", | ||
698 | " , plot t (pol 1 t) \"blue\" 1 \"degree 1\"\n", | ||
699 | " , plot t (pol 2 t) \"green\" 1 \"degree 2\"\n", | ||
700 | " , plot t (pol 3 t) \"brown\" 1 \"degree 3\"\n", | ||
701 | " , plot t (pol 9 t) \"gray\" 1 \"degree 9\"\n", | ||
702 | " , MarginX 0.05, Title \"polynomial models\", LegendPos 0.05 0.95, MaxY 120\n", | ||
703 | " ] " | ||
704 | ] | ||
705 | } | ||
706 | ], | ||
707 | "metadata": { | ||
708 | "kernelspec": { | ||
709 | "display_name": "Haskell", | ||
710 | "language": "haskell", | ||
711 | "name": "haskell" | ||
712 | }, | ||
713 | "language_info": { | ||
714 | "codemirror_mode": "ihaskell", | ||
715 | "file_extension": ".hs", | ||
716 | "name": "haskell", | ||
717 | "version": "7.10.1" | ||
718 | } | ||
719 | }, | ||
720 | "nbformat": 4, | ||
721 | "nbformat_minor": 0 | ||
722 | } | ||