Question: # 6.3 scatter plot and correlation in log scale plt.figure() plt.scatter(np.log(data[me].flatten()), np.log(data[mu].flatten())) plt.xticks([0,1,2,3],[ '10^0', '10^1', '10^2', '10^3']) plt.yticks([0,1,2,3],[ '10^0', '10^1', '10^2', '10^3']) plt.xlabel('Monthly cases of

# 6.3 scatter plot and correlation in log scale plt.figure() plt.scatter(np.log(data[me].flatten()), np.log(data[mu].flatten())) plt.xticks([0,1,2,3],[ '10^0', '10^1', '10^2', '10^3']) plt.yticks([0,1,2,3],[ '10^0', '10^1', '10^2', '10^3']) plt.xlabel('Monthly cases of ' + diseases[me]) plt.ylabel('Monthly cases of ' + diseases[mu]) plt.title('Fig 6.3: Monthly cases of %s vs %s' %(diseases[me], diseases[mu])) # compute and display Pearson correlation coefficient Spearman correlation pearson_corr, _ = stats.pearsonr(np.log(data[me].flatten()), np.log(data[mu].flatten())) spearman_corr, _ = stats.spearmanr(np.log(data[me].flatten()), np.log(data[mu].flatten())) plt.text(0.6, 0.4, f'Pearson corr: {pearson_corr:.4f}', transform=plt.gca().transAxes, fontsize=10) plt.text(0.6, 0.35, f'Spearman corr: {spearman_corr:.4f}', transform=plt.gca().transAxes, fontsize=10) plt.show() print('Pearson correlation in log space: %.4f') print('Spearman correlation in log space: %.4f ')

Fig 6.3: Monthly cases of Measles vs Mumps 103 Monthly cases of Mumps 102 Pearson corr in log space: Spearman corr in log spcace: 101 102 103 104 Monthly cases of Measles

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!