Updating old references to Matlab in Python notebooks in course modules 10 and 11

This commit is contained in:
Joseph Lizier 2025-10-17 15:10:17 +11:00
parent 31f56ad1ec
commit bf14e5b44c
6 changed files with 6 additions and 8 deletions

View File

@ -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."
]

View File

@ -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."
]

View File

@ -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",

View File

@ -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",

View File

@ -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);`"
]

View File

@ -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);`"
]