Commit 9602c60f authored by Chanelle Lee's avatar Chanelle Lee
Browse files

Updated test params

parent 3d0ae38c
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"[<matplotlib.lines.Line2D at 0x97bb1d0>]" "[<matplotlib.lines.Line2D at 0x22e0f4ad240>]"
] ]
}, },
"execution_count": 7, "execution_count": 7,
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"[<matplotlib.lines.Line2D at 0x9851c88>]" "[<matplotlib.lines.Line2D at 0x22e0f548f28>]"
] ]
}, },
"execution_count": 8, "execution_count": 8,
...@@ -353,7 +353,7 @@ ...@@ -353,7 +353,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 51,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -828,7 +828,7 @@ ...@@ -828,7 +828,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x5394898>" "<matplotlib.axes._subplots.AxesSubplot at 0x22e106ee1d0>"
] ]
}, },
"execution_count": 20, "execution_count": 20,
...@@ -860,7 +860,7 @@ ...@@ -860,7 +860,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.lines.Line2D at 0x9984320>" "<matplotlib.lines.Line2D at 0x22e1083ae80>"
] ]
}, },
"execution_count": 21, "execution_count": 21,
...@@ -994,31 +994,16 @@ ...@@ -994,31 +994,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 24, "execution_count": 52,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\cl15753\\AppData\\Local\\Continuum\\anaconda2\\envs\\Py3\\lib\\site-packages\\pandas\\core\\frame.py:6211: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version\n",
"of pandas will change to not sort by default.\n",
"\n",
"To accept the future behavior, pass 'sort=False'.\n",
"\n",
"To retain the current behavior and silence the warning, pass 'sort=True'.\n",
"\n",
" sort=sort)\n"
]
}
],
"source": [ "source": [
"testParams_DF = testParams_DF.append([{'sigma': row[1], 'alpha': row[2], 'chance': '10%', 'note': 'Prob_q2'} for row in df_1Ranges.itertuples()])" "testParams_DF = testParams_DF.append([{'sigma': row[1], 'alpha': row[2], 'chance': '10%', 'note': 'Prob_q2'} for row in df_1Ranges.itertuples()], sort=True)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": 53,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1030,7 +1015,7 @@ ...@@ -1030,7 +1015,7 @@
" 0.028578442773621412]" " 0.028578442773621412]"
] ]
}, },
"execution_count": 25, "execution_count": 53,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1042,7 +1027,7 @@ ...@@ -1042,7 +1027,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": 54,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1059,7 +1044,7 @@ ...@@ -1059,7 +1044,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": 55,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1073,7 +1058,7 @@ ...@@ -1073,7 +1058,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 56,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -1149,7 +1134,7 @@ ...@@ -1149,7 +1134,7 @@
"35 0.175175 0.250550 0.089228 0.021781 0.003561" "35 0.175175 0.250550 0.089228 0.021781 0.003561"
] ]
}, },
"execution_count": 28, "execution_count": 56,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -1160,16 +1145,16 @@ ...@@ -1160,16 +1145,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 29, "execution_count": 57,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.lines.Line2D at 0xb114470>" "<matplotlib.lines.Line2D at 0x22e11174400>"
] ]
}, },
"execution_count": 29, "execution_count": 57,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
}, },
...@@ -1199,7 +1184,7 @@ ...@@ -1199,7 +1184,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 30, "execution_count": 58,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1208,7 +1193,7 @@ ...@@ -1208,7 +1193,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 31, "execution_count": 59,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1217,7 +1202,7 @@ ...@@ -1217,7 +1202,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 32, "execution_count": 60,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1227,7 +1212,26 @@ ...@@ -1227,7 +1212,26 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 33, "execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [],
"source": [
"sigmas = set(testParams_DF['sigma'])\n",
"chances = [testParams_DF.loc[testParams_DF['sigma'] == sigma, 'chance'].iloc[0] for sigma in sigmas]\n",
"testParams_DF = testParams_DF.append([{'sigma': sigma, 'alpha': 0.1, 'chance': chances[i], 'note': 'control'}\n",
" for i, sigma in enumerate(sigmas)])"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": { "metadata": {
"scrolled": true "scrolled": true
}, },
...@@ -1236,23 +1240,105 @@ ...@@ -1236,23 +1240,105 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
" alpha chance note sigma\n", " alpha chance note \\\n",
"0 0.375167 10.0 Prob_q2 0.370370\n", "0 0.375167 10% Prob_q2 \n",
"1 0.337069 10.0 Prob_q2 0.280280\n", "1 0.337069 10% Prob_q2 \n",
"2 0.262259 10.0 Prob_q2 0.185185\n", "2 0.262259 10% Prob_q2 \n",
"3 0.107618 10.0 Prob_q2 0.095095\n", "3 0.107618 10% Prob_q2 \n",
"0 0.227216 10.0 mean 0.370370\n", "0 0.227216 10% mean \n",
"1 0.171782 10.0 mean 0.280280\n", "1 0.171782 10% mean \n",
"2 0.099345 10.0 mean 0.185185\n", "2 0.099345 10% mean \n",
"3 0.028578 10.0 mean 0.095095\n", "3 0.028578 10% mean \n",
"0 0.433217 25.0 Prob_q2 0.700701\n", "0 0.433217 25% Prob_q2 \n",
"1 0.411280 25.0 Prob_q2 0.525526\n", "1 0.411280 25% Prob_q2 \n",
"2 0.368292 25.0 Prob_q2 0.350350\n", "2 0.368292 25% Prob_q2 \n",
"3 0.250550 25.0 Prob_q2 0.175175\n", "3 0.250550 25% Prob_q2 \n",
"0 0.339747 25.0 mean 0.700701\n", "0 0.339747 25% mean \n",
"1 0.293395 25.0 mean 0.525526\n", "1 0.293395 25% mean \n",
"2 0.216131 25.0 mean 0.350350\n", "2 0.216131 25% mean \n",
"3 0.091280 25.0 mean 0.175175\n" "3 0.091280 25% mean \n",
"0 0.100000 0 10%\n",
"0 10%\n",
"Name: chance, dtype: object control \n",
"1 0.100000 0 25%\n",
"0 25%\n",
"Name: chance, dtype: object control \n",
"2 0.100000 3 10%\n",
"3 10%\n",
"Name: chance, dtype: object control \n",
"3 0.100000 1 10%\n",
"1 10%\n",
"Name: chance, dtype: object control \n",
"4 0.100000 2 10%\n",
"2 10%\n",
"Name: chance, dtype: object control \n",
"5 0.100000 1 25%\n",
"1 25%\n",
"Name: chance, dtype: object control \n",
"6 0.100000 2 25%\n",
"2 25%\n",
"Name: chance, dtype: object control \n",
"7 0.100000 3 25%\n",
"3 25%\n",
"Name: chance, dtype: object control \n",
"0 0.433217 25% Prob_q2 \n",
"1 0.411280 25% Prob_q2 \n",
"2 0.368292 25% Prob_q2 \n",
"3 0.250550 25% Prob_q2 \n",
"0 0.339747 25% mean \n",
"1 0.293395 25% mean \n",
"2 0.216131 25% mean \n",
"3 0.091280 25% mean \n",
"0 0.100000 0 ... control \n",
"1 0.100000 0 ... control \n",
"2 0.100000 3 ... control \n",
"3 0.100000 1 ... control \n",
"4 0.100000 2 ... control \n",
"5 0.100000 1 ... control \n",
"6 0.100000 2 ... control \n",
"7 0.100000 3 ... control \n",
"\n",
" sigma \n",
"0 0.370370 \n",
"1 0.280280 \n",
"2 0.185185 \n",
"3 0.095095 \n",
"0 0.370370 \n",
"1 0.280280 \n",
"2 0.185185 \n",
"3 0.095095 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.370370 \n",
"1 0.700701 \n",
"2 0.095095 \n",
"3 0.280280 \n",
"4 0.185185 \n",
"5 0.525526 \n",
"6 0.350350 \n",
"7 0.175175 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.700701 \n",
"1 0.525526 \n",
"2 0.350350 \n",
"3 0.175175 \n",
"0 0.370370 \n",
"1 0.700701 \n",
"2 0.095095 \n",
"3 0.280280 \n",
"4 0.185185 \n",
"5 0.525526 \n",
"6 0.350350 \n",
"7 0.175175 \n"
] ]
} }
], ],
...@@ -1262,34 +1348,9 @@ ...@@ -1262,34 +1348,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
" alpha chance note sigma\n",
"paramSet \n",
"1 0.375167 10.0 Prob_q2 0.370370\n",
"2 0.337069 10.0 Prob_q2 0.280280\n",
"3 0.262259 10.0 Prob_q2 0.185185\n",
"4 0.107618 10.0 Prob_q2 0.095095\n",
"5 0.227216 10.0 mean 0.370370\n",
"6 0.171782 10.0 mean 0.280280\n",
"7 0.099345 10.0 mean 0.185185\n",
"8 0.028578 10.0 mean 0.095095\n",
"9 0.433217 25.0 Prob_q2 0.700701\n",
"10 0.411280 25.0 Prob_q2 0.525526\n",
"11 0.368292 25.0 Prob_q2 0.350350\n",
"12 0.250550 25.0 Prob_q2 0.175175\n",
"13 0.339747 25.0 mean 0.700701\n",
"14 0.293395 25.0 mean 0.525526\n",
"15 0.216131 25.0 mean 0.350350\n",
"16 0.091280 25.0 mean 0.175175\n"
]
}
],
"source": [ "source": [
"testParams_DF['paramSet'] = range(1, len(testParams_DF)+1)\n", "testParams_DF['paramSet'] = range(1, len(testParams_DF)+1)\n",
"testParams_DF = testParams_DF.set_index('paramSet')\n", "testParams_DF = testParams_DF.set_index('paramSet')\n",
...@@ -1298,7 +1359,7 @@ ...@@ -1298,7 +1359,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 35, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -1307,44 +1368,65 @@ ...@@ -1307,44 +1368,65 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 36, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"0.37037046296296294"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"testParams_DF.iloc[0]['sigma']" "testParams_DF.iloc[0]['sigma']"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 37, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"set(testParams_DF.index.values) " "set(testParams_DF.index.values) "
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"testParams_DF.index.values"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"testParams_DF.iloc[15]['sigma']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def convert_paramSetNum(filePath):\n",
" df = pd.read_csv(filePath, names=['time', 'paramSet', 'simNum', 'timestep', 'agent', 'iteration', 'option', 'belief'])\n",
" df['paramSet'] +=1\n",
" df.to_csv(filePath)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os, glob\n",
"path = 'Results/'\n",
"all_files = glob.glob(os.path.join(path, \"botSim_beliefs_[0-9].csv\")) \n",
"for f in all_files:\n",
" convert_paramSetNum(f)"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
...@@ -1369,7 +1451,7 @@ ...@@ -1369,7 +1451,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.1" "version": "3.7.2"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import numpy as np import numpy as np
import scipy import scipy
import seaborn as sns import seaborn as sns
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import pandas as pd import pandas as pd
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Analysis of the probability of confusing qualities for different values of sigma # Analysis of the probability of confusing qualities for different values of sigma
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
First need the pdf and cdf of the normal distributions which will represent the noise around each of the quality values First need the pdf and cdf of the normal distributions which will represent the noise around each of the quality values
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def f(x, mu, s): def f(x, mu, s):
return scipy.stats.norm.pdf(x, loc=mu, scale=s) return scipy.stats.norm.pdf(x, loc=mu, scale=s)
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def F(x, mu, s): def F(x, mu, s):
return scipy.stats.norm.cdf(x, loc=mu, scale=s) return scipy.stats.norm.cdf(x, loc=mu, scale=s)
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
Qualities are set in the interval (0,1) and equally spaced Qualities are set in the interval (0,1) and equally spaced
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
n = 5 n = 5
qualities = {i: i/(n+1) for i in range(1, (n+1))} qualities = {i: i/(n+1) for i in range(1, (n+1))}
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
def integrand(x, i, j, s): def integrand(x, i, j, s):
return f(x, qualities[i], s)*F(x, qualities[j], s) return f(x, qualities[i], s)*F(x, qualities[j], s)
def probConfusion(i, j, s): def probConfusion(i, j, s):
return scipy.integrate.quad(integrand, -np.inf, np.inf, args=(i, j, s)) return scipy.integrate.quad(integrand, -np.inf, np.inf, args=(i, j, s))
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
s0 = 0.0000001 s0 = 0.0000001
sf = 100 sf = 100
ss = np.linspace(s0, sf, 1000) ss = np.linspace(s0, sf, 1000)
confusions = [probConfusion(1, 2, s)[0] for s in ss] confusions = [probConfusion(1, 2, s)[0] for s in ss]
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
plt.plot(ss, confusions) plt.plot(ss, confusions)
``` ```
%%%% Output: execute_result %%%% Output: execute_result
[<matplotlib.lines.Line2D at 0x97bb1d0>] [<matplotlib.lines.Line2D at 0x22e0f4ad240>]
%%%% Output: display_data %%%% Output: display_data
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
ss = np.linspace(0.0000001, 10, 1000) ss = np.linspace(0.0000001, 10, 1000)
confusions = [probConfusion(1, 2, s)[0] for s in ss] confusions = [probConfusion(1, 2, s)[0] for s in ss]
plt.plot(ss, confusions) plt.plot(ss, confusions)
``` ```
%%%% Output: execute_result %%%% Output: execute_result
[<matplotlib.lines.Line2D at 0x9851c88>] [<matplotlib.lines.Line2D at 0x22e0f548f28>]
%%%% Output: display_data %%%% Output: display_data
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
ss = np.linspace(0.0000001, 10, 1000) ss = np.linspace(0.0000001, 10, 1000)
confusions = [[probConfusion(1, j, s)[0] for s in ss] for j in [2, 3, 4, 5]] confusions = [[probConfusion(1, j, s)[0] for s in ss] for j in [2, 3, 4, 5]]
for confusion in confusions: for confusion in confusions:
plt.plot(ss, confusion) plt.plot(ss, confusion)
``` ```
%%%% Output: display_data %%%% Output: display_data