-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmse.html
91 lines (66 loc) · 2.82 KB
/
mse.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<!-- Local files containing the website icon and stylesheet. -->
<link rel="stylesheet" type="text/css" href="theme.css">
<!--<link rel="stylesheet" type="text/css" href="https://sagecell.sagemath.org/static/sagecell_embed.css">-->
<!-- Imports needed to use the Sage cell server. -->
<script type="text/javascript" src="https://sagecell.sagemath.org/static/jquery.min.js"></script>
<script type="text/javascript" src="https://sagecell.sagemath.org/embedded_sagecell.js"></script>
<!--<script>sagecell.makeSagecell({"inputLocation": ".sage"});</script>-->
<!--<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="embedded_sagecell.js"></script>-->
<script type="text/javascript" src="sagecell.js"></script>
<script type="text/javascript" src="sage-text.js"></script>
<!-- Additional CSS customizations -->
<style type="text/css"></style>
<!-- Page title -->
<title>Vaganov-Shashkin Growth Model</title>
</head>
<body>
<h1>Vaganov-Shashkin Growth Model</h1>
<p>It's coming!
<div class="sagecell-plot" id="sagecell2">
<script type="application/sage">
# coding=utf-8
__author__ = 'vilyin'
import numpy as np
import matplotlib.pyplot as plt
def meanSquaredError(ringc, crn):
"""
Фитнесс функция, как сумма среднеквадратичных невязок (Mean squared error)
http://en.wikipedia.org/wiki/meanSquaredError
"""
n = len(ringc)
s = 0.0
for i in range(n):
s += (crn[i] - ringc[i]) ** 2
return -1.0 * (1.0 / float(n)) * s
def interval_random_sample(n, a, b):
return (b - a) * np.random.random_sample(n) + a
def py_plot_crn(min_crn = 0.2, max_crn = 1.9, min_year = 1940, max_year = 2015):
""" py_plot_crn """
count_year = max_year - min_year
irs1 = interval_random_sample(count_year, min_crn, max_crn)
irs2 = interval_random_sample(count_year, min_crn, max_crn)
# print(type(irs1), irs1, irs2, meanSquaredError(irs1, irs2))
x = np.linspace(min_year, max_year, count_year)
line, = plt.plot(x, irs1)
line, = plt.plot(x, irs2)
plt.show()
def sage_plot_crn(min_crn = 0.2, max_crn = 1.9, min_year = 1940, max_year = 2015):
""" sage_plot_crn """
count_year = max_year - min_year
irs1 = interval_random_sample(count_year, min_crn, max_crn)
irs2 = interval_random_sample(count_year, min_crn, max_crn)
x = np.linspace(min_year, max_year, count_year)
p1 = list_plot(zip(x, irs1), plotjoined=true, color="red", legend_label="ringc")
p2 = list_plot(zip(x, irs2), plotjoined=true, color="green", legend_label="crn")
show(p1+p2)
py_plot_crn(0.2, 1.9, 1965, 2001)
sage_plot_crn(0.2, 1.9, 1965, 2001)
</script>
</div>
<script type="text/javascript">sageFooter()</script>
</body>
</html>