Michi

Michi commited on 2012-06-03 16:52:14
Zeige 15 geänderte Dateien mit 1731 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,51 @@
1
+read.table("M100_spec.txt",header=TRUE)
2
+spec = read.table("M100_spec.txt",header=TRUE)
3
+
4
+spec.fit <- lm(spec[175:746,2] ~ [175:746,1])
5
+spec.fit <- lm(spec[175:746,2] ~ spec[175:746,1])
6
+summary(spec.fit)
7
+abline(spec.fit)
8
+plot(spec[:,1],spec[:,2])
9
+plot(spec[,1],spec[,2])
10
+abline(spec.fit)
11
+plot(spec[,1],spec[,2],type=l)
12
+plot(spec[,1],spec[,2],l)
13
+plot(spec[,1],spec[,2],'l')
14
+abline(spec.fit)
15
+x <- array(1:20, dim=c(4,5))
16
+x
17
+spec[:5,1]
18
+spec[1:5,1]
19
+spec[1:5,]
20
+spec[2:5,]
21
+spec
22
+spec = read.table("M100_spec.txt",header=FALSE)
23
+spec[1:3,]
24
+spec.boolmask = 21 > spec[,2] >17
25
+spec.boolmask =  (spec[,2] >17) 
26
+spec.boolmask =  (spec[,2] >17) & (spec[,2] <20)
27
+spec.boolmask
28
+spec.fit <- lm(spec[spec.boolmask,2] ~ [spec.boolmask,1])
29
+spec.boolmask
30
+spec.fit <- lm(spec[spec.boolmask,2] ~ spec[spec.boolmask,1])
31
+abline(spec.fit)
32
+summery(spec.fit)
33
+summary(spec.fit)
34
+coef(spec.fit)[1]
35
+spec.zero = spec - coef(spec.fit)[1]
36
+spec.zero = spec
37
+spec.zero[,2] = spec[,2] - coef(spec.fit)[1]
38
+plot(spec[,1],spec.zero[,2],'l')
39
+plot(spec[,1],spec.zero[,2],'l')
40
+spec.zero = spec - coef(spec.fit)[1]
41
+spec.zero
42
+spec.notNull = (spec != 0)
43
+spec.notNull
44
+spec.notNull = (spec[,2] != 0)
45
+spec.notNull
46
+ls
47
+plot(spec[spec.notNull,1],spec.zero[notNull,2],'l')
48
+plot(spec[spec.notNull,1],spec.zero[spec.notNull,2],'l')
49
+save()
50
+save(fiel="flux2zero.R")
51
+q()
... ...
@@ -0,0 +1,1202 @@
1
+# lambda Flux ((10^{-17} erg s^{-1}"+aaangs+"^{-1} cm^{-2}))
2
+       6248.6000      0.00000
3
+       6249.1540      0.00000
4
+       6249.7080      0.00000
5
+       6250.2620      0.00000
6
+       6250.8160      0.00000
7
+       6251.3700      0.00000
8
+       6251.9240      0.00000
9
+       6252.4780      0.00000
10
+       6253.0320      0.00000
11
+       6253.5860      0.00000
12
+       6254.1400      0.00000
13
+       6254.6940      0.00000
14
+       6255.2480      0.00000
15
+       6255.8020      0.00000
16
+       6256.3560      0.00000
17
+       6256.9100      0.00000
18
+       6257.4640      0.00000
19
+       6258.0180      0.00000
20
+       6258.5720      0.00000
21
+       6259.1260      0.00000
22
+       6259.6800      0.00000
23
+       6260.2340      0.00000
24
+       6260.7880      0.00000
25
+       6261.3420      0.00000
26
+       6261.8960      0.00000
27
+       6262.4500      0.00000
28
+       6263.0040      0.00000
29
+       6263.5580      0.00000
30
+       6264.1120      0.00000
31
+       6264.6660      0.00000
32
+       6265.2200      0.00000
33
+       6265.7740      0.00000
34
+       6266.3280      0.00000
35
+       6266.8820      0.00000
36
+       6267.4360      0.00000
37
+       6267.9900      0.00000
38
+       6268.5440      0.00000
39
+       6269.0980      0.00000
40
+       6269.6520      0.00000
41
+       6270.2060      0.00000
42
+       6270.7600      0.00000
43
+       6271.3140      0.00000
44
+       6271.8680      0.00000
45
+       6272.4220      0.00000
46
+       6272.9760      0.00000
47
+       6273.5300      0.00000
48
+       6274.0840      0.00000
49
+       6274.6380      0.00000
50
+       6275.1920      0.00000
51
+       6275.7460      0.00000
52
+       6276.3000      0.00000
53
+       6276.8540      0.00000
54
+       6277.4080      0.00000
55
+       6277.9620      0.00000
56
+       6278.5160      0.00000
57
+       6279.0700      0.00000
58
+       6279.6240      0.00000
59
+       6280.1780      0.00000
60
+       6280.7320      0.00000
61
+       6281.2860      0.00000
62
+       6281.8400      0.00000
63
+       6282.3940      0.00000
64
+       6282.9480      0.00000
65
+       6283.5020      0.00000
66
+       6284.0560      0.00000
67
+       6284.6100      0.00000
68
+       6285.1640      0.00000
69
+       6285.7180      0.00000
70
+       6286.2720      0.00000
71
+       6286.8260      0.00000
72
+       6287.3800      0.00000
73
+       6287.9340      0.00000
74
+       6288.4880      0.00000
75
+       6289.0420      0.00000
76
+       6289.5960      0.00000
77
+       6290.1500      0.00000
78
+       6290.7040      0.00000
79
+       6291.2580      0.00000
80
+       6291.8120      0.00000
81
+       6292.3660      0.00000
82
+       6292.9200      0.00000
83
+       6293.4740      0.00000
84
+       6294.0280      0.00000
85
+       6294.5820      0.00000
86
+       6295.1360      0.00000
87
+       6295.6900      0.00000
88
+       6296.2440      0.00000
89
+       6296.7980      28.1966
90
+       6297.3520      16.9010
91
+       6297.9060      18.9971
92
+       6298.4600      20.8780
93
+       6299.0140      18.5692
94
+       6299.5680      19.7306
95
+       6300.1220      18.9521
96
+       6300.6760      19.8322
97
+       6301.2300      19.6677
98
+       6301.7840      18.0532
99
+       6302.3380      19.3939
100
+       6302.8920      18.4899
101
+       6303.4460      20.9124
102
+       6304.0000      19.2130
103
+       6304.5540      22.4971
104
+       6305.1080      19.4275
105
+       6305.6620      18.5390
106
+       6306.2160      18.4152
107
+       6306.7700      18.6887
108
+       6307.3240      19.3154
109
+       6307.8780      20.1014
110
+       6308.4320      20.6188
111
+       6308.9860      18.6696
112
+       6309.5400      18.8784
113
+       6310.0940      17.0876
114
+       6310.6480      19.5688
115
+       6311.2020      19.2849
116
+       6311.7560      19.1638
117
+       6312.3100      18.7903
118
+       6312.8640      19.1984
119
+       6313.4180      19.3322
120
+       6313.9720      19.3685
121
+       6314.5260      17.8240
122
+       6315.0800      17.4342
123
+       6315.6340      18.4613
124
+       6316.1880      19.7234
125
+       6316.7420      20.0285
126
+       6317.2960      17.1575
127
+       6317.8500      17.4727
128
+       6318.4040      18.2427
129
+       6318.9580      19.3886
130
+       6319.5120      19.4544
131
+       6320.0660      20.2449
132
+       6320.6200      19.5405
133
+       6321.1740      20.5919
134
+       6321.7280      19.9698
135
+       6322.2820      20.8797
136
+       6322.8360      22.5275
137
+       6323.3900      20.9754
138
+       6323.9440      20.4816
139
+       6324.4980      20.4083
140
+       6325.0520      20.9788
141
+       6325.6060      19.2594
142
+       6326.1600      18.1152
143
+       6326.7140      20.7610
144
+       6327.2680      19.0925
145
+       6327.8220      19.5991
146
+       6328.3760      18.9765
147
+       6328.9300      19.7201
148
+       6329.4840      19.8251
149
+       6330.0380      20.7413
150
+       6330.5920      21.6081
151
+       6331.1460      21.5628
152
+       6331.7000      21.3715
153
+       6332.2540      23.3972
154
+       6332.8080      22.8690
155
+       6333.3620      25.8322
156
+       6333.9160      25.0590
157
+       6334.4700      25.7084
158
+       6335.0240      25.9620
159
+       6335.5780      24.7512
160
+       6336.1320      24.9528
161
+       6336.6860      23.9990
162
+       6337.2400      21.8191
163
+       6337.7940      21.0391
164
+       6338.3480      21.7726
165
+       6338.9020      21.5823
166
+       6339.4560      20.4367
167
+       6340.0100      21.0235
168
+       6340.5640      20.4038
169
+       6341.1180      20.1036
170
+       6341.6720      18.9850
171
+       6342.2260      20.0438
172
+       6342.7800      20.9713
173
+       6343.3340      20.8324
174
+       6343.8880      19.9256
175
+       6344.4420      19.7780
176
+       6344.9960      20.3833
177
+       6345.5500      19.9043
178
+       6346.1040      20.2789
179
+       6346.6580      19.7787
180
+       6347.2120      20.6096
181
+       6347.7660      20.9657
182
+       6348.3200      19.9545
183
+       6348.8740      19.5408
184
+       6349.4280      21.0450
185
+       6349.9820      20.3079
186
+       6350.5360      19.2938
187
+       6351.0900      19.9137
188
+       6351.6440      20.2691
189
+       6352.1980      20.4626
190
+       6352.7520      19.5967
191
+       6353.3060      19.0879
192
+       6353.8600      18.7181
193
+       6354.4140      18.6576
194
+       6354.9680      18.1687
195
+       6355.5220      17.9342
196
+       6356.0760      19.3493
197
+       6356.6300      19.2049
198
+       6357.1840      20.0517
199
+       6357.7380      20.6566
200
+       6358.2920      20.0795
201
+       6358.8460      19.6292
202
+       6359.4000      20.6407
203
+       6359.9540      21.4774
204
+       6360.5080      21.0786
205
+       6361.0620      20.3557
206
+       6361.6160      20.4000
207
+       6362.1700      20.9715
208
+       6362.7240      21.6996
209
+       6363.2780      23.0209
210
+       6363.8320      23.7886
211
+       6364.3860      22.2981
212
+       6364.9400      20.7709
213
+       6365.4940      20.9334
214
+       6366.0480      21.1331
215
+       6366.6020      20.2686
216
+       6367.1560      20.0964
217
+       6367.7100      20.1502
218
+       6368.2640      20.4474
219
+       6368.8180      21.3246
220
+       6369.3720      20.4840
221
+       6369.9260      19.6883
222
+       6370.4800      19.9162
223
+       6371.0340      19.1407
224
+       6371.5880      18.6808
225
+       6372.1420      18.9308
226
+       6372.6960      18.7782
227
+       6373.2500      20.4495
228
+       6373.8040      20.6244
229
+       6374.3580      21.1210
230
+       6374.9120      21.5160
231
+       6375.4660      19.7167
232
+       6376.0200      20.1573
233
+       6376.5740      19.9482
234
+       6377.1280      18.9084
235
+       6377.6820      19.4178
236
+       6378.2360      20.3309
237
+       6378.7900      19.4465
238
+       6379.3440      19.1042
239
+       6379.8980      20.3540
240
+       6380.4520      19.9988
241
+       6381.0060      20.3102
242
+       6381.5600      21.5019
243
+       6382.1140      21.4907
244
+       6382.6680      21.4798
245
+       6383.2220      20.3653
246
+       6383.7760      21.0955
247
+       6384.3300      19.7839
248
+       6384.8840      19.5822
249
+       6385.4380      20.5195
250
+       6385.9920      20.3335
251
+       6386.5460      20.6013
252
+       6387.1000      20.9891
253
+       6387.6540      21.0284
254
+       6388.2080      20.8663
255
+       6388.7620      20.9138
256
+       6389.3160      21.0911
257
+       6389.8700      21.4152
258
+       6390.4240      20.2149
259
+       6390.9780      19.0383
260
+       6391.5320      19.9420
261
+       6392.0860      19.2547
262
+       6392.6400      18.6413
263
+       6393.1940      19.2761
264
+       6393.7480      20.7316
265
+       6394.3020      21.1625
266
+       6394.8560      19.1657
267
+       6395.4100      19.0795
268
+       6395.9640      19.7464
269
+       6396.5180      18.5395
270
+       6397.0720      21.2910
271
+       6397.6260      21.5000
272
+       6398.1800      20.5851
273
+       6398.7340      20.1652
274
+       6399.2880      20.8072
275
+       6399.8420      19.9666
276
+       6400.3960      19.4763
277
+       6400.9500      19.9386
278
+       6401.5040      19.5952
279
+       6402.0580      19.8548
280
+       6402.6120      20.2395
281
+       6403.1660      20.3432
282
+       6403.7200      20.0623
283
+       6404.2740      19.1232
284
+       6404.8280      20.6660
285
+       6405.3820      21.2264
286
+       6405.9360      19.9968
287
+       6406.4900      21.7730
288
+       6407.0440      20.9638
289
+       6407.5980      19.5268
290
+       6408.1520      22.6426
291
+       6408.7060      21.2944
292
+       6409.2600      21.2414
293
+       6409.8140      22.6271
294
+       6410.3680      21.1302
295
+       6410.9220      20.0924
296
+       6411.4760      20.0184
297
+       6412.0300      19.3069
298
+       6412.5840      19.8463
299
+       6413.1380      18.3898
300
+       6413.6920      20.5393
301
+       6414.2460      21.5158
302
+       6414.8000      20.7910
303
+       6415.3540      19.0696
304
+       6415.9080      20.7009
305
+       6416.4620      20.6294
306
+       6417.0160      19.7967
307
+       6417.5700      21.6159
308
+       6418.1240      21.2850
309
+       6418.6780      20.8644
310
+       6419.2320      19.3014
311
+       6419.7860      19.1776
312
+       6420.3400      21.0048
313
+       6420.8940      19.5610
314
+       6421.4480      20.2111
315
+       6422.0020      19.7493
316
+       6422.5560      20.6237
317
+       6423.1100      20.6793
318
+       6423.6640      19.7174
319
+       6424.2180      21.7265
320
+       6424.7720      20.8540
321
+       6425.3260      19.8743
322
+       6425.8800      19.6253
323
+       6426.4340      21.6716
324
+       6426.9880      19.2786
325
+       6427.5420      22.5170
326
+       6428.0960      20.6717
327
+       6428.6500      19.7288
328
+       6429.2040      20.9789
329
+       6429.7580      20.2257
330
+       6430.3120      17.7914
331
+       6430.8660      17.9932
332
+       6431.4200      18.3601
333
+       6431.9740      20.6140
334
+       6432.5280      20.6605
335
+       6433.0820      19.7340
336
+       6433.6360      19.6376
337
+       6434.1900      20.8994
338
+       6434.7440      17.5517
339
+       6435.2980      17.9134
340
+       6435.8520      21.1444
341
+       6436.4060      18.5837
342
+       6436.9600      20.8869
343
+       6437.5140      20.1269
344
+       6438.0680      21.1678
345
+       6438.6220      20.4201
346
+       6439.1760      19.1197
347
+       6439.7300      19.1932
348
+       6440.2840      19.9368
349
+       6440.8380      20.1973
350
+       6441.3920      21.2910
351
+       6441.9460      19.6138
352
+       6442.5000      20.1451
353
+       6443.0540      19.7426
354
+       6443.6080      19.9238
355
+       6444.1620      20.4573
356
+       6444.7160      19.7036
357
+       6445.2700      18.5351
358
+       6445.8240      19.7359
359
+       6446.3780      19.8491
360
+       6446.9320      20.7861
361
+       6447.4860      22.0220
362
+       6448.0400      19.3191
363
+       6448.5940      19.4570
364
+       6449.1480      19.4546
365
+       6449.7020      18.7902
366
+       6450.2560      19.0337
367
+       6450.8100      19.7706
368
+       6451.3640      20.4381
369
+       6451.9180      20.5747
370
+       6452.4720      19.0581
371
+       6453.0260      19.5739
372
+       6453.5800      20.1833
373
+       6454.1340      18.5490
374
+       6454.6880      19.9595
375
+       6455.2420      20.5207
376
+       6455.7960      19.3244
377
+       6456.3500      18.6483
378
+       6456.9040      19.7354
379
+       6457.4580      19.4414
380
+       6458.0120      19.6636
381
+       6458.5660      18.1859
382
+       6459.1200      18.8838
383
+       6459.6740      18.7148
384
+       6460.2280      19.4150
385
+       6460.7820      19.4203
386
+       6461.3360      20.7793
387
+       6461.8900      21.0711
388
+       6462.4440      19.2714
389
+       6462.9980      20.3183
390
+       6463.5520      20.1991
391
+       6464.1060      19.2642
392
+       6464.6600      19.5939
393
+       6465.2140      20.5366
394
+       6465.7680      19.9005
395
+       6466.3220      19.7264
396
+       6466.8760      19.5644
397
+       6467.4300      19.6285
398
+       6467.9840      19.7406
399
+       6468.5380      18.9328
400
+       6469.0920      20.1133
401
+       6469.6460      20.0485
402
+       6470.2000      19.1371
403
+       6470.7540      18.9930
404
+       6471.3080      19.5754
405
+       6471.8620      19.3754
406
+       6472.4160      19.2887
407
+       6472.9700      19.8068
408
+       6473.5240      19.2577
409
+       6474.0780      18.5806
410
+       6474.6320      19.8234
411
+       6475.1860      20.2020
412
+       6475.7400      19.6858
413
+       6476.2940      19.2899
414
+       6476.8480      20.2259
415
+       6477.4020      20.2585
416
+       6477.9560      20.8226
417
+       6478.5100      18.8833
418
+       6479.0640      16.9565
419
+       6479.6180      17.4281
420
+       6480.1720      18.7420
421
+       6480.7260      20.4770
422
+       6481.2800      20.6345
423
+       6481.8340      19.8184
424
+       6482.3880      20.5903
425
+       6482.9420      20.7109
426
+       6483.4960      20.3396
427
+       6484.0500      19.7796
428
+       6484.6040      19.0464
429
+       6485.1580      18.4396
430
+       6485.7120      17.3707
431
+       6486.2660      17.4104
432
+       6486.8200      18.5430
433
+       6487.3740      20.3525
434
+       6487.9280      19.9713
435
+       6488.4820      18.5401
436
+       6489.0360      18.6629
437
+       6489.5900      20.0296
438
+       6490.1440      19.1001
439
+       6490.6980      18.0039
440
+       6491.2520      20.3629
441
+       6491.8060      20.7241
442
+       6492.3600      19.3060
443
+       6492.9140      19.1011
444
+       6493.4680      19.1001
445
+       6494.0220      19.9910
446
+       6494.5760      20.8003
447
+       6495.1300      20.5146
448
+       6495.6840      19.3671
449
+       6496.2380      19.3087
450
+       6496.7920      19.5976
451
+       6497.3460      17.1439
452
+       6497.9000      16.6859
453
+       6498.4540      18.3108
454
+       6499.0080      19.7231
455
+       6499.5620      19.8253
456
+       6500.1160      20.4994
457
+       6500.6700      20.6713
458
+       6501.2240      20.4268
459
+       6501.7780      20.1723
460
+       6502.3320      20.2873
461
+       6502.8860      21.0014
462
+       6503.4400      21.9179
463
+       6503.9940      20.7388
464
+       6504.5480      19.5961
465
+       6505.1020      21.8973
466
+       6505.6560      21.4722
467
+       6506.2100      20.4203
468
+       6506.7640      21.1310
469
+       6507.3180      20.0532
470
+       6507.8720      19.5319
471
+       6508.4260      20.0422
472
+       6508.9800      20.1316
473
+       6509.5340      20.4387
474
+       6510.0880      21.0395
475
+       6510.6420      20.5248
476
+       6511.1960      21.4537
477
+       6511.7500      20.2382
478
+       6512.3040      19.9861
479
+       6512.8580      20.4104
480
+       6513.4120      21.1839
481
+       6513.9660      21.2309
482
+       6514.5200      20.5409
483
+       6515.0740      20.5971
484
+       6515.6280      20.5917
485
+       6516.1820      19.9272
486
+       6516.7360      19.3515
487
+       6517.2900      21.8094
488
+       6517.8440      20.3250
489
+       6518.3980      19.4079
490
+       6518.9520      20.2948
491
+       6519.5060      21.8275
492
+       6520.0600      20.6900
493
+       6520.6140      20.3956
494
+       6521.1680      21.4746
495
+       6521.7220      19.8163
496
+       6522.2760      19.7471
497
+       6522.8300      21.0215
498
+       6523.3840      20.0798
499
+       6523.9380      19.8207
500
+       6524.4920      21.2896
501
+       6525.0460      19.3720
502
+       6525.6000      20.8146
503
+       6526.1540      19.2791
504
+       6526.7080      20.4548
505
+       6527.2620      18.4258
506
+       6527.8160      18.3268
507
+       6528.3700      19.3503
508
+       6528.9240      21.0856
509
+       6529.4780      18.1434
510
+       6530.0320      18.5880
511
+       6530.5860      18.0368
512
+       6531.1400      16.8475
513
+       6531.6940      18.1456
514
+       6532.2480      18.1349
515
+       6532.8020      18.5337
516
+       6533.3560      17.6984
517
+       6533.9100      18.6612
518
+       6534.4640      19.1887
519
+       6535.0180      19.8609
520
+       6535.5720      19.2619
521
+       6536.1260      18.4209
522
+       6536.6800      17.6579
523
+       6537.2340      19.9940
524
+       6537.7880      17.7102
525
+       6538.3420      19.7276
526
+       6538.8960      18.6907
527
+       6539.4500      19.2168
528
+       6540.0040      21.4948
529
+       6540.5580      21.0503
530
+       6541.1120      18.6240
531
+       6541.6660      21.5506
532
+       6542.2200      19.1411
533
+       6542.7740      20.3340
534
+       6543.3280      19.0112
535
+       6543.8820      20.4616
536
+       6544.4360      17.3566
537
+       6544.9900      19.0455
538
+       6545.5440      19.6785
539
+       6546.0980      21.2090
540
+       6546.6520      20.5227
541
+       6547.2060      20.0974
542
+       6547.7600      19.9369
543
+       6548.3140      18.8975
544
+       6548.8680      21.2557
545
+       6549.4220      17.3551
546
+       6549.9760      20.3647
547
+       6550.5300      20.8568
548
+       6551.0840      19.4628
549
+       6551.6380      19.8924
550
+       6552.1920      18.6387
551
+       6552.7460      19.8774
552
+       6553.3000      21.1110
553
+       6553.8540      17.1980
554
+       6554.4080      20.9541
555
+       6554.9620      22.6632
556
+       6555.5160      19.8164
557
+       6556.0700      20.5334
558
+       6556.6240      21.0241
559
+       6557.1780      21.4203
560
+       6557.7320      22.3708
561
+       6558.2860      23.2339
562
+       6558.8400      21.6285
563
+       6559.3940      21.4539
564
+       6559.9480      20.4885
565
+       6560.5020      20.5943
566
+       6561.0560      20.3349
567
+       6561.6100      18.7316
568
+       6562.1640      19.5434
569
+       6562.7180      19.9610
570
+       6563.2720      18.6941
571
+       6563.8260      19.1814
572
+       6564.3800      18.8340
573
+       6564.9340      19.6391
574
+       6565.4880      18.9640
575
+       6566.0420      20.4038
576
+       6566.5960      20.6336
577
+       6567.1500      19.1907
578
+       6567.7040      19.1191
579
+       6568.2580      19.5066
580
+       6568.8120      20.5585
581
+       6569.3660      20.9814
582
+       6569.9200      20.8646
583
+       6570.4740      19.6008
584
+       6571.0280      20.1055
585
+       6571.5820      20.8478
586
+       6572.1360      21.4340
587
+       6572.6900      21.0763
588
+       6573.2440      21.0281
589
+       6573.7980      20.0633
590
+       6574.3520      21.6055
591
+       6574.9060      22.0496
592
+       6575.4600      22.5150
593
+       6576.0140      23.2025
594
+       6576.5680      25.0891
595
+       6577.1220      25.5392
596
+       6577.6760      25.6677
597
+       6578.2300      24.7705
598
+       6578.7840      24.6712
599
+       6579.3380      26.5970
600
+       6579.8920      27.7217
601
+       6580.4460      29.8677
602
+       6581.0000      31.6401
603
+       6581.5540      36.2007
604
+       6582.1080      39.5042
605
+       6582.6620      45.1931
606
+       6583.2160      52.1273
607
+       6583.7700      59.4507
608
+       6584.3240      67.3330
609
+       6584.8780      66.2447
610
+       6585.4320      58.1841
611
+       6585.9860      51.0285
612
+       6586.5400      42.0325
613
+       6587.0940      33.9296
614
+       6587.6480      29.6038
615
+       6588.2020      27.0463
616
+       6588.7560      26.2361
617
+       6589.3100      23.4578
618
+       6589.8640      23.5562
619
+       6590.4180      24.9060
620
+       6590.9720      24.4400
621
+       6591.5260      23.7210
622
+       6592.0800      24.1002
623
+       6592.6340      25.8813
624
+       6593.1880      28.7411
625
+       6593.7420      31.1462
626
+       6594.2960      34.5940
627
+       6594.8500      38.2738
628
+       6595.4040      44.2407
629
+       6595.9580      55.9275
630
+       6596.5120      67.3132
631
+       6597.0660      82.0715
632
+       6597.6200      104.158
633
+       6598.1740      130.759
634
+       6598.7280      154.839
635
+       6599.2820      166.689
636
+       6599.8360      144.946
637
+       6600.3900      122.120
638
+       6600.9440      95.8310
639
+       6601.4980      64.1135
640
+       6602.0520      48.4300
641
+       6602.6060      39.5269
642
+       6603.1600      34.2148
643
+       6603.7140      30.0838
644
+       6604.2680      25.7155
645
+       6604.8220      23.7614
646
+       6605.3760      23.3404
647
+       6605.9300      23.7890
648
+       6606.4840      23.7415
649
+       6607.0380      23.6208
650
+       6607.5920      23.6858
651
+       6608.1460      23.1684
652
+       6608.7000      23.5296
653
+       6609.2540      24.2691
654
+       6609.8080      25.1316
655
+       6610.3620      25.1295
656
+       6610.9160      24.3198
657
+       6611.4700      24.5262
658
+       6612.0240      24.9355
659
+       6612.5780      25.8981
660
+       6613.1320      29.1776
661
+       6613.6860      32.9874
662
+       6614.2400      34.5587
663
+       6614.7940      36.4524
664
+       6615.3480      42.3573
665
+       6615.9020      48.0832
666
+       6616.4560      54.5850
667
+       6617.0100      65.3569
668
+       6617.5640      76.9998
669
+       6618.1180      93.8837
670
+       6618.6720      116.844
671
+       6619.2260      137.523
672
+       6619.7800      152.852
673
+       6620.3340      161.448
674
+       6620.8880      152.001
675
+       6621.4420      118.938
676
+       6621.9960      82.2067
677
+       6622.5500      58.2807
678
+       6623.1040      44.6812
679
+       6623.6580      34.3301
680
+       6624.2120      29.1157
681
+       6624.7660      28.1992
682
+       6625.3200      26.6171
683
+       6625.8740      24.3425
684
+       6626.4280      24.2991
685
+       6626.9820      24.0765
686
+       6627.5360      21.8737
687
+       6628.0900      20.7832
688
+       6628.6440      21.9380
689
+       6629.1980      20.7688
690
+       6629.7520      19.6957
691
+       6630.3060      19.2478
692
+       6630.8600      18.6033
693
+       6631.4140      19.9453
694
+       6631.9680      20.3755
695
+       6632.5220      19.7011
696
+       6633.0760      19.4732
697
+       6633.6300      19.4947
698
+       6634.1840      20.9534
699
+       6634.7380      20.5470
700
+       6635.2920      19.3099
701
+       6635.8460      20.5670
702
+       6636.4000      20.3986
703
+       6636.9540      19.6587
704
+       6637.5080      18.9457
705
+       6638.0620      19.1586
706
+       6638.6160      19.9326
707
+       6639.1700      20.3277
708
+       6639.7240      19.4582
709
+       6640.2780      20.6160
710
+       6640.8320      21.1014
711
+       6641.3860      19.7347
712
+       6641.9400      21.4853
713
+       6642.4940      21.4933
714
+       6643.0480      20.7241
715
+       6643.6020      20.8845
716
+       6644.1560      20.6209
717
+       6644.7100      20.6115
718
+       6645.2640      19.4499
719
+       6645.8180      20.5414
720
+       6646.3720      21.0062
721
+       6646.9260      19.7883
722
+       6647.4800      18.3220
723
+       6648.0340      19.3579
724
+       6648.5880      19.5905
725
+       6649.1420      20.6075
726
+       6649.6960      18.8132
727
+       6650.2500      17.6117
728
+       6650.8040      21.4534
729
+       6651.3580      20.9789
730
+       6651.9120      20.1589
731
+       6652.4660      20.2961
732
+       6653.0200      19.4876
733
+       6653.5740      19.8435
734
+       6654.1280      20.8248
735
+       6654.6820      20.5742
736
+       6655.2360      19.3550
737
+       6655.7900      19.4507
738
+       6656.3440      19.9566
739
+       6656.8980      19.1757
740
+       6657.4520      20.5401
741
+       6658.0060      22.4129
742
+       6658.5600      20.8692
743
+       6659.1140      20.8352
744
+       6659.6680      20.4446
745
+       6660.2220      20.8682
746
+       6660.7760      19.2264
747
+       6661.3300      19.4142
748
+       6661.8840      19.2252
749
+       6662.4380      18.8023
750
+       6662.9920      19.6633
751
+       6663.5460      20.3500
752
+       6664.1000      19.6079
753
+       6664.6540      20.3009
754
+       6665.2080      19.6269
755
+       6665.7620      21.9497
756
+       6666.3160      20.5701
757
+       6666.8700      19.2821
758
+       6667.4240      19.0143
759
+       6667.9780      19.5594
760
+       6668.5320      20.3786
761
+       6669.0860      19.7933
762
+       6669.6400      20.0205
763
+       6670.1940      18.6706
764
+       6670.7480      18.8540
765
+       6671.3020      20.0066
766
+       6671.8560      19.9728
767
+       6672.4100      19.2545
768
+       6672.9640      20.1626
769
+       6673.5180      18.6990
770
+       6674.0720      19.5303
771
+       6674.6260      19.7407
772
+       6675.1800      20.8232
773
+       6675.7340      22.6179
774
+       6676.2880      20.3008
775
+       6676.8420      19.3083
776
+       6677.3960      20.9807
777
+       6677.9500      20.5947
778
+       6678.5040      18.5498
779
+       6679.0580      19.0943
780
+       6679.6120      21.3645
781
+       6680.1660      19.9647
782
+       6680.7200      18.1677
783
+       6681.2740      17.3911
784
+       6681.8280      19.9894
785
+       6682.3820      17.9086
786
+       6682.9360      19.1081
787
+       6683.4900      18.8703
788
+       6684.0440      18.8569
789
+       6684.5980      22.0491
790
+       6685.1520      19.2424
791
+       6685.7060      20.0554
792
+       6686.2600      20.1510
793
+       6686.8140      19.0480
794
+       6687.3680      20.5827
795
+       6687.9220      19.7750
796
+       6688.4760      20.3948
797
+       6689.0300      19.0764
798
+       6689.5840      17.6081
799
+       6690.1380      19.9236
800
+       6690.6920      20.3151
801
+       6691.2460      19.8926
802
+       6691.8000      19.0738
803
+       6692.3540      19.7650
804
+       6692.9080      20.5196
805
+       6693.4620      21.1427
806
+       6694.0160      18.8082
807
+       6694.5700      19.8406
808
+       6695.1240      21.0289
809
+       6695.6780      19.7923
810
+       6696.2320      18.9540
811
+       6696.7860      17.8256
812
+       6697.3400      18.6686
813
+       6697.8940      18.6286
814
+       6698.4480      19.8510
815
+       6699.0020      17.6020
816
+       6699.5560      18.4082
817
+       6700.1100      18.5649
818
+       6700.6640      18.1578
819
+       6701.2180      18.5283
820
+       6701.7720      18.0017
821
+       6702.3260      19.8825
822
+       6702.8800      18.1138
823
+       6703.4340      19.1790
824
+       6703.9880      19.4695
825
+       6704.5420      20.1022
826
+       6705.0960      19.7503
827
+       6705.6500      19.4556
828
+       6706.2040      19.0063
829
+       6706.7580      19.2346
830
+       6707.3120      19.7346
831
+       6707.8660      19.7955
832
+       6708.4200      20.3739
833
+       6708.9740      20.2788
834
+       6709.5280      19.4209
835
+       6710.0820      19.5952
836
+       6710.6360      18.3127
837
+       6711.1900      19.4116
838
+       6711.7440      20.1447
839
+       6712.2980      17.1444
840
+       6712.8520      20.8219
841
+       6713.4060      19.3216
842
+       6713.9600      19.4712
843
+       6714.5140      21.7114
844
+       6715.0680      20.6351
845
+       6715.6220      19.5372
846
+       6716.1760      20.8066
847
+       6716.7300      19.6911
848
+       6717.2840      19.1860
849
+       6717.8380      19.2569
850
+       6718.3920      19.4478
851
+       6718.9460      19.8728
852
+       6719.5000      19.8443
853
+       6720.0540      20.1460
854
+       6720.6080      19.3576
855
+       6721.1620      20.3845
856
+       6721.7160      20.2068
857
+       6722.2700      20.7287
858
+       6722.8240      19.6896
859
+       6723.3780      18.3578
860
+       6723.9320      19.3693
861
+       6724.4860      18.9992
862
+       6725.0400      18.1613
863
+       6725.5940      20.6043
864
+       6726.1480      21.0316
865
+       6726.7020      20.5277
866
+       6727.2560      21.8013
867
+       6727.8100      19.7795
868
+       6728.3640      20.9107
869
+       6728.9180      20.3970
870
+       6729.4720      19.4869
871
+       6730.0260      20.1869
872
+       6730.5800      19.4323
873
+       6731.1340      18.8834
874
+       6731.6880      19.3356
875
+       6732.2420      18.7087
876
+       6732.7960      19.4827
877
+       6733.3500      21.1118
878
+       6733.9040      20.9485
879
+       6734.4580      20.8602
880
+       6735.0120      20.8539
881
+       6735.5660      21.1124
882
+       6736.1200      21.3894
883
+       6736.6740      21.0573
884
+       6737.2280      20.9166
885
+       6737.7820      19.5911
886
+       6738.3360      20.2924
887
+       6738.8900      19.5895
888
+       6739.4440      21.1529
889
+       6739.9980      20.8831
890
+       6740.5520      20.0236
891
+       6741.1060      21.2298
892
+       6741.6600      21.0492
893
+       6742.2140      22.0070
894
+       6742.7680      21.4358
895
+       6743.3220      20.4420
896
+       6743.8760      18.9136
897
+       6744.4300      21.6202
898
+       6744.9840      20.4650
899
+       6745.5380      20.6454
900
+       6746.0920      21.0727
901
+       6746.6460      20.6895
902
+       6747.2000      22.2061
903
+       6747.7540      22.2918
904
+       6748.3080      22.3728
905
+       6748.8620      23.8036
906
+       6749.4160      23.3103
907
+       6749.9700      23.7450
908
+       6750.5240      26.5682
909
+       6751.0780      27.6973
910
+       6751.6320      30.8140
911
+       6752.1860      33.2592
912
+       6752.7400      36.0206
913
+       6753.2940      39.0239
914
+       6753.8480      37.2524
915
+       6754.4020      34.5739
916
+       6754.9560      31.1382
917
+       6755.5100      28.5667
918
+       6756.0640      24.8606
919
+       6756.6180      24.3483
920
+       6757.1720      21.5713
921
+       6757.7260      23.7640
922
+       6758.2800      21.7487
923
+       6758.8340      21.2566
924
+       6759.3880      21.7451
925
+       6759.9420      21.6718
926
+       6760.4960      21.8084
927
+       6761.0500      21.4460
928
+       6761.6040      22.7694
929
+       6762.1580      21.7641
930
+       6762.7120      22.9700
931
+       6763.2660      23.8768
932
+       6763.8200      22.7537
933
+       6764.3740      25.4592
934
+       6764.9280      28.1632
935
+       6765.4820      30.2257
936
+       6766.0360      32.4609
937
+       6766.5900      35.5991
938
+       6767.1440      40.7722
939
+       6767.6980      43.5496
940
+       6768.2520      45.4351
941
+       6768.8060      40.7874
942
+       6769.3600      37.7164
943
+       6769.9140      31.4194
944
+       6770.4680      26.5626
945
+       6771.0220      24.8850
946
+       6771.5760      21.9932
947
+       6772.1300      21.5798
948
+       6772.6840      20.9439
949
+       6773.2380      19.7670
950
+       6773.7920      21.0333
951
+       6774.3460      20.8703
952
+       6774.9000      21.6122
953
+       6775.4540      19.2450
954
+       6776.0080      19.9100
955
+       6776.5620      18.6992
956
+       6777.1160      18.7935
957
+       6777.6700      19.7032
958
+       6778.2240      20.5730
959
+       6778.7780      19.5226
960
+       6779.3320      18.7790
961
+       6779.8860      18.7053
962
+       6780.4400      18.4863
963
+       6780.9940      19.1434
964
+       6781.5480      16.3791
965
+       6782.1020      16.7204
966
+       6782.6560      18.0721
967
+       6783.2100      18.0712
968
+       6783.7640      18.8048
969
+       6784.3180      18.1767
970
+       6784.8720      19.2046
971
+       6785.4260      20.3328
972
+       6785.9800      20.6915
973
+       6786.5340      19.4404
974
+       6787.0880      19.6642
975
+       6787.6420      19.5783
976
+       6788.1960      18.9902
977
+       6788.7500      18.2599
978
+       6789.3040      18.8512
979
+       6789.8580      18.5336
980
+       6790.4120      17.6636
981
+       6790.9660      18.3255
982
+       6791.5200      20.0259
983
+       6792.0740      19.0938
984
+       6792.6280      19.4149
985
+       6793.1820      19.2219
986
+       6793.7360      20.4679
987
+       6794.2900      21.1455
988
+       6794.8440      19.5279
989
+       6795.3980      18.7935
990
+       6795.9520      20.5456
991
+       6796.5060      20.0350
992
+       6797.0600      18.9582
993
+       6797.6140      19.6174
994
+       6798.1680      20.3751
995
+       6798.7220      19.9874
996
+       6799.2760      18.3562
997
+       6799.8300      19.5166
998
+       6800.3840      20.2143
999
+       6800.9380      19.6551
1000
+       6801.4920      19.0767
1001
+       6802.0460      18.7790
1002
+       6802.6000      20.3401
1003
+       6803.1540      21.5462
1004
+       6803.7080      19.9388
1005
+       6804.2620      18.4681
1006
+       6804.8160      19.9775
1007
+       6805.3700      19.6801
1008
+       6805.9240      19.0773
1009
+       6806.4780      18.8479
1010
+       6807.0320      18.4472
1011
+       6807.5860      19.4451
1012
+       6808.1400      18.3430
1013
+       6808.6940      18.4687
1014
+       6809.2480      18.8832
1015
+       6809.8020      19.7252
1016
+       6810.3560      19.8735
1017
+       6810.9100      21.0937
1018
+       6811.4640      19.6230
1019
+       6812.0180      18.9942
1020
+       6812.5720      19.6918
1021
+       6813.1260      18.9632
1022
+       6813.6800      19.1040
1023
+       6814.2340      21.3457
1024
+       6814.7880      19.3450
1025
+       6815.3420      18.9928
1026
+       6815.8960      19.2127
1027
+       6816.4500      18.4426
1028
+       6817.0040      18.4924
1029
+       6817.5580      18.8741
1030
+       6818.1120      18.1046
1031
+       6818.6660      19.7911
1032
+       6819.2200      20.0068
1033
+       6819.7740      19.5075
1034
+       6820.3280      20.5297
1035
+       6820.8820      19.5471
1036
+       6821.4360      18.3781
1037
+       6821.9900      18.0614
1038
+       6822.5440      18.8608
1039
+       6823.0980      18.6227
1040
+       6823.6520      18.7572
1041
+       6824.2060      18.4036
1042
+       6824.7600      19.0150
1043
+       6825.3140      19.3986
1044
+       6825.8680      19.7782
1045
+       6826.4220      19.7572
1046
+       6826.9760      18.3128
1047
+       6827.5300      16.5033
1048
+       6828.0840      18.4095
1049
+       6828.6380      19.5098
1050
+       6829.1920      19.5282
1051
+       6829.7460      20.7815
1052
+       6830.3000      19.9678
1053
+       6830.8540      17.9019
1054
+       6831.4080      20.7641
1055
+       6831.9620      19.3701
1056
+       6832.5160      18.4056
1057
+       6833.0700      19.1954
1058
+       6833.6240      19.6086
1059
+       6834.1780      18.0328
1060
+       6834.7320      19.1735
1061
+       6835.2860      18.8388
1062
+       6835.8400      17.9688
1063
+       6836.3940      17.8133
1064
+       6836.9480      20.3226
1065
+       6837.5020      19.9505
1066
+       6838.0560      19.7628
1067
+       6838.6100      18.5026
1068
+       6839.1640      19.4168
1069
+       6839.7180      19.0886
1070
+       6840.2720      19.4950
1071
+       6840.8260      19.0386
1072
+       6841.3800      19.3613
1073
+       6841.9340      20.5760
1074
+       6842.4880      19.2767
1075
+       6843.0420      20.2116
1076
+       6843.5960      19.8021
1077
+       6844.1500      17.9357
1078
+       6844.7040      18.4056
1079
+       6845.2580      18.9235
1080
+       6845.8120      21.2539
1081
+       6846.3660      19.1222
1082
+       6846.9200      19.1116
1083
+       6847.4740      19.4858
1084
+       6848.0280      16.9752
1085
+       6848.5820      20.6931
1086
+       6849.1360      18.8379
1087
+       6849.6900      18.3726
1088
+       6850.2440      17.2251
1089
+       6850.7980      18.3125
1090
+       6851.3520      18.8181
1091
+       6851.9060      19.6145
1092
+       6852.4600      18.0518
1093
+       6853.0140      16.4574
1094
+       6853.5680      16.1572
1095
+       6854.1220      18.3224
1096
+       6854.6760      19.9573
1097
+       6855.2300      19.1848
1098
+       6855.7840      19.2895
1099
+       6856.3380      20.0645
1100
+       6856.8920      20.0335
1101
+       6857.4460      18.8627
1102
+       6858.0000      17.7411
1103
+       6858.5540      19.4334
1104
+       6859.1080      19.3225
1105
+       6859.6620      18.8582
1106
+       6860.2160      18.1860
1107
+       6860.7700      20.4508
1108
+       6861.3240      20.7856
1109
+       6861.8780      20.1865
1110
+       6862.4320      18.7809
1111
+       6862.9860      18.9147
1112
+       6863.5400      20.6800
1113
+       6864.0940      18.4504
1114
+       6864.6480      18.6347
1115
+       6865.2020      24.5428
1116
+       6865.7560      0.00000
1117
+       6866.3100      0.00000
1118
+       6866.8640      0.00000
1119
+       6867.4180      0.00000
1120
+       6867.9720      0.00000
1121
+       6868.5260      0.00000
1122
+       6869.0800      0.00000
1123
+       6869.6340      0.00000
1124
+       6870.1880      0.00000
1125
+       6870.7420      0.00000
1126
+       6871.2960      0.00000
1127
+       6871.8500      0.00000
1128
+       6872.4040      0.00000
1129
+       6872.9580      0.00000
1130
+       6873.5120      0.00000
1131
+       6874.0660      0.00000
1132
+       6874.6200      0.00000
1133
+       6875.1740      0.00000
1134
+       6875.7280      0.00000
1135
+       6876.2820      0.00000
1136
+       6876.8360      0.00000
1137
+       6877.3900      0.00000
1138
+       6877.9440      0.00000
1139
+       6878.4980      0.00000
1140
+       6879.0520      0.00000
1141
+       6879.6060      0.00000
1142
+       6880.1600      0.00000
1143
+       6880.7140      0.00000
1144
+       6881.2680      0.00000
1145
+       6881.8220      0.00000
1146
+       6882.3760      0.00000
1147
+       6882.9300      0.00000
1148
+       6883.4840      0.00000
1149
+       6884.0380      0.00000
1150
+       6884.5920      0.00000
1151
+       6885.1460      0.00000
1152
+       6885.7000      0.00000
1153
+       6886.2540      0.00000
1154
+       6886.8080      0.00000
1155
+       6887.3620      0.00000
1156
+       6887.9160      0.00000
1157
+       6888.4700      0.00000
1158
+       6889.0240      0.00000
1159
+       6889.5780      0.00000
1160
+       6890.1320      0.00000
1161
+       6890.6860      0.00000
1162
+       6891.2400      0.00000
1163
+       6891.7940      0.00000
1164
+       6892.3480      0.00000
1165
+       6892.9020      0.00000
1166
+       6893.4560      0.00000
1167
+       6894.0100      0.00000
1168
+       6894.5640      0.00000
1169
+       6895.1180      0.00000
1170
+       6895.6720      0.00000
1171
+       6896.2260      0.00000
1172
+       6896.7800      0.00000
1173
+       6897.3340      0.00000
1174
+       6897.8880      0.00000
1175
+       6898.4420      0.00000
1176
+       6898.9960      0.00000
1177
+       6899.5500      0.00000
1178
+       6900.1040      0.00000
1179
+       6900.6580      0.00000
1180
+       6901.2120      0.00000
1181
+       6901.7660      0.00000
1182
+       6902.3200      0.00000
1183
+       6902.8740      0.00000
1184
+       6903.4280      0.00000
1185
+       6903.9820      0.00000
1186
+       6904.5360      0.00000
1187
+       6905.0900      0.00000
1188
+       6905.6440      0.00000
1189
+       6906.1980      0.00000
1190
+       6906.7520      0.00000
1191
+       6907.3060      0.00000
1192
+       6907.8600      0.00000
1193
+       6908.4140      0.00000
1194
+       6908.9680      0.00000
1195
+       6909.5220      0.00000
1196
+       6910.0760      0.00000
1197
+       6910.6300      0.00000
1198
+       6911.1840      0.00000
1199
+       6911.7380      0.00000
1200
+       6912.2920      0.00000
1201
+       6912.8460      0.00000
1202
+       6913.4000      0.00000
... ...
@@ -0,0 +1,18 @@
1
+#1
2
+spec = read.table("M100_spec.txt",header=FALSE)
3
+spec.boolmask = (21 > spec[,2]) & (spec[,2] >17)
4
+spec.zero = spec
5
+spec.notnull = (spec[,2] != 0)
6
+spec.fit <- lm(spec[spec.boolmask,2] ~ spec[spec.boolmask,1])
7
+spec.zero[,2]=(spec[,2])-coef(spec.fit)[1]
8
+
9
+#2
10
+y=spec.zero[622:646,2]
11
+x=spec.zero[622:646,1]
12
+gbin <- cbind(spec.zero[622:646,])
13
+Sigma= var(gbin)
14
+mu = apply(gbin,2,mean)
15
+gcoeffs <-nls(y~(b/a)*exp(-(x-6599.2820)^2/(2*a**2)),start=list(a=1,b=200), trace=TRUE)
16
+yg=(231.24/1.73)*exp(-(x-6599.2820)^2/(2*1.73**2))
17
+plot(spec.zero[spec.notNull,1],spec.zero[spec.notNull,2],'l')
18
+lines(x,yg,col='red')
... ...
@@ -0,0 +1,115 @@
1
+#Exercise 1
2
+#a)
3
+#setwd("C:/Users/Studium/Desktop/Statistische Methoden/Sheet 4")
4
+input=scan(file = "sn_data_riess.dat", what = list(character(), double(), double(), double()), skip=1, multi.line=FALSE)
5
+data=cbind(input[[2]], input[[3]], input[[4]])
6
+data
7
+
8
+#b)
9
+#Constants
10
+H0=72.0 #km/s/Mpc
11
+c = 3*10^5 #km/s
12
+
13
+
14
+#Hubble's law
15
+Hubble=function(z,Omegam) H0*sqrt(Omegam*(1+z)^3+(1.0-Omegam))
16
+
17
+
18
+#H^(-1)
19
+Hinv=function(zint,Omegam) 1.0/Hubble(zint,Omegam)
20
+
21
+
22
+#Luminosity distance
23
+dL=function(z,Omegami){
24
+	dLsol=z
25
+	for (i in (1:length(z))){
26
+		zarg=z[i]
27
+		I=integrate(Hinv,0.0,zarg,Omegam=Omegami)
28
+		dLsol[i] = c*(1+zarg)*I$value
29
+		}
30
+	return(dLsol)
31
+	}
32
+
33
+m=function(z, Omegam, M) M + 5*log10(H0 * dL(z, Omegam))
34
+
35
+mag_th=NULL
36
+mag_th[186]=1
37
+for (i in (1:186)){
38
+	mag_th[i] = m(data[i,1], 1, data[i,2]) #Omegam = 1 for a flat universe 
39
+	}
40
+
41
+#c)
42
+chisquare=function(Omegam, M) {
43
+	chisqu=0
44
+	for (i in (1:186)){
45
+		chisqu=chisqu+(data[i,2] - m(data[i,1], Omegam, M))**2/data[i,3]**2
46
+	}
47
+	return(chisqu)
48
+}
49
+
50
+	
51
+#d)
52
+#create vectors Omegam und M
53
+Omegam_vec=seq(0.0,1.0, by=0.05)
54
+M_vec=seq(15.5, 16.6, 0.01)
55
+
56
+chisquare_min = chisquare(0,0) #set initial value
57
+Omegam_min=0
58
+M_min=0
59
+
60
+#zweifach verschachtelte Schleife f�r Omegam und M
61
+
62
+for (i in M_vec){
63
+	for (j in Omegam_vec){
64
+		if (chisquare(j,i) < chisquare_min){ #compare current value with known smallest value 
65
+			chisquare_min = chisquare(j,i)# set new smallest value
66
+			Omegam_min = j 
67
+			M_min = i
68
+		}
69
+	}
70
+}
71
+chisquare_min
72
+Omegam_min
73
+M_min
74
+
75
+#e)
76
+posterior = function(Omegam, M){
77
+	p = exp(-0.5*(chisquare(Omegam, M)- chisquare_min))
78
+	return(p)
79
+}
80
+
81
+#f)
82
+Atest=seq(0,1,by = 0.05)	
83
+Btest=seq(15.5,16.5,by = 0.01)
84
+
85
+jmax=length(Atest)
86
+kmax=length(Btest)
87
+j=1
88
+k=1
89
+
90
+postplot = matrix(nrow=jmax,ncol=kmax)
91
+while (j<=jmax){ k=1
92
+	while (k<=kmax) {
93
+	postplot[j,k]=posterior(Atest[j],Btest[k])
94
+	k=k+1}
95
+	j=j+1}
96
+contour(Atest,Btest,postplot,levels=c(1.0,0.8,0.6,0.4,0.2,0.0),drawlabels=FALSE,xlab='Omegam',ylab='M',xlim=c(0,3),ylim=c(0,3))
97
+
98
+#g)
99
+pMmarg=function(Mi) {I=integrate(posterior,13.0,18.0,A=Mi)
100
+	return(I$value)
101
+	}
102
+
103
+#h)
104
+pMplot=function(Mi) {dumplot=Mi
105
+	for (i in (1:length(Mi))) {
106
+	     Marg=Mi[i]*1.0
107
+	     dumplot[i]=pMmarg(Marg)
108
+	            }
109
+	return(dumplot)}
110
+	
111
+Mplot=seq(0.1,3.0,by = 0.02)
112
+
113
+normM=1.0/max(pMplot(Mplot))
114
+plot(Mplot,normM*pMplot(Mplot),type='l',lwd=2,xlab='M',ylab='prob(M|{N_k},I)')
115
+
... ...
@@ -0,0 +1,52 @@
1
+# EXAMPLE 3: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+
6
+
7
+
8
+# Sequence of probabilities (Hypothesis)
9
+H=seq(0,1,by = 0.01)
10
+
11
+# number of trials
12
+n=32
13
+
14
+# bias 
15
+bias=0.25
16
+
17
+# generate random sample with possible outcome 0,1 and bias: toss the (un-)fair coin
18
+coin=sample(c(0,1),n,replace=TRUE,c(1.0-bias,bias))
19
+
20
+# 
21
+
22
+# count heads of sample
23
+heads=sum(coin)
24
+
25
+
26
+# prior distribution 
27
+# uniform
28
+prior = 1.0
29
+
30
+
31
+#Gaussian approximation
32
+H0 = heads/n
33
+sigma=sqrt(H0*(1-H0)/n)
34
+likeapprox <- function(H) 1.0/sqrt(2.0*pi)/sigma*exp(-0.5*(H-H0)**2/sigma**2)
35
+
36
+#calculate normalization of binomial distribution
37
+sum = 0.0
38
+i = 0
39
+while (i < n-heads) {sum=sum+choose(n-heads,i)*((-1)^i)/(heads+i+1) 
40
+	i=i+1 }
41
+norm = abs(1.0/sum)
42
+
43
+# plot posterior (likelihood times prior)
44
+
45
+par(font.lab=2)
46
+par(font.axis=2)
47
+plot(H,norm*dbinom(heads,n,H)*prior,type='l', xlab='H',ylab='prob(H|{data},I)', lwd=2, main=paste("N=",n))
48
+lines(H,likeapprox(H)*prior,lty=2,lwd=2)
49
+abline(v=H0,lty=3,lwd=2,col='blue')
50
+abline(v=H0-sigma,lty=3,lwd=2,col='blue')
51
+abline(v=H0+sigma,lty=3,lwd=2,col='blue')
52
+legend("topright",legend=c("Binomial","Gaussian approximation","maximum, sigma"),lty=c(1,2,3),lwd=c(2,2,2),col=c("black","black","blue"))
0 53
\ No newline at end of file
... ...
@@ -0,0 +1,51 @@
1
+# EXAMPLE 4: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+
6
+# The Lighthouse Problem
7
+alpha0 = 1 #km true position at coastline
8
+beta = 1 #km position out at see
9
+
10
+# Sequence of positions (use already prior range from -10 to 10 km)
11
+alpha=seq(-10,10,by = 0.05)
12
+
13
+# number of trials
14
+N=512
15
+
16
+# generate random sample distributed according to a Cauchy distribution (see lecture)
17
+# with N trial
18
+pos=rcauchy(N,alpha0,beta)
19
+
20
+# prior distribution 
21
+# uniform between -10 and +10 km
22
+prior = 1.0/20.0
23
+
24
+sum = 0.0
25
+i = 1
26
+
27
+logpost <- function(alpha) { while (i<=N){sum=sum+log(beta^2+(pos[i]-alpha)^2)
28
+		i=i+1 }; sum}
29
+
30
+#find minimum of log likelihood
31
+lmin=min(logpost(alpha))
32
+
33
+# normalized posterior
34
+post <- function(alpha) exp(-logpost(alpha)+lmin)
35
+
36
+# plot posterior 
37
+
38
+par(font.lab=2)
39
+par(font.axis=2)
40
+plot(alpha,post(alpha),type='l', xlab=expression(paste(alpha,"(km)")),ylab=expression(prob(~alpha~"|{"~x[k]~"}",~beta,I)), lwd=2, main=paste("N=",N),xlim=c(-12,12),ylim=c(0,1.2))
41
+
42
+# plot points of samples at vertical position 1.1
43
+
44
+normpoint = (pos-pos)+1.1
45
+points(pos,normpoint)
46
+
47
+# vertical line at mean of sample
48
+abline(v=mean(pos),lwd=2,lty=2)
49
+
50
+
51
+
... ...
@@ -0,0 +1,16 @@
1
+# EXAMPLE 5: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+# BINOMIAL PROBABILITY
6
+
7
+N=20
8
+r=seq(0,N,by=1)
9
+
10
+p=0.1
11
+
12
+plot(r,dbinom(r,N,p),type='h',xlim=c(0,20),xlab='r',ylab='f(r;N,p)',main=paste("N=",N,"; p=",p))
13
+
14
+
15
+
16
+
... ...
@@ -0,0 +1,14 @@
1
+# EXAMPLE 6: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+# Poisson PROBABILITY
6
+
7
+nu=2
8
+r=seq(0,20,by=1)
9
+
10
+plot(r,dpois(r,nu),type='h',xlim=c(0,20),xlab='r',ylab="f(r;nu)",main=paste("nu=",nu))
11
+
12
+
13
+
14
+
... ...
@@ -0,0 +1,20 @@
1
+# EXAMPLE 7: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+# Exponential PROBABILITY
6
+
7
+
8
+x=seq(0,5,by=0.1)
9
+
10
+xi=1.0
11
+plot(x,exp(-x/xi)/xi,type='l',xlim=c(0,5),xlab='x',ylab="f(x;xi)",lwd=2)
12
+
13
+xi2=2.0
14
+lines(x,exp(-x/xi2)/xi2,lwd=2,lty=2)
15
+
16
+xi3=5.0
17
+lines(x,exp(-x/xi3)/xi3,lwd=2,lty=3)
18
+legend("topright",legend=c(paste("xi=",xi),paste("xi=",xi2),paste("xi=",xi3)),lty=c(1,2,3),lwd=c(2,2,2),col=c("black","black","black"))
19
+
20
+
... ...
@@ -0,0 +1,35 @@
1
+# EXAMPLE 7: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+# LOG-NORMAL PROBABILITY
6
+
7
+
8
+x=seq(0,4,by=0.1)
9
+
10
+mu=0.0
11
+sigma=1.0
12
+norm=1.0/sqrt(2.0*pi)/sigma
13
+plot(x,norm*exp(-(log(x)-mu)^2/sigma^2)/x,type='l',xlim=c(0,4),ylim=c(0,1),xlab='x',ylab="f(x;mu,sigma)",lwd=2)
14
+
15
+
16
+
17
+mu=0
18
+sigma=1.5
19
+norm=1.0/sqrt(2.0*pi)/sigma
20
+lines(x,norm*exp(-(log(x)-mu)^2/sigma^2)/x,lwd=2,lty=2)
21
+
22
+mu=0
23
+sigma=0.5
24
+norm=1.0/sqrt(2.0*pi)/sigma
25
+lines(x,norm*exp(-(log(x)-mu)^2/sigma^2)/x,lwd=2,lty=3)
26
+
27
+mu=1
28
+sigma=1.0
29
+norm=1.0/sqrt(2.0*pi)/sigma
30
+lines(x,norm*exp(-(log(x)-mu)^2/sigma^2)/x,lwd=2,lty=4)
31
+
32
+
33
+legend("topright",legend=c("mu=0,sigma=1","mu=0,sigma=1.5","mu=0,sigma=0.5","mu=1,sigma=1"),lty=c(1,2,3,4),lwd=c(2,2,2,2),col=c("black","black","black","black"))
34
+
35
+
... ...
@@ -0,0 +1,16 @@
1
+# EXAMPLE 9: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+# Poisson PROBABILITY
6
+
7
+nu=1.7
8
+r=seq(0,8,by=1)
9
+height=dpois(r,nu)
10
+
11
+barplot(height,xlab='Number of Counts N',ylab="prob(N|D=12.5)",axisnames=TRUE)
12
+
13
+
14
+
15
+
16
+
... ...
@@ -0,0 +1,65 @@
1
+# EXAMPLE 10: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+x0=1
6
+#fwhm = 5 = 2.35*sigma
7
+w=2.13
8
+n0=33.333
9
+A=1
10
+B=2
11
+
12
+#First generate random data 
13
+#Datum is Gaussian, and measurement Poisson
14
+
15
+xmin=-7
16
+xmax=7
17
+x=seq(xmin,xmax,by=1)
18
+
19
+d=n0*(A*exp(-0.5*(x-x0)^2/w^2)+B)
20
+N=d
21
+imax=length(d)
22
+i=1
23
+while (i <= imax) {N[i]=rpois(1,d[i])
24
+	i=i+1}
25
+	
26
+# The minimum chi2 for later	
27
+logepmin=sum(N*log(d)-d)	
28
+	
29
+quartz()
30
+
31
+# Plot the data	
32
+par(font.lab=2)
33
+par(font.axis=2)	
34
+plot(x,N,type='s',xlim=c(xmin,xmax),lwd=2)
35
+
36
+
37
+# posterior function for arbitrary A and B
38
+posterior<- function(A,B) {
39
+	d=n0*(A*exp(-0.5*(x-x0)^2/w^2)+B)
40
+	dummy=exp(sum(N*log(d)-d)-logepmin)
41
+	return(dummy)}
42
+
43
+# scan the parameter space
44
+Atest=seq(0,3,by = 0.02)	
45
+Btest=seq(0,3,by = 0.02)
46
+
47
+jmax=length(Atest)
48
+kmax=length(Btest)
49
+j=1
50
+k=1
51
+# generate a posterior matrix for the contour plot
52
+postplot = matrix(nrow=jmax,ncol=kmax)
53
+while (j<=jmax){ k=1
54
+	while (k<=kmax) {
55
+	postplot[j,k]=posterior(Atest[j],Btest[k])
56
+	k=k+1}
57
+	j=j+1}
58
+quartz()
59
+contour(Atest,Btest,postplot,levels=c(0.9,0.7,0.5,0.3,0.1),drawlabels=FALSE,xlab='A',ylab='B',xlim=c(0,3),ylim=c(0,3))
60
+	
61
+	
62
+
63
+
64
+
65
+
... ...
@@ -0,0 +1,76 @@
1
+# EXAMPLE 11: Introduction to Statistics for Astrophysicists
2
+# SS 2012
3
+# JOCHEN WELLER
4
+
5
+x0=1
6
+#fwhm = 5 = 2.35*sigma
7
+w=2.13
8
+n0=33.3333
9
+A=1
10
+B=2
11
+
12
+#First generate random data 
13
+#Datum is Gaussian, and measurement Poisson
14
+
15
+xmin=-7
16
+xmax=7
17
+x=seq(xmin,xmax,by=1.0)
18
+
19
+d=n0*(A*exp(-0.5*(x-x0)^2/w^2)+B)
20
+N=d
21
+imax=length(d)
22
+i=1
23
+while (i <= imax) {N[i]=rpois(1,d[i])
24
+	i=i+1}
25
+	
26
+# The minimum chi2 for later	
27
+logepmin=sum(N*log(d)-d)	
28
+	
29
+
30
+# posterior function for arbitrary A and B
31
+posterior=function (A,B) 
32
+{ summe=0.0*A
33
+	for (i in 1:length(x)) {
34
+	di=n0*(A*exp(-0.5*(x[i]-x0)^2/w^2)+B)
35
+	summe=summe+N[i]*log(di)-di
36
+	}
37
+	return(exp(summe-logepmin))
38
+}
39
+pAmarg=function(Ai) {I=integrate(posterior,0.0,Inf,A=Ai)
40
+	return(I$value)
41
+	}
42
+
43
+pAplot=function(Ai) {dumplot=Ai
44
+	for (i in (1:length(Ai))) {
45
+	     Aarg=Ai[i]*1.0
46
+	     dumplot[i]=pAmarg(Aarg)
47
+	            }
48
+	return(dumplot)}		
49
+	
50
+pBmarg=function(Bi) {I=integrate(posterior,0.0,Inf,B=Bi)
51
+	return(I$value)
52
+	}
53
+
54
+pBplot=function(Bi) {dumplot=Bi
55
+	for (i in (1:length(Bi))) {
56
+	     Barg=Bi[i]*1.0
57
+	     dumplot[i]=pBmarg(Barg)
58
+	            }
59
+	return(dumplot)}	
60
+	
61
+Aplot=seq(0.1,3.0,by = 0.02)
62
+Bplot=seq(0.1,3.0,by = 0.02)
63
+
64
+normA=1.0/max(pAplot(Aplot))
65
+plot(Aplot,normA*pAplot(Aplot),type='l',lwd=2,xlab='A',ylab='prob(A|{N_k},I)')
66
+normA2=1.0/max(posterior(Aplot,2.0))
67
+lines(Aplot,normA2*posterior(Aplot,2.0),lty=3,lwd=2)	
68
+
69
+quartz()
70
+normB=1.0/max(pBplot(Bplot))
71
+plot(Bplot,normB*pBplot(Bplot),type='l',lwd=2,xlab='B',ylab='prob(B|{N_k},I)')
72
+
73
+
74
+
75
+
76
+
0 77