Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Correlation and Trend Analysis | Data Analysis for Engineers
Python for Engineers

bookCorrelation and Trend Analysis

Deslize para mostrar o menu

Understanding the relationship between two variables is a key part of engineering analysis. Correlation is a statistical measure that describes how closely two variables move together. For example, in many engineering systems, you might want to know if there is a relationship between temperature and pressure readings in a closed vessel. If temperature increases, does pressure also increase? Quantifying this relationship helps you make informed decisions and diagnose system behavior.

12345678910
import numpy as np # Example temperature (in Celsius) and pressure (in kPa) readings from a system temperature = [20, 22, 25, 27, 30, 32, 35] pressure = [101, 104, 108, 110, 115, 118, 121] # Calculate the Pearson correlation coefficient corr_matrix = np.corrcoef(temperature, pressure) correlation_coefficient = corr_matrix[0, 1] print(f"Correlation coefficient: {correlation_coefficient:.2f}")
copy

The output from the previous calculation gives you a correlation coefficient, which always ranges from -1 to 1. A value close to 1 means a strong positive relationship: as temperature increases, pressure tends to increase as well. If the coefficient is close to -1, it indicates a strong negative relationship: as one variable increases, the other decreases. A coefficient near 0 means there is little or no linear relationship between the variables. In the temperature and pressure example, a coefficient near 1 suggests that increases in temperature are closely linked to increases in pressure, which is consistent with the behavior of gases in closed systems.

1234567891011
import matplotlib.pyplot as plt temperature = [20, 22, 25, 27, 30, 32, 35] pressure = [101, 104, 108, 110, 115, 118, 121] plt.scatter(temperature, pressure, color="blue") plt.title("Temperature vs. Pressure") plt.xlabel("Temperature (°C)") plt.ylabel("Pressure (kPa)") plt.grid(True) plt.show()
copy

1. What does a correlation coefficient close to 1 indicate?

2. How can engineers use correlation analysis in system diagnostics?

3. Which numpy function computes the correlation coefficient?

question mark

What does a correlation coefficient close to 1 indicate?

Selecione a resposta correta

question mark

How can engineers use correlation analysis in system diagnostics?

Selecione a resposta correta

question mark

Which numpy function computes the correlation coefficient?

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 6

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Seção 1. Capítulo 6
some-alt