data_q3['is_InAppPurcased'].value_counts()

free = data_q3.loc[data_q3['is_InAppPurcased'] == 0]
paid = data_q3.loc[data_q3['is_InAppPurcased'] == 1]
free['current_rating'].plot(kind = "density")
paid['current_rating'].plot(kind = "density")
plt.xlabel('Current Rating')
plt.legend(labels = ['free','paid'], loc='upper right')
plt.title('Distribution of current rating among free/paid apps')
plt.show()

"""
Explanation: <b>Question 3 Is there any difference in app quality for free apps with in-app purchases?</b>
End of explanation
"""


import scipy.stats

free = list(free['current_rating'])
paid = list(paid['current_rating'])

print(np.mean(free))
print(np.mean(paid))

scipy.stats.ttest_ind(free, paid, equal_var = False)

"""
Explanation: <p>First, the data set is splitted into two parts, one is app without in-app purchases and another is app with in-app purchases. Then the density plots for the two subsets are made and from the plots we can see that the current rating of paid app is generally higher than the overall rating of free app. Some specific tests are still needed to perform.</p>
End of explanation
"""


scipy.stats.f_oneway(free, paid)

"""
Explanation: <p>I perform t test here. We have two samples here, one is free apps and another is apps with in-app purchases. So I want to test whether the mean current rating for these two samples are different.</p>

<p>The null hypothesis is mean current rating for free apps and mean current rating for apps with in-app purchases are the same and the alternative hypothesis is that the mean current rating for these two samples are not the same.</p>

<p>From the result we can see that the p value is 2.5715670717150474e-38, which is smaller than 0.05, so we should reject null hypothesis at significance level 0.05, that is, we should conclude that the mean of current rating for these two samples are not the same and with in-app purchases or not do influent the rating of an app.</p>
End of explanation
"""


scipy.stats.kruskal(free, paid)

"""
Explanation: <p>I also perform one-way ANOVA test here.</p>

<p>The null hypothesis is mean current rating for free apps and mean overall rating for apps with in-app purchases are the same and the alternative hypothesis is that the mean current rating for these two samples are not the same.</p>

<p>From the result we can see that the p value is 9.7392843155192399e-37, which is smaller than 0.05, so we should reject null hypothesis at significance level 0.05, that is, we should conclude that the mean of current rating for these two samples are not the same and with in-app purchases or not do influent the rating of an app.</p>
End of explanation
"""


