Bird
0
0

Which code correctly computes the Pearson correlation and interprets a strong positive relationship?

hard📝 Application Q15 of 15
SciPy - Statistical Tests
You have two variables: temperature (in Celsius) and ice cream sales. You want to check if higher temperature relates to higher sales. Which code correctly computes the Pearson correlation and interprets a strong positive relationship?
Afrom scipy.stats import pearsonr corr, p = pearsonr(temp, sales) if p > 0.7: print('Strong positive correlation')
Bfrom scipy.stats import pearsonr corr, p = pearsonr(temp, sales) if corr > 0.7: print('Strong positive correlation')
Cfrom scipy.stats import pearsonr corr, p = pearsonr(temp, sales) if corr < -0.7: print('Strong positive correlation')
Dfrom scipy.stats import pearsonr corr, p = pearsonr(temp, sales) if abs(corr) < 0.3: print('Strong positive correlation')
Step-by-Step Solution
Solution:
  1. Step 1: Calculate Pearson correlation

    Use pearsonr to get correlation coefficient and p-value between temperature and sales.
  2. Step 2: Interpret correlation coefficient

    A strong positive correlation means corr > 0.7. Checking p-value > 0.7 or negative corr is incorrect.
  3. Final Answer:

    from scipy.stats import pearsonr corr, p = pearsonr(temp, sales) if corr > 0.7: print('Strong positive correlation') -> Option B
  4. Quick Check:

    Strong positive correlation if corr > 0.7 [OK]
Quick Trick: Check corr > 0.7 for strong positive relation [OK]
Common Mistakes:
MISTAKES
  • Using p-value instead of correlation coefficient
  • Checking for negative correlation for positive relation
  • Using absolute value less than threshold incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes