mirror of https://github.com/jlizier/jidt
150 lines
5.6 KiB
Plaintext
150 lines
5.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "fe8e1d06-f91e-430d-855b-b4f618232057",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Module 10 -- Active Information Storage -- Synthetic examples\n",
|
|
"\n",
|
|
"In this notebook, we explore the AIS in several synthetic time series.\n",
|
|
"\n",
|
|
"## 5. Active Information Storage with JIDT\n",
|
|
"\n",
|
|
"In this activity we will write some simple code to calculate AIS on sample data.\n",
|
|
"\n",
|
|
"1. Start by opening the AutoAnalyser and selecting Active Info Storage. Select a Discrete estimator, data file `2CoupledBinaryUseK2.txt`. and tick `Add stat. signif.?\"`. Click `Generate Code and Compute`.\n",
|
|
"2. Copy and paste the the generated code into the cells below.\n",
|
|
"3. Replace the loaded data in `variable` with the following line:\n",
|
|
"``` python\n",
|
|
"variable = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0];\n",
|
|
"```\n",
|
|
"This is the first example plot you tried to predict the next value of in the activity above. You can plot the data if you like with the code:\n",
|
|
"``` python\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"plt.scatter(range(1,len(variable)+1), variable, marker='x'); \n",
|
|
"plt.ylabel('x(n)'); \n",
|
|
"plt.xlabel('n'); \n",
|
|
"plt.axis([0,20,0,1.1]); \n",
|
|
"plt.grid();\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9c419f90-69df-439b-b2d2-986335b07d65",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Paste the import and JVM startup lines here:\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "31d1ff27-5047-4da2-816b-5c770176789b",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Paste the code performing the actual analysis and plotting here:\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "85cb1f19-8315-4e38-b38c-183ac26a0c27",
|
|
"metadata": {},
|
|
"source": [
|
|
"4. How much information storage did you predict for this example? Did this match the output from the code above? Do you need to change the history length $k$ parameter to be longer than the default of 1 to see the result you expect? You can use the AutoAnalyser to see the line of code to use to change the $k$ parameter to something other than its default value. Modify your code so that you can set any value for the k parameter:\n",
|
|
" * Add a line such as `k = 1;` before the estimator is constructed, then\n",
|
|
" * Change how the estimator is constructed to:\n",
|
|
"```python\n",
|
|
"calc = calcClass(2, k)\n",
|
|
"```\n",
|
|
"5. Repeat for the following examples (you can change the code in the cell above, or copy/paste and adjust in a new cell below). For these you may need to try up to `k=3` to see the information storage result that you expect:\n",
|
|
" * `variable = [0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0];`\n",
|
|
" * `variable = [0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0];`\n",
|
|
" * `variable = [0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1];`\n",
|
|
"6. For the last example, you may be interested to examine the results of the statistical significance check to see that we haven't really supplied enough data to properly conclude on a pattern of information storage."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3d3925e8-d81f-4fb2-b2a6-c16b4825c4f8",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "ed0610bb-cb0e-4b1a-b94b-888c5b3f7e3f",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 6. Local active information storage with JIDT\n",
|
|
"\n",
|
|
"Here we will continue the above activity, but examining _local_ AIS on the same sample data. The local AIS is the pointwise or local mutual information from the previous $k$ samples to the next sample.\n",
|
|
"\n",
|
|
"1. Using the second last example with `variable = [0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0];` let's compute and plot the local AIS values at each point in the time series. To do so:\n",
|
|
" * Switch your code in the cell above back to that data set, and re-run it.\n",
|
|
" * Then insert the following code into a new cell below and run it:\n",
|
|
"```python\n",
|
|
"# Pull out the local AIS values for each point in the time series:\n",
|
|
"localAISValues = calc.computeLocalFromPreviousObservations(variable);\n",
|
|
"# We only plot the local values from time index k onwards -- the AIS is undefined before this (localAISValues just fills these values with zeros)\n",
|
|
"plt.scatter(range(k+1,len(localAISValues)+1), localAISValues[k:], marker='x'); \n",
|
|
"plt.ylabel('AIS(n,k)'); \n",
|
|
"plt.xlabel('n');\n",
|
|
"plt.title('Local AIS (k = %d)' % k);\n",
|
|
"plt.axis([0,20,-0.5,2.2]); \n",
|
|
"plt.grid();\n",
|
|
"```"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e2865a32-79dc-46d8-b643-164639927464",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "d8be9cd7-cec4-4120-98a5-05d94d9d8093",
|
|
"metadata": {},
|
|
"source": [
|
|
"Explain why there is greater active information storage at some updates of the time series compared to others."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "c1988388-4dc4-490c-a3b7-192ddf45d167",
|
|
"metadata": {},
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|