From bf14e5b44cb6cd79bb4fd5c7f3e8e92a8b854fc3 Mon Sep 17 00:00:00 2001 From: Joseph Lizier Date: Fri, 17 Oct 2025 15:10:17 +1100 Subject: [PATCH] Updating old references to Matlab in Python notebooks in course modules 10 and 11 --- course/Module10-InformationStorage/AISInCellularAutomata.ipynb | 2 +- .../AISInCellularAutomata_Solutions.ipynb | 2 +- course/Module10-InformationStorage/AISSyntheticExamples.ipynb | 3 +-- .../AISSyntheticExamples_Solutions.ipynb | 3 +-- .../HeartbeatProcess/heartBeatProcess.ipynb | 2 +- .../HeartbeatProcess/heartBeatProcess_Solutions.ipynb | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/course/Module10-InformationStorage/AISInCellularAutomata.ipynb b/course/Module10-InformationStorage/AISInCellularAutomata.ipynb index 473aa00..3af10d2 100644 --- a/course/Module10-InformationStorage/AISInCellularAutomata.ipynb +++ b/course/Module10-InformationStorage/AISInCellularAutomata.ipynb @@ -82,7 +82,7 @@ " 1. Add a loop (after loading in the data) over the rest of the calculation, looping over values of `k` from 1 to 20.\n", " 2. Supply your new value of k to the JIDT estimator. To see how if you're not sure, go back to the AutoAnalyser, change the `k` parameter, generate the code and see where the new value is inserted.\n", " 3. Change the print statement for your results to include `k` as well.\n", - " 4. Now, the AIS discrete estimator does not include bias correction, so we'll do this manually. Go back to the AutoAnalyser, click the checkbox for `Add stat signif.?` and `analytically?` and generate new code. Go to the Matlab tab and copy the code for step 6 into the Matlab code file you are working on. It should go after where you compute the result. Then, after the analytic surrogate distribution is returned in the object `measDist`, add a line to retrieve the bias via: `bias = measDist.getMeanOfDistribution();`\n", + " 4. Now, the AIS discrete estimator does not include bias correction, so we'll do this manually. Go back to the AutoAnalyser, click the checkbox for `Add stat signif.?` and `analytically?` and generate new code. Go to the Python tab and copy the code for step 6 into the cell below. It should go after where you compute the result. Then, after the analytic surrogate distribution is returned in the object `measDist`, add a line to retrieve the bias via: `bias = measDist.getMeanOfDistribution();`\n", " 5. Now, store all of the computed results and bias values in an array for each value of `k`, and generate the bias-corrected AIS values (`= results - bias`).\n", " 6. Plot the raw computed result, the bias and bias corrected values versus `k`. Identify the optimal value of `k` to use from the maximum bias-corrected AIS. Notice how the bias rises quickly after this, indicating the onset of _undersampling_ for large `k`, with respect to the given number of samples. My result is **k=15**, but statistical fluctuations in your data set could change that slightly." ] diff --git a/course/Module10-InformationStorage/AISInCellularAutomata_Solutions.ipynb b/course/Module10-InformationStorage/AISInCellularAutomata_Solutions.ipynb index 1952768..3fd0619 100644 --- a/course/Module10-InformationStorage/AISInCellularAutomata_Solutions.ipynb +++ b/course/Module10-InformationStorage/AISInCellularAutomata_Solutions.ipynb @@ -10170,7 +10170,7 @@ " 1. Add a loop (after loading in the data) over the rest of the calculation, looping over values of `k` from 1 to 20.\n", " 2. Supply your new value of k to the JIDT estimator. To see how if you're not sure, go back to the AutoAnalyser, change the `k` parameter, generate the code and see where the new value is inserted.\n", " 3. Change the print statement for your results to include `k` as well.\n", - " 4. Now, the AIS discrete estimator does not include bias correction, so we'll do this manually. Go back to the AutoAnalyser, click the checkbox for `Add stat signif.?` and `analytically?` and generate new code. Go to the Matlab tab and copy the code for step 6 into the Matlab code file you are working on. It should go after where you compute the result. Then, after the analytic surrogate distribution is returned in the object `measDist`, add a line to retrieve the bias via: `bias = measDist.getMeanOfDistribution();`\n", + " 4. Now, the AIS discrete estimator does not include bias correction, so we'll do this manually. Go back to the AutoAnalyser, click the checkbox for `Add stat signif.?` and `analytically?` and generate new code. Go to the Python tab and copy the code for step 6 into the cell below. It should go after where you compute the result. Then, after the analytic surrogate distribution is returned in the object `measDist`, add a line to retrieve the bias via: `bias = measDist.getMeanOfDistribution();`\n", " 5. Now, store all of the computed results and bias values in an array for each value of `k`, and generate the bias-corrected AIS values (`= results - bias`).\n", " 6. Plot the raw computed result, the bias and bias corrected values versus `k`. Identify the optimal value of `k` to use from the maximum bias-corrected AIS. Notice how the bias rises quickly after this, indicating the onset of _undersampling_ for large `k`, with respect to the given number of samples. My result is **k=15**, but statistical fluctuations in your data set could change that slightly." ] diff --git a/course/Module10-InformationStorage/AISSyntheticExamples.ipynb b/course/Module10-InformationStorage/AISSyntheticExamples.ipynb index 12a33b1..4d85767 100644 --- a/course/Module10-InformationStorage/AISSyntheticExamples.ipynb +++ b/course/Module10-InformationStorage/AISSyntheticExamples.ipynb @@ -92,9 +92,8 @@ "```python\n", "# Pull out the local AIS values for each point in the time series:\n", "localAISValues = calc.computeLocalFromPreviousObservations(variable);\n", - "figure(2);\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:end], marker='x'); \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", diff --git a/course/Module10-InformationStorage/AISSyntheticExamples_Solutions.ipynb b/course/Module10-InformationStorage/AISSyntheticExamples_Solutions.ipynb index 24e074c..7abc667 100644 --- a/course/Module10-InformationStorage/AISSyntheticExamples_Solutions.ipynb +++ b/course/Module10-InformationStorage/AISSyntheticExamples_Solutions.ipynb @@ -202,9 +202,8 @@ "```python\n", "# Pull out the local AIS values for each point in the time series:\n", "localAISValues = calc.computeLocalFromPreviousObservations(variable);\n", - "figure(2);\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:end], marker='x'); \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", diff --git a/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess.ipynb b/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess.ipynb index 528c630..348a73e 100644 --- a/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess.ipynb +++ b/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess.ipynb @@ -166,7 +166,7 @@ "metadata": {}, "source": [ "5. Replace the code at step 0 where the data file is loaded with the line we ran above to generate the heartbeat data sample: `data = generateHeartbeatMessages(0.05, 0.2, 100000);` (or you can load a saved sample data file as an alternative)\n", - "6. Run your Matlab script to check that it computes an average TE ok -- the result should be close to the theoretical value of 0.3735 bits for this large data sample.\n", + "6. Run your code above to check that it computes an average TE ok -- the result should be close to the theoretical value of 0.3735 bits for this large data sample.\n", " * Is this value statistically significant? (_Challenge_: can you check this?)\n", "7. In the next code cell, add the following code to compute local TE at each time step: `locals = calc.computeLocalFromPreviousObservations(source, destination);`" ] diff --git a/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess_Solutions.ipynb b/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess_Solutions.ipynb index 339df76..fbd32ed 100644 --- a/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess_Solutions.ipynb +++ b/course/Module11-InformationTransfer/HeartbeatProcess/heartBeatProcess_Solutions.ipynb @@ -222,7 +222,7 @@ "metadata": {}, "source": [ "5. Replace the code at step 0 where the data file is loaded with the line we ran above to generate the heartbeat data sample: `data = generateHeartbeatMessages(0.05, 0.2, 100000);` (or you can load a saved sample data file as an alternative)\n", - "6. Run your Matlab script to check that it computes an average TE ok -- the result should be close to the theoretical value of 0.3735 bits for this large data sample.\n", + "6. Run your code above to check that it computes an average TE ok -- the result should be close to the theoretical value of 0.3735 bits for this large data sample.\n", " * Is this value statistically significant? (_Challenge_: can you check this?)\n", "7. In the next code cell, add the following code to compute local TE at each time step: `locals = calc.computeLocalFromPreviousObservations(source, destination);`" ]