Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132928 views
License: OTHER
1
import numpy as np
2
3
4
def linear_data_sample(N=40, rseed=0, m=3, b=-2):
5
rng = np.random.RandomState(rseed)
6
7
x = 10 * rng.rand(N)
8
dy = m / 2 * (1 + rng.rand(N))
9
y = m * x + b + dy * rng.randn(N)
10
11
return (x, y, dy)
12
13
14
def linear_data_sample_big_errs(N=40, rseed=0, m=3, b=-2):
15
rng = np.random.RandomState(rseed)
16
17
x = 10 * rng.rand(N)
18
dy = m / 2 * (1 + rng.rand(N))
19
dy[20:25] *= 10
20
y = m * x + b + dy * rng.randn(N)
21
22
return (x, y, dy)
23
24
25
def sample_light_curve(phased=True):
26
from astroML.datasets import fetch_LINEAR_sample
27
data = fetch_LINEAR_sample()
28
t, y, dy = data[18525697].T
29
30
if phased:
31
P_best = 0.580313015651
32
t /= P_best
33
34
return (t, y, dy)
35
36
37
def sample_light_curve_2(phased=True):
38
from astroML.datasets import fetch_LINEAR_sample
39
data = fetch_LINEAR_sample()
40
t, y, dy = data[10022663].T
41
42
if phased:
43
P_best = 0.61596079804
44
t /= P_best
45
46
return (t, y, dy)
47
48
49