1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
|
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import Numeric.LinearAlgebra"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import IHaskell.Display"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
":ext FlexibleInstances\n",
"\n",
"dec = 3\n",
"\n",
"instance IHaskellDisplay (Matrix C) where\n",
" display m = return $ Display [html (\"<p>$$\"++(latexFormat \"bmatrix\" . dispcf dec) m++\"$$</p>\")]\n",
"\n",
"instance IHaskellDisplay (Matrix R) where\n",
" display m = return $ Display [html (\"<p>$$\"++ (latexFormat \"bmatrix\" . dispf dec) m++\"$$</p>\")]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import Graphics.SVG\n",
"data RawSVG = RawSVG String\n",
"instance IHaskellDisplay RawSVG where\n",
" display (RawSVG s) = return $ Display [html $ \"<div style=\\\"width:600px\\\">\"++ s ++ \"</div>\"]\n",
"\n",
"lplot = RawSVG . hPlot"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# least squares polynomial model"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"expand :: Int -> Vector R -> Matrix R\n",
"expand n x = fromColumns $ map (x^) [0 .. n]\n",
"\n",
"polynomialModel :: Vector R -> Vector R -> Int -> (Vector R -> Vector R)\n",
"polynomialModel x y n = f\n",
" where\n",
" f z = expand n z #> ws\n",
" ws = expand n x <\\> y"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"[x,y] <- toColumns <$> loadMatrix \"data.txt\""
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[0.9,2.1,3.1,4.0,4.9,6.1,7.0,7.9,9.1,10.2]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[1.1,3.9,9.2,51.8,25.3,35.7,49.4,3.6,81.5,99.5]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x\n",
"y"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<style>/*\n",
"Custom IHaskell CSS.\n",
"*/\n",
"\n",
"/* Styles used for the Hoogle display in the pager */\n",
".hoogle-doc {\n",
" display: block;\n",
" padding-bottom: 1.3em;\n",
" padding-left: 0.4em;\n",
"}\n",
".hoogle-code {\n",
" display: block;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
"}\n",
".hoogle-text {\n",
" display: block;\n",
"}\n",
".hoogle-name {\n",
" color: green;\n",
" font-weight: bold;\n",
"}\n",
".hoogle-head {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-sub {\n",
" display: block;\n",
" margin-left: 0.4em;\n",
"}\n",
".hoogle-package {\n",
" font-weight: bold;\n",
" font-style: italic;\n",
"}\n",
".hoogle-module {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-class {\n",
" font-weight: bold;\n",
"}\n",
"\n",
"/* Styles used for basic displays */\n",
".get-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" display: block;\n",
" white-space: pre-wrap;\n",
"}\n",
"\n",
".show-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
".mono {\n",
" font-family: monospace;\n",
" display: block;\n",
"}\n",
"\n",
".err-msg {\n",
" color: red;\n",
" font-style: italic;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
" display: block;\n",
"}\n",
"\n",
"#unshowable {\n",
" color: red;\n",
" font-weight: bold;\n",
"}\n",
"\n",
".err-msg.in.collapse {\n",
" padding-top: 0.7em;\n",
"}\n",
"\n",
"/* Code that will get highlighted before it is highlighted */\n",
".highlight-code {\n",
" white-space: pre;\n",
" font-family: monospace;\n",
"}\n",
"\n",
"/* Hlint styles */\n",
".suggestion-warning { \n",
" font-weight: bold;\n",
" color: rgb(200, 130, 0);\n",
"}\n",
".suggestion-error { \n",
" font-weight: bold;\n",
" color: red;\n",
"}\n",
".suggestion-name {\n",
" font-weight: bold;\n",
"}\n",
"</style><p>$$\\begin{bmatrix}\n",
"1.000 & 0.900 & 0.810\n",
"\\\\\n",
"1.000 & 2.100 & 4.410\n",
"\\\\\n",
"1.000 & 3.100 & 9.610\n",
"\\\\\n",
"1.000 & 4.000 & 16.000\n",
"\\\\\n",
"1.000 & 4.900 & 24.010\n",
"\\\\\n",
"1.000 & 6.100 & 37.210\n",
"\\\\\n",
"1.000 & 7.000 & 49.000\n",
"\\\\\n",
"1.000 & 7.900 & 62.410\n",
"\\\\\n",
"1.000 & 9.100 & 82.810\n",
"\\\\\n",
"1.000 & 10.200 & 104.040\n",
"\\end{bmatrix}$$</p>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"expand 2 x"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"pol = polynomialModel x y\n",
"view = [x, y, pol 1 x, pol 2 x, pol 3 x]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
" x y p 1 p 2 p 3"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
" 0.90 1.10 -3.41 7.70 -6.99\n",
" 2.10 3.90 6.83 9.80 15.97\n",
" 3.10 9.20 15.36 13.39 25.09\n",
" 4.00 51.80 23.04 18.05 28.22\n",
" 4.90 25.30 30.72 24.05 28.86\n",
" 6.10 35.70 40.96 34.16 29.68\n",
" 7.00 49.40 48.64 43.31 33.17\n",
" 7.90 3.60 56.32 53.82 41.60\n",
" 9.10 81.50 66.57 69.92 64.39\n",
"10.20 99.50 75.95 86.80 101.01"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import Text.Printf\n",
"\n",
"putStrLn \" x y p 1 p 2 p 3\"\n",
"putStrLn $ format \" \" (printf \"%.2f\") $ fromColumns view"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"t = linspace 100 (minElement x, maxElement x)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<style>/*\n",
"Custom IHaskell CSS.\n",
"*/\n",
"\n",
"/* Styles used for the Hoogle display in the pager */\n",
".hoogle-doc {\n",
" display: block;\n",
" padding-bottom: 1.3em;\n",
" padding-left: 0.4em;\n",
"}\n",
".hoogle-code {\n",
" display: block;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
"}\n",
".hoogle-text {\n",
" display: block;\n",
"}\n",
".hoogle-name {\n",
" color: green;\n",
" font-weight: bold;\n",
"}\n",
".hoogle-head {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-sub {\n",
" display: block;\n",
" margin-left: 0.4em;\n",
"}\n",
".hoogle-package {\n",
" font-weight: bold;\n",
" font-style: italic;\n",
"}\n",
".hoogle-module {\n",
" font-weight: bold;\n",
"}\n",
".hoogle-class {\n",
" font-weight: bold;\n",
"}\n",
"\n",
"/* Styles used for basic displays */\n",
".get-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" display: block;\n",
" white-space: pre-wrap;\n",
"}\n",
"\n",
".show-type {\n",
" color: green;\n",
" font-weight: bold;\n",
" font-family: monospace;\n",
" margin-left: 1em;\n",
"}\n",
"\n",
".mono {\n",
" font-family: monospace;\n",
" display: block;\n",
"}\n",
"\n",
".err-msg {\n",
" color: red;\n",
" font-style: italic;\n",
" font-family: monospace;\n",
" white-space: pre;\n",
" display: block;\n",
"}\n",
"\n",
"#unshowable {\n",
" color: red;\n",
" font-weight: bold;\n",
"}\n",
"\n",
".err-msg.in.collapse {\n",
" padding-top: 0.7em;\n",
"}\n",
"\n",
"/* Code that will get highlighted before it is highlighted */\n",
".highlight-code {\n",
" white-space: pre;\n",
" font-family: monospace;\n",
"}\n",
"\n",
"/* Hlint styles */\n",
".suggestion-warning { \n",
" font-weight: bold;\n",
" color: rgb(200, 130, 0);\n",
"}\n",
".suggestion-error { \n",
" font-weight: bold;\n",
" color: red;\n",
"}\n",
".suggestion-name {\n",
" font-weight: bold;\n",
"}\n",
"</style><div style=\"width:600px\"><?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='0 0 600 400' >\n",
"\n",
"<g style='text-anchor:middle'>\n",
"<text x='300.000' y='30.000' style='font-size:14.0px'> polynomial models </text>\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:white; stroke:none; stroke-width:1.0'>\n",
"<rect x='70.000' y='50.000' width='490.000' height='300.000' />\n",
"\n",
"</g>\n",
"\n",
"<g style='stroke:black;stroke-width:0.1;stroke-dasharray:2'>\n",
"<path d = 'M 144.961 350.000 144.961 50.000 ' />\n",
"<path d = 'M 240.758 350.000 240.758 50.000 ' />\n",
"<path d = 'M 336.554 350.000 336.554 50.000 ' />\n",
"<path d = 'M 432.351 350.000 432.351 50.000 ' />\n",
"<path d = 'M 528.148 350.000 528.148 50.000 ' />\n",
"\n",
"<path d = 'M 70.000 317.304 560.000 317.304 ' />\n",
"<path d = 'M 70.000 279.118 560.000 279.118 ' />\n",
"<path d = 'M 70.000 240.932 560.000 240.932 ' />\n",
"<path d = 'M 70.000 202.745 560.000 202.745 ' />\n",
"<path d = 'M 70.000 164.559 560.000 164.559 ' />\n",
"<path d = 'M 70.000 126.373 560.000 126.373 ' />\n",
"<path d = 'M 70.000 88.186 560.000 88.186 ' />\n",
"<path d = 'M 70.000 50.000 560.000 50.000 ' />\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<defs> <clipPath id='clip7000050000490000300000'>\n",
"<rect x='70.000' y='50.000' width='490.000' height='300.000' />\n",
"</clipPath> </defs>\n",
"<g clip-path='url(#clip7000050000490000300000)'>\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"<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",
"\n",
"</g>\n",
"\n",
"<g style='fill:red; stroke:none; stroke-width:1.0'>\n",
"<circle cx='92.273' cy='277.018' r='3.000' />\n",
"<circle cx='149.751' cy='271.672' r='3.000' />\n",
"<circle cx='197.649' cy='261.552' r='3.000' />\n",
"<circle cx='240.758' cy='180.215' r='3.000' />\n",
"<circle cx='283.866' cy='230.812' r='3.000' />\n",
"<circle cx='341.344' cy='210.955' r='3.000' />\n",
"<circle cx='384.453' cy='184.798' r='3.000' />\n",
"<circle cx='427.561' cy='272.244' r='3.000' />\n",
"<circle cx='485.039' cy='123.509' r='3.000' />\n",
"<circle cx='537.727' cy='89.141' r='3.000' />\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:blue; stroke-width:1.0'>\n",
"<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",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:green; stroke-width:1.0'>\n",
"<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",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:brown; stroke-width:1.0'>\n",
"<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",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:gray; stroke-width:1.0'>\n",
"<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",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:black; stroke-width:1.5'>\n",
"<rect x='70.000' y='50.000' width='490.000' height='300.000' />\n",
"\n",
"</g>\n",
"\n",
"<g style='text-anchor:middle'>\n",
"<text x='144.961' y='366.000' style='font-size:12.0px'> 2 </text>\n",
"<text x='240.758' y='366.000' style='font-size:12.0px'> 4 </text>\n",
"<text x='336.554' y='366.000' style='font-size:12.0px'> 6 </text>\n",
"<text x='432.351' y='366.000' style='font-size:12.0px'> 8 </text>\n",
"<text x='528.148' y='366.000' style='font-size:12.0px'> 10 </text>\n",
"\n",
"<text x='315.000' y='382.000' style='font-size:12.0px'> </text>\n",
"\n",
"</g>\n",
"\n",
"<g style='text-anchor:end'>\n",
"<text x='62.000' y='320.304' style='font-size:12.0px'> -20 </text>\n",
"<text x='62.000' y='282.118' style='font-size:12.0px'> 0 </text>\n",
"<text x='62.000' y='243.932' style='font-size:12.0px'> 20 </text>\n",
"<text x='62.000' y='205.745' style='font-size:12.0px'> 40 </text>\n",
"<text x='62.000' y='167.559' style='font-size:12.0px'> 60 </text>\n",
"<text x='62.000' y='129.373' style='font-size:12.0px'> 80 </text>\n",
"<text x='62.000' y='91.186' style='font-size:12.0px'> 100 </text>\n",
"<text x='62.000' y='53.000' style='font-size:12.0px'> 120 </text>\n",
"\n",
"</g>\n",
"\n",
"<g style='text-anchor:middle'>\n",
"<g transform='matrix(1,0,0,1,30.0,199.99999999999997)'>\n",
"<g transform='rotate(-90.0)'>\n",
"<g transform='matrix(1,0,0,1,-30.0,-199.99999999999997)'>\n",
"<text x='30.000' y='200.000' style='font-size:12.0px'> </text>\n",
"\n",
"</g>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='stroke:black; stroke-width:1'>\n",
"<path d = 'M 144.961 350.000 144.961 344.000 ' />\n",
"<path d = 'M 240.758 350.000 240.758 344.000 ' />\n",
"<path d = 'M 336.554 350.000 336.554 344.000 ' />\n",
"<path d = 'M 432.351 350.000 432.351 344.000 ' />\n",
"<path d = 'M 528.148 350.000 528.148 344.000 ' />\n",
"\n",
"<path d = 'M 70.000 317.304 79.800 317.304 ' />\n",
"<path d = 'M 70.000 279.118 79.800 279.118 ' />\n",
"<path d = 'M 70.000 240.932 79.800 240.932 ' />\n",
"<path d = 'M 70.000 202.745 79.800 202.745 ' />\n",
"<path d = 'M 70.000 164.559 79.800 164.559 ' />\n",
"<path d = 'M 70.000 126.373 79.800 126.373 ' />\n",
"<path d = 'M 70.000 88.186 79.800 88.186 ' />\n",
"<path d = 'M 70.000 50.000 79.800 50.000 ' />\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"\n",
"<g style='fill:#fcfcff;stroke:gray'>\n",
"<rect x='89.500' y='44.600' width='113.600' height='122.400' />\n",
"\n",
"</g>\n",
"\n",
"<defs> <clipPath id='clip995004460030800122400'>\n",
"<rect x='99.500' y='44.600' width='30.800' height='122.400' />\n",
"</clipPath> </defs>\n",
"<g clip-path='url(#clip995004460030800122400)'>\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"<path d = 'M 94.500 65.000 114.900 65.000 135.300 65.000 ' />\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:red; stroke:none; stroke-width:1.0'>\n",
"<circle cx='94.500' cy='65.000' r='3.000' />\n",
"<circle cx='114.900' cy='65.000' r='3.000' />\n",
"<circle cx='135.300' cy='65.000' r='3.000' />\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:blue; stroke-width:1.0'>\n",
"<path d = 'M 94.500 85.400 114.900 85.400 135.300 85.400 ' />\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:green; stroke-width:1.0'>\n",
"<path d = 'M 94.500 105.800 114.900 105.800 135.300 105.800 ' />\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:brown; stroke-width:1.0'>\n",
"<path d = 'M 94.500 126.200 114.900 126.200 135.300 126.200 ' />\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"<g style='fill:none; stroke:gray; stroke-width:1.0'>\n",
"<path d = 'M 94.500 146.600 114.900 146.600 135.300 146.600 ' />\n",
"\n",
"</g>\n",
"\n",
"<g style='fill:none; stroke:none; stroke-width:1.0'>\n",
"\n",
"\n",
"</g>\n",
"\n",
"\n",
"\n",
"</g>\n",
"\n",
"<text x='140.300' y='68.000' style='font-size:12.0px'> data </text>\n",
"<text x='140.300' y='88.400' style='font-size:12.0px'> degree 1 </text>\n",
"<text x='140.300' y='108.800' style='font-size:12.0px'> degree 2 </text>\n",
"<text x='140.300' y='129.200' style='font-size:12.0px'> degree 3 </text>\n",
"<text x='140.300' y='149.600' style='font-size:12.0px'> degree 9 </text>\n",
"\n",
"\n",
"\n",
"\n",
"</svg>\n",
"</div>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"lplot\n",
" [ plotMark x y \"none\" 1 circles \"red\" 3 \"data\"\n",
" , plot t (pol 1 t) \"blue\" 1 \"degree 1\"\n",
" , plot t (pol 2 t) \"green\" 1 \"degree 2\"\n",
" , plot t (pol 3 t) \"brown\" 1 \"degree 3\"\n",
" , plot t (pol 9 t) \"gray\" 1 \"degree 9\"\n",
" , MarginX 0.05, Title \"polynomial models\", LegendPos 0.05 0.95, MaxY 120\n",
" ] "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
|