Distribución normal
Ejercicio 1
i. La altura promedio de 500 personas es 1.70cm con una desviación estándar de 9cm, asumiendo que los datos han sido distribuidos normalmente, determina.
(a) el número de personas que probablemente tengan alturas entre 150cm y 195cm.
(b) el número de personas que tienen alturas menores a 165cm.
(c) cuantas personas tienen alturas mayores a 194cm
Programa echo en Python
import scipy.stats as stats
def calculate_probability(mean, std_dev, lower_bound, upper_bound):
"""
Calculate the probability of a normal distribution between two values.
Args:
mean (float): The mean of the normal distribution.
std_dev (float): The standard deviation of the normal distribution.
lower_bound (float): The lower bound of the range.
upper_bound (float): The upper bound of the range.
Returns:
float: The probability of values falling between the lower and upper bounds.
"""
z_lower = (lower_bound - mean) / std_dev
z_upper = (upper_bound - mean) / std_dev
probability = stats.norm.cdf(z_upper) - stats.norm.cdf(z_lower)
return probability
# Given data
mean_height = 170 # Mean height in cm
std_dev_height = 9 # Standard deviation in cm
# (a) Number of people with heights between 150cm and 195cm
prob_between_150_195 = calculate_probability(mean_height, std_dev_height, 150, 195)
num_people_between_150_195 = prob_between_150_195 * 500
# (b) Number of people with heights less than 165cm
prob_less_than_165 = calculate_probability(mean_height, std_dev_height, -float('inf'), 165)
num_people_less_than_165 = prob_less_than_165 * 500
# (c) Number of people with heights greater than 194cm
prob_greater_than_194 = 1 - calculate_probability(mean_height, std_dev_height, -float('inf'), 194)
num_people_greater_than_194 = prob_greater_than_194 * 500
print(f"Number of people with heights between 150cm and 195cm: {num_people_between_150_195}")
print(f"Number of people with heights less than 165cm: {num_people_less_than_165}")
print(f"Number of people with heights greater than 194cm: {num_people_greater_than_194}")
Ejercicio 2
. Un lote de 1500 botellas de limonada tiene un contenido promedio de 753 ml y el estándar, la desviación del contenido es de 1,8 ml. Si los datos de los volumenes contenidos se distribuyen normalmente, determinar.
(a) La cantidad de botellas que probablemente contengan menos de 750 ml
(b) La cantidad de botellas que probablemente contengan entre 751 y 754 ml.
(e) La cantidad de botellas que probablemente contengan más de 757 ml
(d) La cantidad de botellas que probablemente contengan entre 750 y 751 ml
Programa echo en Python
import scipy.stats as stats
def calcular_probabilidades_botellas():
# Datos del problema
promedio = 753 # ml
desviacion_estandar = 1.8 # ml
total_botellas = 1500
# Calcular la probabilidad usando la distribución normal
prob_menos_750 = stats.norm.cdf(750, promedio, desviacion_estandar)
prob_entre_751_754 = stats.norm.cdf(754, promedio, desviacion_estandar) - stats.norm.cdf(751, promedio, desviacion_estandar)
prob_mas_757 = 1 - stats.norm.cdf(757, promedio, desviacion_estandar)
prob_entre_750_751 = stats.norm.cdf(751, promedio, desviacion_estandar) - stats.norm.cdf(750, promedio, desviacion_estandar)
# Calcular la cantidad de botellas para cada probabilidad
botellas_menos_750 = int(prob_menos_750 * total_botellas)
botellas_entre_751_754 = int(prob_entre_751_754 * total_botellas)
botellas_mas_757 = int(prob_mas_757 * total_botellas)
botellas_entre_750_751 = int(prob_entre_750_751 * total_botellas)
return botellas_menos_750, botellas_entre_751_754, botellas_mas_757, botellas_entre_750_751
# Llamar a la función para obtener las cantidades de botellas
resultado = calcular_probabilidades_botellas()
print("Cantidad de botellas con menos de 750 ml:", resultado[0])
print("Cantidad de botellas con entre 751 y 754 ml:", resultado[1])
print("Cantidad de botellas con más de 757 ml:", resultado[2])
print("Cantidad de botellas con entre 750 y 751 ml:", resultado[3])
Comentarios
Publicar un comentario