<jupyter_start><jupyter_text>Analyzing the Stroop EffectPerform the analysis in the space below. Remember to follow [the instructions](https://docs.google.com/document/d/1-OkpZLjG_kX9J6LIQ5IltsqMzVWjh36QpnP2RYpVdPU/pub?embedded=True) and review the [project rubric](https://review.udacity.com/!/rubrics/71/view) before submitting. Once you've completed the analysis and write-up, download this file as a PDF or HTML file, upload that PDF/HTML into the workspace here (click on the orange Jupyter icon in the upper left then Upload), then use the Submit Project button at the bottom of this page. This will create a zip file containing both this .ipynb doc and the PDF/HTML doc that will be submitted for your project.(1) What is the independent variable? What is the dependent variable? The *independent variable* is word-color congruency (binary: congruent/incongruent), and the *dependent variable* is the reaction time, or time taken to name the color (continuous). (2) What is an appropriate set of hypotheses for this task? Specify your null and alternative hypotheses, and clearly define any notation used. Justify your choices. The mean reaction time of the population in the *congruent* condition is $μ_c$, while the mean reaction time of the population in the *incongruent* condition is $μ_i$.  *p* signifies the probability that a difference of the corresponding magnitude (or greater) between the two conditions would be found, if the null hypothesis were indeed true.**Null hypothesis**: There is no statistically significant difference (*p*$\geq$0.05) in reaction times between congruent and incongruent words.  $H_0$: $μ_c$ = $μ_i$.**Alternative hypothesis**: There is a statistically significant difference (*p*<0.05) in reaction times between congruent and incongruent words. $H_1$: $μ_c$ $\neq$ $μ_i$.I chose the null hypothesis due to the fact that the default null hypothesis is that there is no (statistically significant) difference between groups.  Since $μ_i$ can differ from $μ_c$ in either direction (significantly larger, or significantly smaller), I do not consider a directional hypothesis appropriate in this case.  To note, however, from a theoretical standpoint I might predict, based on the relative difficulty of completing the *incongruent* task, that $μ_i$ > $μ_c$, in which case a directional alternative hypothesis might be approriate.In this case, assuming the difference between the conditions is roughly normally distributed, and a non-directional alternative hypothesis, a two-tailed paired t-test (given the presence of repeated paired observations) would be appropriate.  An independent samples t-test, given that the samples are *not* independent, would not be appropriate.  The paired t-test assumes a normal distribution of (paired) differences between the two groups, and the minimum sample size for the paired t-test is 2 pairs, although in practice this would in almost all cases be considered an insufficient sample size.I chose the t-test instead of the z-test because the paired z-test is only appropriate when the standard deviation of populatation differences is known, and typically used for larger sample sizes ($\geq$30). (3) Report some descriptive statistics regarding this dataset. Include at least one measure of central tendency and at least one measure of variability. The name of the data file is 'stroopdata.csv'.<jupyter_code>import pandas as pd
import scipy.stats as stats
import matplotlib.pyplot as plot
import numpy as np

data = pd.read_csv("stroopdata.csv")
data.describe()<jupyter_output><empty_output><jupyter_text>In both conditions respectively, the mean and the median (50th percentile) are numerically similar to each other, although the mean is higher than the median in the *incongruent* condition, suggesting that the distribution of values may be somewhat skewed towards higher values (*congruent*: 14.05 vs. 14.36; *incongruent*: 22.02 vs. 21.02).  The variability (standard deviation) in the *incongruent* condition is slightly higher.  Overall, the reaction times in the *incongruent* condition seem higher than those in the *congruent* condition. (4) Provide one or two visualizations that show the distribution of the sample data. Write one or two sentences noting what you observe about the plot or plots.<jupyter_code>boxplot=data.boxplot()
boxplot.set_ylabel('Reaction Times')
boxplot.set_title('Congruent vs. Incongruent Reaction Times (Boxplot)')
plot.show()

density = data.plot(kind='kde')
density.set_xlabel('Reaction Times')
density.set_title('Congruent vs. Incongruent Reaction Times (Density)')
plot.show()

difference = data['Incongruent']-data['Congruent']
diff_density = difference.plot(kind='kde')
diff_density.set_xlabel('Reaction Times')
diff_density.set_title('Difference between Reaction Times (Density)')
plot.show()<jupyter_output><empty_output><jupyter_text>The median is higher in the *incongruent* condition, and the distributions of values only partially overlap.  There are slightly more outliers in the "incongruent" condition, suggesting that some participants find the *incongruent* condition particularly difficult / that there is more individual variability (or possibly some error in data gathering, but the values are not so extreme that there is reason to suspect this).In the density plots, it can also be seen that while the *congruent* and *incongruent* distributions overlap, they are clearly distinct, with overall higher values in the latter condition.  The *incongruent* distribution may also be slightly skewed to the right, depending on how one treats the outliers (this would likely be more clear if more data was collected).  However, overall, the difference between the two conditions appears to be normally distributed. (5)  Now, perform the statistical test and report your results. What is your confidence level or Type I error associated with your test? What is your conclusion regarding the hypotheses you set up? Did the results match up with your expectations? **Hint:**  Think about what is being measured on each individual, and what statistic best captures how an individual reacts in each environment.<jupyter_code>print("T-statistic:",round(stats.ttest_rel(data["Incongruent"],data["Congruent"])[0],3),"; p-value:",round(stats.ttest_rel(data["Congruent"],data["Incongruent"])[1],10),"; df:",(len(data)-1),"; confidence interval:",round(np.mean(difference),3),"+/-",round(2.069*(np.std(difference)/(23**(1/2))),3))<jupyter_output>T-statistic: 8.021 ; p-value: 4.1e-08 ; df: 23 ; confidence interval: 7.965 +/- 2.055
{'fraction_non_alphanumeric': 0.07653605732581187, 'fraction_numerical': 0.011739594450373533, 'mean_word_length': 5.673448626653102, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '320735', 'license': 'MIT', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1664, 'n_words': 835, 'path': 'perceptual-phenomenon/Test a Perceptual Phenomenon.ipynb', 'repo_name': 'eskrav/udacity-data-analyst', 'size': '6559'}