Skip to content

Commit 00d551b

Browse files
authored
Merge pull request #9 from caleb-hamilton/master
changes to cp_pelt.ipynb
2 parents 8471852 + 56aebbb commit 00d551b

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

time_series_analysis/cp_pelt.ipynb

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
},
1414
{
1515
"cell_type": "code",
16-
"execution_count": 1,
17-
"metadata": {},
16+
"execution_count": 25,
17+
"metadata": {
18+
"collapsed": true
19+
},
1820
"outputs": [],
1921
"source": [
2022
"y = [\n",
@@ -45,13 +47,15 @@
4547
"cell_type": "markdown",
4648
"metadata": {},
4749
"source": [
48-
"We wish to look for changes in the mean, which is selected using the following `ctype` value in the NAG routine"
50+
"We wish to look for changes in the mean, assuming the data comes from Normal distributions, which is selected by setting the `ctype` parameter of the `cp_pelt` routine to `1`. Other values for `ctype` can be used for different distributions and properties of the data, but the plot in this notebook assumes `ctype = 1`."
4951
]
5052
},
5153
{
5254
"cell_type": "code",
53-
"execution_count": 2,
54-
"metadata": {},
55+
"execution_count": 26,
56+
"metadata": {
57+
"collapsed": true
58+
},
5559
"outputs": [],
5660
"source": [
5761
"ctype = 1"
@@ -66,8 +70,10 @@
6670
},
6771
{
6872
"cell_type": "code",
69-
"execution_count": 3,
70-
"metadata": {},
73+
"execution_count": 46,
74+
"metadata": {
75+
"collapsed": true
76+
},
7177
"outputs": [],
7278
"source": [
7379
"param = [0.2]"
@@ -82,8 +88,10 @@
8288
},
8389
{
8490
"cell_type": "code",
85-
"execution_count": 4,
86-
"metadata": {},
91+
"execution_count": 47,
92+
"metadata": {
93+
"collapsed": true
94+
},
8795
"outputs": [],
8896
"source": [
8997
"from naginterfaces.library import tsa\n",
@@ -101,7 +109,7 @@
101109
},
102110
{
103111
"cell_type": "code",
104-
"execution_count": 5,
112+
"execution_count": 48,
105113
"metadata": {},
106114
"outputs": [
107115
{
@@ -138,7 +146,7 @@
138146
},
139147
{
140148
"cell_type": "code",
141-
"execution_count": 6,
149+
"execution_count": 49,
142150
"metadata": {},
143151
"outputs": [
144152
{
@@ -223,7 +231,7 @@
223231
" };\n",
224232
"\n",
225233
" this.imageObj.onunload = function() {\n",
226-
" fig.ws.close();\n",
234+
" this.ws.close();\n",
227235
" }\n",
228236
"\n",
229237
" this.ws.onmessage = this._make_on_message_function(this);\n",
@@ -698,7 +706,7 @@
698706
"mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
699707
" this.message.textContent = tooltip;\n",
700708
"};\n",
701-
"mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
709+
"mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
702710
"\n",
703711
"mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n",
704712
"\n",
@@ -718,7 +726,7 @@
718726
" // Register the callback with on_msg.\n",
719727
" comm.on_msg(function(msg) {\n",
720728
" //console.log('receiving', msg['content']['data'], msg);\n",
721-
" // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
729+
" // Pass the mpl event to the overriden (by mpl) onmessage function.\n",
722730
" ws.onmessage(msg['content']['data'])\n",
723731
" });\n",
724732
" return ws;\n",
@@ -870,12 +878,9 @@
870878
" // Check for shift+enter\n",
871879
" if (event.shiftKey && event.which == 13) {\n",
872880
" this.canvas_div.blur();\n",
873-
" event.shiftKey = false;\n",
874-
" // Send a \"J\" for go to next cell\n",
875-
" event.which = 74;\n",
876-
" event.keyCode = 74;\n",
877-
" manager.command_mode();\n",
878-
" manager.handle_keydown(event);\n",
881+
" // select the cell after this one\n",
882+
" var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
883+
" IPython.notebook.select(index + 1);\n",
879884
" }\n",
880885
"}\n",
881886
"\n",
@@ -950,7 +955,7 @@
950955
" last_cp = tau_val\n",
951956
"plt.xlim((1, len(y)))\n",
952957
"t11 = ['1999 Initiation of Euro', '2008 Financial Crisis', '2016 UK EU Referendum']\n",
953-
"t12 = (0, soln.tau[1]-4, soln.tau[3]-4)\n",
958+
"t12 = [0, 9*12, 17*12]\n",
954959
"plt.xticks(t12, t11, size='small')\n",
955960
"plt.xlabel('Time - January 1999 to December 2018')\n",
956961
"plt.ylabel('Euros per Pound')\n",
@@ -961,11 +966,21 @@
961966
"plt.legend(handles=[vl, hl], loc='upper right')\n",
962967
"plt.show()"
963968
]
969+
},
970+
{
971+
"cell_type": "code",
972+
"execution_count": null,
973+
"metadata": {
974+
"collapsed": true
975+
},
976+
"outputs": [],
977+
"source": []
964978
}
965979
],
966980
"metadata": {
981+
"anaconda-cloud": {},
967982
"kernelspec": {
968-
"display_name": "Python 3",
983+
"display_name": "Python [default]",
969984
"language": "python",
970985
"name": "python3"
971986
},

time_series_analysis/ts_data.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[1.41, 1.47, 1.49, 1.49, 1.54, 1.56, 1.54, 1.52, 1.54, 1.56, 1.59, 1.61, 1.61, 1.67, 1.64, 1.69, 1.72, 1.61, 1.61, 1.64, 1.64, 1.69, 1.69, 1.67, 1.59, 1.59, 1.59, 1.61, 1.61, 1.69, 1.69, 1.64, 1.64, 1.64, 1.64, 1.61, 1.61, 1.67, 1.67, 1.64, 1.64, 1.56, 1.56, 1.61, 1.59, 1.61, 1.59, 1.59, 1.56, 1.54, 1.47, 1.45, 1.45, 1.41, 1.45, 1.45, 1.47, 1.43, 1.47, 1.45, 1.43, 1.47, 1.52, 1.52, 1.49, 1.52, 1.52, 1.54, 1.49, 1.45, 1.45, 1.47, 1.43, 1.45, 1.47, 1.47, 1.49, 1.49, 1.49, 1.47, 1.47, 1.49, 1.47, 1.49, 1.47, 1.49, 1.47, 1.45, 1.47, 1.47, 1.45, 1.47, 1.49, 1.49, 1.52, 1.49, 1.49, 1.52, 1.49, 1.49, 1.47, 1.49, 1.49, 1.49, 1.49, 1.45, 1.45, 1.43, 1.35, 1.33, 1.32, 1.27, 1.28, 1.28, 1.27, 1.28, 1.23, 1.27, 1.27, 1.19, 1.05, 1.12, 1.12, 1.1, 1.14, 1.16, 1.18, 1.18, 1.15, 1.1, 1.11, 1.11, 1.12, 1.15, 1.11, 1.14, 1.16, 1.2, 1.22, 1.22, 1.22, 1.15, 1.16, 1.19, 1.16, 1.18, 1.19, 1.14, 1.12, 1.15, 1.11, 1.15, 1.14, 1.18, 1.18, 1.18, 1.2, 1.2, 1.2, 1.2, 1.23, 1.25, 1.25, 1.28, 1.27, 1.27, 1.25, 1.23, 1.23, 1.16, 1.16, 1.19, 1.19, 1.18, 1.18, 1.15, 1.19, 1.2, 1.19, 1.22, 1.2, 1.22, 1.22, 1.22, 1.22, 1.23, 1.27, 1.27, 1.27, 1.3, 1.28, 1.27, 1.28, 1.33, 1.39, 1.39, 1.37, 1.41, 1.43, 1.43, 1.37, 1.37, 1.41, 1.43, 1.37, 1.33, 1.3, 1.25, 1.28, 1.3, 1.2, 1.19, 1.19, 1.15, 1.11, 1.19, 1.18, 1.18, 1.18, 1.18, 1.19, 1.15, 1.15, 1.12, 1.1, 1.14, 1.15, 1.14, 1.14, 1.15, 1.12, 1.15, 1.14, 1.15, 1.14, 1.14, 1.12, 1.14, 1.15, 1.13]

0 commit comments

Comments
 (0)