mirror of
https://github.com/ION606/COGMOD-HWI.git
synced 2026-05-14 22:16:57 +00:00
hw3 code
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
+123
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## HW3 Problem 3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "ModuleNotFoundError",
|
||||
"evalue": "No module named 'numpy'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[1], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mnumpy\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01mplt\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# Baseline parameters\u001b[39;00m\n",
|
||||
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'numpy'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"\n",
|
||||
"# Baseline parameters\n",
|
||||
"a = 2.0\n",
|
||||
"beta = 0.5\n",
|
||||
"tau = 0.5\n",
|
||||
"scale = 1.0\n",
|
||||
"max_time = 10.0\n",
|
||||
"dt = 1e-3\n",
|
||||
"num_sims = 2000\n",
|
||||
"\n",
|
||||
"# Vary drift rate\n",
|
||||
"v_values = np.linspace(0.5, 1.5, 25)\n",
|
||||
"mean_rt_upper = []\n",
|
||||
"mean_rt_lower = []\n",
|
||||
"\n",
|
||||
"for v in v_values:\n",
|
||||
" data = simulate_diffusion_n(num_sims, v, a, beta, tau, dt, scale, max_time)\n",
|
||||
" mean_rt_upper.append(data[data[:, 1] == 1, 0].mean())\n",
|
||||
" mean_rt_lower.append(data[data[:, 1] == 0, 0].mean())\n",
|
||||
"\n",
|
||||
"# Plot results\n",
|
||||
"plt.figure(figsize=(8, 6))\n",
|
||||
"plt.plot(v_values, mean_rt_upper, label='Upper Boundary (Correct)', color='maroon')\n",
|
||||
"plt.plot(v_values, mean_rt_lower, label='Lower Boundary (Incorrect)', color='gray')\n",
|
||||
"plt.xlabel('Drift Rate (v)')\n",
|
||||
"plt.ylabel('Mean Response Time (s)')\n",
|
||||
"plt.legend()\n",
|
||||
"plt.title('Effect of Drift Rate on Mean RTs')\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Vary boundary separation (a)\n",
|
||||
"a_values = np.linspace(1.0, 3.0, 25)\n",
|
||||
"mean_rt_upper = []\n",
|
||||
"mean_rt_lower = []\n",
|
||||
"std_rt_upper = []\n",
|
||||
"std_rt_lower = []\n",
|
||||
"\n",
|
||||
"for a in a_values:\n",
|
||||
" data = simulate_diffusion_n(num_sims, v, a, beta, tau, dt, scale, max_time)\n",
|
||||
" mean_rt_upper.append(data[data[:, 1] == 1, 0].mean())\n",
|
||||
" mean_rt_lower.append(data[data[:, 1] == 0, 0].mean())\n",
|
||||
" std_rt_upper.append(data[data[:, 1] == 1, 0].std())\n",
|
||||
" std_rt_lower.append(data[data[:, 1] == 0, 0].std())\n",
|
||||
"\n",
|
||||
"# Plot results\n",
|
||||
"plt.figure(figsize=(12, 6))\n",
|
||||
"plt.subplot(1, 2, 1)\n",
|
||||
"plt.plot(a_values, mean_rt_upper, label='Upper Boundary (Correct)', color='maroon')\n",
|
||||
"plt.plot(a_values, mean_rt_lower, label='Lower Boundary (Incorrect)', color='gray')\n",
|
||||
"plt.xlabel('Boundary Separation (a)')\n",
|
||||
"plt.ylabel('Mean Response Time (s)')\n",
|
||||
"plt.legend()\n",
|
||||
"\n",
|
||||
"plt.subplot(1, 2, 2)\n",
|
||||
"plt.plot(a_values, std_rt_upper, label='Upper Boundary (Correct)', color='maroon')\n",
|
||||
"plt.plot(a_values, std_rt_lower, label='Lower Boundary (Incorrect)', color='gray')\n",
|
||||
"plt.xlabel('Boundary Separation (a)')\n",
|
||||
"plt.ylabel('Standard Deviation of RT (s)')\n",
|
||||
"plt.legend()\n",
|
||||
"\n",
|
||||
"plt.suptitle('Effect of Boundary Separation on RT Distributions')\n",
|
||||
"plt.show()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"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.13.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user