document.write( "Question 1162465: Raw material used in the production of synthetic fiber is stored in a place which has no humidity control. Measurements of the relative humidity in the storage place and the moisture content of a sample of the raw material (both in percentages) on 12 days yielded the following results:
\n" );
document.write( " Humidity x 42 C5 50 4C 48 62 C1 C6 44 C9 55 48
\n" );
document.write( "Moixture content y 12 8 14 9 11 16 7 9 12 10 1C 11
\n" );
document.write( "(i) Make a scatter plot to verify that it is reasonable to assume that the regression of y on x is linear (ii) Fit a straight line by the method of least squares, (iii) Estimate the moisture content when humidity is 45%. (iv) Determine the correlation coefficient. \n" );
document.write( "
Algebra.Com's Answer #854403 by CPhill(2264) You can put this solution on YOUR website! ```python?code_reference&code_event_index=2 \n" ); document.write( "import numpy as np \n" ); document.write( "import matplotlib.pyplot as plt \n" ); document.write( "from scipy.stats import linregress\r \n" ); document.write( "\n" ); document.write( "# Data with C interpreted as 3 \n" ); document.write( "x = np.array([42, 35, 50, 43, 48, 62, 31, 36, 44, 39, 55, 48]) \n" ); document.write( "y = np.array([12, 8, 14, 9, 11, 16, 7, 9, 12, 10, 13, 11])\r \n" ); document.write( "\n" ); document.write( "# (i) Scatter plot \n" ); document.write( "plt.scatter(x, y, color='blue', label='Data Points') \n" ); document.write( "plt.xlabel('Relative Humidity x (%)') \n" ); document.write( "plt.ylabel('Moisture Content y (%)') \n" ); document.write( "plt.title('Scatter Plot of Humidity vs. Moisture Content')\r \n" ); document.write( "\n" ); document.write( "# (ii) Least Squares Fit \n" ); document.write( "slope, intercept, r_value, p_value, std_err = linregress(x, y) \n" ); document.write( "line = slope * x + intercept \n" ); document.write( "plt.plot(x, line, color='red', label=f'Fit: y={intercept:.2f} + {slope:.2f}x') \n" ); document.write( "plt.legend() \n" ); document.write( "plt.grid(True) \n" ); document.write( "plt.savefig('scatter_plot.png')\r \n" ); document.write( "\n" ); document.write( "# (iii) Estimate at x = 45% \n" ); document.write( "x_est = 45 \n" ); document.write( "y_est = intercept + slope * x_est\r \n" ); document.write( "\n" ); document.write( "# (iv) Correlation coefficient \n" ); document.write( "correlation = r_value\r \n" ); document.write( "\n" ); document.write( "print(f\"Slope (b): {slope}\") \n" ); document.write( "print(f\"Intercept (a): {intercept}\") \n" ); document.write( "print(f\"Estimate for x=45: {y_est}\") \n" ); document.write( "print(f\"Correlation coefficient (r): {correlation}\")\r \n" ); document.write( " \n" ); document.write( "\n" ); document.write( "``` \n" ); document.write( "```text?code_stdout&code_event_index=2 \n" ); document.write( "Slope (b): 0.26903206940247587 \n" ); document.write( "Intercept (a): -0.9495077492933035 \n" ); document.write( "Estimate for x=45: 11.156935373818111 \n" ); document.write( "Correlation coefficient (r): 0.9144291969589217\r \n" ); document.write( "\n" ); document.write( "```\r \n" ); document.write( "\n" ); document.write( "[image-tag: code-generated-image-0-1776522998299002780]\r \n" ); document.write( "\n" ); document.write( "To analyze the relationship between relative humidity ($x$) and moisture content ($y$), we first interpreted the characters in the data (where 'C' appeared to represent '3'). \r \n" ); document.write( "\n" ); document.write( "**The clean dataset used for analysis:** \n" ); document.write( "* **Humidity ($x$):** 42, 35, 50, 43, 48, 62, 31, 36, 44, 39, 55, 48 \n" ); document.write( "* **Moisture ($y$):** 12, 8, 14, 9, 11, 16, 7, 9, 12, 10, 13, 11\r \n" ); document.write( "\n" ); document.write( "---\r \n" ); document.write( "\n" ); document.write( "### (i) Scatter Plot \n" ); document.write( "The scatter plot shows a strong, positive linear trend. As relative humidity increases, the moisture content of the raw material also tends to increase. The points cluster closely around a straight line, making the assumption of a linear regression model very reasonable.\r \n" ); document.write( "\n" ); document.write( "### (ii) Least Squares Regression Line \n" ); document.write( "Using the method of least squares, we calculated the regression parameters: \n" ); document.write( "* **Slope ($b$):** $0.2690$ \n" ); document.write( "* **Intercept ($a$):** $-0.9495$\r \n" ); document.write( "\n" ); document.write( "The equation of the fitted straight line is: \n" ); document.write( "$$\hat{y} = -0.9495 + 0.2690x$$\r \n" ); document.write( "\n" ); document.write( "### (iii) Estimate for 45% Humidity \n" ); document.write( "To estimate the moisture content when the relative humidity is 45%, we substitute $x = 45$ into our regression equation: \n" ); document.write( "$$\hat{y} = -0.9495 + 0.2690(45)$$ \n" ); document.write( "$$\hat{y} = -0.9495 + 12.105$$ \n" ); document.write( "$$\hat{y} \approx 11.16\%$$\r \n" ); document.write( "\n" ); document.write( "**Estimated moisture content:** **11.16%**\r \n" ); document.write( "\n" ); document.write( "### (iv) Correlation Coefficient ($r$) \n" ); document.write( "The correlation coefficient measures the strength and direction of the linear relationship. \n" ); document.write( "* **$r \approx 0.9144$**\r \n" ); document.write( "\n" ); document.write( "Since $r$ is very close to $1$, it indicates a **very strong positive linear correlation** between humidity and moisture content. \n" ); document.write( " |