# Stroop Task

## Background Information
In a Stroop task, participants are presented with a list of words, with each word displayed in a color of ink. The participant’s task is to say out loud the *color of the ink* in which the word is printed. The task has two conditions: a congruent words condition, and an incongruent words condition. In the *congruent words* condition, the words being displayed are color words whose names match the colors in which they are printed: for example <span style="color:red;">RED</span>, <span style="color:blue;">BLUE</span>. In the *incongruent words* condition, the words displayed are color words whose names do not match the colors in which they are printed: for example <span style="color:#6aa84f;">PURPLE</span>, <span style="color:#674ea7;">ORANGE</span>. In each case, we measure the time it takes to name the ink colors in equally-sized lists. Each participant will go through and record a time from each condition.

### 1. What is our independent variable? What is our dependent variable?

Our independent variable is the test that participants take under two conditions: congruent and incongruent.

Our dependent variable is the time it takes for a participant to name the ink colors in equally-sized lists.

### 2. What is an appropriate set of hypotheses for this task? What kind of statistical test do you expect to perform? Justify your choices.
By looking at the data provided in the sample dataset, it seems like participants taken from a population are taking longer to identify the names of colors when printed in a different color (incongruent words condition). From this observation, we can come up with the following hypotheses:

Let $\mu_{incongruent}$ be defined as the mean of the population that performs the task under the incongruent condition.

Let $\mu_{congruent}$ be defined as the mean of the population that perform the task under the congruent condition.

**Null Hypothesis**: There is no statistical difference in time measurement between the two population means. It will take the same time for an individuals from the population to perform each task.
$$H_0 :\ \mu_{incongruent} = \mu_{congruent}$$


**Alternative Hypothesis**: Individuals from the population will take longer to complete the task under the incongruent words condition than with the congruent words condition.
$$H_A: \mu_{incongruent} > \mu_{congruent}$$


A **One-tailed dependent t-test** in the positive direction is expected to be performed to see if any hypotheses need to be rejected. 
* A t-test is used because:
    * The sample size is below 30.
    * The population standard deviation is not known.
* A dependent t-test is used because the two samples are dependent; the same partipants take the two tests under different conditions. 
* Only one direction is tested because we want to see if it takes longer for partipants to perform the task under the incongruent words condition.

Based on the results of our t-test we can make a inference towards how conflicting cues play a role in how fast individuals from the human population can process information. In this particular case, we will find out how a name of a color being displayed with a different color affect how long it takes to be recited.

### 3. Report some descriptive statistics regarding this dataset. Include at least one measure of central tendency and at least one measure of variability.


```python
import math
import pandas as pd
import scipy.stats as st
from IPython.display import Latex
from IPython.display import Math
from IPython.display import display

%matplotlib inline
```


```python
path = r'./stroopdata.csv'

df_stroop = pd.read_csv(path)
df_stroop
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Congruent</th>
      <th>Incongruent</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>12.079</td>
      <td>19.278</td>
    </tr>
    <tr>
      <th>1</th>
      <td>16.791</td>
      <td>18.741</td>
    </tr>
    <tr>
      <th>2</th>
      <td>9.564</td>
      <td>21.214</td>
    </tr>
    <tr>
      <th>3</th>
      <td>8.630</td>
      <td>15.687</td>
    </tr>
    <tr>
      <th>4</th>
      <td>14.669</td>
      <td>22.803</td>
    </tr>
    <tr>
      <th>5</th>
      <td>12.238</td>
      <td>20.878</td>
    </tr>
    <tr>
      <th>6</th>
      <td>14.692</td>
      <td>24.572</td>
    </tr>
    <tr>
      <th>7</th>
      <td>8.987</td>
      <td>17.394</td>
    </tr>
    <tr>
      <th>8</th>
      <td>9.401</td>
      <td>20.762</td>
    </tr>
    <tr>
      <th>9</th>
      <td>14.480</td>
      <td>26.282</td>
    </tr>
    <tr>
      <th>10</th>
      <td>22.328</td>
      <td>24.524</td>
    </tr>
    <tr>
      <th>11</th>
      <td>15.298</td>
      <td>18.644</td>
    </tr>
    <tr>
      <th>12</th>
      <td>15.073</td>
      <td>17.510</td>
    </tr>
    <tr>
      <th>13</th>
      <td>16.929</td>
      <td>20.330</td>
    </tr>
    <tr>
      <th>14</th>
      <td>18.200</td>
      <td>35.255</td>
    </tr>
    <tr>
      <th>15</th>
      <td>12.130</td>
      <td>22.158</td>
    </tr>
    <tr>
      <th>16</th>
      <td>18.495</td>
      <td>25.139</td>
    </tr>
    <tr>
      <th>17</th>
      <td>10.639</td>
      <td>20.429</td>
    </tr>
    <tr>
      <th>18</th>
      <td>11.344</td>
      <td>17.425</td>
    </tr>
    <tr>
      <th>19</th>
      <td>12.369</td>
      <td>34.288</td>
    </tr>
    <tr>
      <th>20</th>
      <td>12.944</td>
      <td>23.894</td>
    </tr>
    <tr>
      <th>21</th>
      <td>14.233</td>
      <td>17.960</td>
    </tr>
    <tr>
      <th>22</th>
      <td>19.710</td>
      <td>22.058</td>
    </tr>
    <tr>
      <th>23</th>
      <td>16.004</td>
      <td>21.157</td>
    </tr>
  </tbody>
</table>
</div>




```python
mu_congruent = round(df_stroop['Congruent'].mean(),4)
mu_incongruent = round(df_stroop['Incongruent'].mean(),4)

text = r"""
\begin{{align}}
    \mu_{{congruent}}={}\\
    \mu_{{incongruent}}={}
\end{{align}}""".format(mu_congruent, mu_incongruent)

Latex(text)
```





\begin{align}
    \mu_{congruent}=14.0511\\
    \mu_{incongruent}=22.0159
\end{align}




```python
df_stroop.plot(kind="bar")

```

### 5. Now, perform the statistical test and report your results. What is your confidence level and your critical statistic value? Do you reject the null hypothesis or fail to reject it? Come to a conclusion in terms of the experiment task. Did the results match up with your expectations?

#### Descriptive statistics for the difference between two conditions
Let $\mu_D$ be defined as the mean difference between the incongruent set and congruent set.

Let $\sigma_D$ be defined as the standard deviation of the differences between the incongruent and congruent set.


```python
df_diff = df_stroop['Incongruent']-df_stroop['Congruent']
mu_D = round(df_diff.mean(),4)
std_D = round(df_diff.std(),4)

text = r"""
        \begin{{align}}
            \mu_D = {}\\
            \sigma_D = {}\\
        \end{{align}}""".format(mu_D,std_D)

display(Latex(text))
```



        \begin{align}
            \mu_D = 7.9648\\
            \sigma_D = 4.8648\\
        \end{align}


#### Calculate the critical t value:


```python
n = df_diff.count()
df = n-1
alpha = .05
t_critical = round(st.t.ppf(1-alpha,df),3)

text = r"""t_{{critical}}=t_{{{},{}}}={}""".format(alpha,df,t_critical)
display(Math(text))
```


$$t_{critical}=t_{0.05,23}=1.714$$


#### Calculate the t value:


```python
# Calculate t
SEM = round(std_D/math.sqrt(n),4)
t = round(mu_D/SEM,3)

text = r"""t = \frac{{\mu_D}}{{SEM}} = \
           \frac{{{}}}{{{}}} = {}""".format(mu_D,SEM,t)
display(Math(text))
```


$$t = \frac{\mu_D}{SEM} =            \frac{7.9648}{0.993} = 8.021$$


#### Confidence Interval:


```python
two_tailed_t_critical = round(st.t.ppf(alpha/2,df),3)
m_error = -1*round(two_tailed_t_critical * SEM,4)


text = r"""
        \begin{{align}}
            {} \pm {}\\
            [{},{}]\\
        \end{{align}}""".format(mu_D,m_error,mu_D-m_error,mu_D+m_error)

display(Latex(text))
```



        \begin{align}
            7.9648 \pm 2.0545\\
            [5.9103,10.0193]\\
        \end{align}


Our results show that t is within the critical region, meaning:
$t > t_{critical}$. The Stroop Effect is observed with these findings. Partipants are likely to take 6 to 10 seconds longer on average to finishing the incongruent word condition compared with the congruent words condition.

We reject the null hypothesis. Based on our statistical findings we can say that the participants take longer to finish the task under the incongruent words condition. The results match up my expectations.


### 6. Optional: What do you think is responsible for the effects observed? Can you think of an alternative or similar task that would result in a similar effect? Some research about the problem will be helpful for thinking about these two questions!

There is a part of our brain that deal with recalling information given a certain stimuli. There is another part of our brain that deals with processing new information. When the information supplied from both of these parts interfere with another, there is a time delay in regards to processing the correct information.

A real life scenario of this problem is learning a new language which uses the roman alphabet. If someone knows English, but tries to learn French, then initially that person will struggle to attach different sounds to the letters that already have a sound attached to it.


```python
import IPython.display as disp
def css_styling():
    styles = open("../css/custom.css", "r").read()
    return disp.HTML(styles)
css_styling()
```




<style>
    @font-face {
        font-family: "Computer Modern";
        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunss.otf');
    }
    @font-face {
        font-family: "Computer Modern";
        font-weight: bold;
        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunsx.otf');
    }
    @font-face {
        font-family: "Computer Modern";
        font-style: oblique;
        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunsi.otf');
    }
    @font-face {
        font-family: "Computer Modern";
        font-weight: bold;
        font-style: oblique;
        src: url('http://9dbb143991406a7c655e-aa5fcb0a5a4ec34cff238a2d56ca4144.r56.cf5.rackcdn.com/cmunso.otf');
    }

    div.CodeMirror code{ /* code font */
        font-family: "Consolas", monospace;
        font-size: 10pt;
    }

    div.text_cell_render{
        font-family: Computer Modern, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
        font-size: 115%;
        padding: 0;
    }
    /* header colours and fonts */
    h1 {
        color: #444;
    }
    h2 { color: #444; }
    h3
    {
         color: #444;
         font-style: italic;
         font-weight: bold;
         font-size: 120% !important;
         margin-top: 0.6em !important;
    }
    h4
    {
        margin-top: 0.5em !important;
        color: #444;
    }
    h5 { color: #444; }
    h6 { color: #444; }

    ul {margin-top: 0em !important}
    ol {margin-top: 0em !important}
    p {margin-top: 0.4em !important}

    div.output_subarea
    {
      padding: 1em;
    }
</style>





32565de53333695a7192ad4ee35928911bc5257a
ipynb
Jupyter Notebook
P1 t test/Data_Analyst_ND_Project1.ipynb
wllmtrng/udacity_data_analyst_nanodegree
63d2d4a03b7d6d43b6730d1cc97d5ada2897e588
MIT
P1 t test/Data_Analyst_ND_Project1.ipynb
wllmtrng/udacity_data_analyst_nanodegree
63d2d4a03b7d6d43b6730d1cc97d5ada2897e588
MIT
P1 t test/Data_Analyst_ND_Project1.ipynb
wllmtrng/udacity_data_analyst_nanodegree
63d2d4a03b7d6d43b6730d1cc97d5ada2897e588
MIT
Qwen/Qwen-72B
1. YES
2. YES