Question

In: Statistics and Probability

BMI= 70 (kg)1.752(m2)=22.86 (kg/m2) Calculate the BMI for this population, and the their corresponding nutritional status...

BMI= 70 (kg)1.752(m2)=22.86 (kg/m2)

  1. Calculate the BMI for this population, and the their corresponding nutritional status according to table1. Use the following lists:
    1. the list weight to store the weight data in kg
    2. the list height to store the height data in
    3. the list bmi to store the calculated body mass index
    4. the list status to store the nutritional status of the population

  1. The file contains 25000 records, displaying the entire data is not convenient. In this case, we can
    1. Display heights, weights, bmi, and status, only for the first and last ten individuals, or
    2. Summarize the data through some statistic figures:
      1. the counts for eash of the nutritional status
      2. the mean μ and the standard σ deviation for the BMI using the following formula:

σ=i=1n(xi-μ)2n

where:

xi is the ith value in the BMI data

μ: is the mean value of BMI

n: is the size of the population

  1. Finally we visualize data using basic plots such as the barplot which we have provided.

Solutions

Expert Solution

Sol:

code :

import math

# read lines from file.
# split the lines at spaces , convert each value to float.
# conver the height in inches to meters.
# covert the weight from pounds to kgs.
def get_data(filename):
file = open(filename)
height = []
weight = []
lines = file.readlines()
for line in lines:
line = list(map(float , line.split(" ")))
height.append(line[1]*0.0254)
weight.append(line[2]*0.453592)
return height , weight

# function to calculate the bmi : weight / height
def calculate_bmi(height , weight):
bmi = []
for h,w in zip(height , weight):
bmi.append(w / h)
return bmi

# function to get teh status.
def gen_status(bmi):
status = []
for i in range(len(bmi)):
if bmi[i] < 18.5:
status.append("Underweight")
elif bmi[i] >= 18.5 and bmi[i] <= 24.9:
status.append("Normal Weight")
elif bmi[i] >= 25.0 and bmi[i] <= 20.9:
status.append("Overweight")
else:
status,append("Obesity")
return status

# function to generate the statistics (mean , std_dev , count)
def gen_stats(BMI , status):
counts = [0]*4
mean_bmi = sum(BMI) / len(BMI)
std_dev = 0
for i in range(len(BMI)):
if status[i] == "Underweight":
counts[0] += 1;
elif status[i] == "Normal Weight":
counts[1] += 1;
elif status[i] == "Overweight":
counts[2] += 1;
else:
counts[3] += 1;
std_dev += (BMI[i] - mean_bmi)**2
std_dev /= len(BMI)
return mean_bmi , math.sqrt(std_dev) , counts

def print_data(height , weight , bmi , status , counts , mean_bmi , std_dev):
print(" Welcome to the BMI Calculator ")
print("Underweight\t\tNormal\t\tOverweight\t\tObese")
print(counts[0],"\t\t",counts[1],"\t\t",counts[2],"\t\t",counts[3])
print("***********************************")
print("Height\t\tWeight\t\tBMI\t\tStatus")
for i in range(0,10):
print(f"{round(height[i],2)}\t\t{round(weight[i],2)}\t\t{round(bmi[i],2)}\t\t{status[i]}")
print(".......")
for i in range(-1,-10,-1):
print(f"{round(height[i],2)}\t\t{round(weight[i],2)}\t\t{round(bmi[i],2)}\t\t{status[i]}")

print("The average BMI : ", mean_bmi)
print("The standard deviation for BMI is : " , std_dev)

def main():
filename = "hw_25000.txt"
height , weight = get_data(filename)
bmi = calculate_bmi(height , weight)
status = gen_status(bmi)
mean_bmi , std_dev , counts = gen_stats(bmi , status)
print_data(height , weight , bmi , status , counts , mean_bmi , std_dev)

if __name__ == "__main__":
main()

Output:

If you Satisfy with Answer, Please give me "Thumb Up". It was very important to me.


Related Solutions

Jimbo, a 30-year old male, has a BMI of 31 kg/m2 , hypercholesterolaemia, and glaucoma. After...
Jimbo, a 30-year old male, has a BMI of 31 kg/m2 , hypercholesterolaemia, and glaucoma. After a series of concerning episodes of mood disturbances, his psychiatrist diagnoses him with schizophrenia. He decides to prescribe an appropriate antipsychotic. Although the treatment is ultimately effective, he initially complained of several side effects with little therapeutic improvement. a. Suggest an appropriate antipsychotic to prescribe to him. Justify your selection by referring to pharmacodynamic and toxicodynamic responses. b. Explain why Jimbo experienced side effects...
Java - Write a program to calculate a user’s BMI and display his/her weight status. The...
Java - Write a program to calculate a user’s BMI and display his/her weight status. The status is defined as Underweight, Normal, Overweight and obese if BMI is less than 18.5, 25, 30 or otherwise respectively. You need to read weight (in kilogram) and height (in metre) from the user as inputs. The BMI is defined as the ratio of the weight and the square of the height. [10 marks]
What percentage of the U.S. population is overweight by BMI? 70% 90% 50% 25%   What are...
What percentage of the U.S. population is overweight by BMI? 70% 90% 50% 25%   What are the potential mechanisms for increasing glucose uptake into muscle? Contraction mediated Glut1 translocation Insulin mediated Glut4 translocation Contraction mediated Glut4 translocation B+C Which of the following is NOT a precaution that should be taken to reduce the risk of exercise- induced hypoglycemia (low blood sugar) in patients with type 1 diabetes? Consume carbohydrate if glucose is <100 mg/dl Avoid exercising during peak insulin action...
10. For the population and sampling distributions corresponding to a and b above, calculate the following...
10. For the population and sampling distributions corresponding to a and b above, calculate the following probabilities. The above a and b referenced are a. X ~ N (0,4) and b. X ~ N (15,7) a. P(X > 1.5); P(X¯ > 1.5) b. P(X < 8); P(X¯ < 8)
How does alcoholism affect the body's nutritional status?
How does alcoholism affect the body's nutritional status?
Is it fair that people who are careful about their BMI status and do not fall...
Is it fair that people who are careful about their BMI status and do not fall into categories of overweight or obese be required to pay increased premiums for their insurance to cover those employees who don't watch their weight, eat to excess, and don't exercise? (Health insurance operates through shared risk principles--younger, healthier people pay for those who are usually older and sicker). List three reasons why it would be fair--and three reasons why it wouldn't be fair.  
identify motivational strategies to improve nutritional status throughout the childbearing period
identify motivational strategies to improve nutritional status throughout the childbearing period
The 2 -dimensional arrays m1 and m2 are strictly identical if their corresponding elements are equal.  ...
The 2 -dimensional arrays m1 and m2 are strictly identical if their corresponding elements are equal.   Write the method "equals" which returns True if the arrays are strictly identical and False if they are not. The method's header is: public static boolean equals(int[][] m1, int[][] m2) Here is the program: import java.util.Scanner; public class StrictlyEquals { public static void main(String[] args) { Scanner input = new Scanner(System.in); final int ROW_SIZE = 3; final int COLUMN_SIZE = 3; System.out.print("Enter m1 (a...
Block 1 with m1 = 0.127 kg and block 2 with m2 = 0.163 kg are...
Block 1 with m1 = 0.127 kg and block 2 with m2 = 0.163 kg are supported on a horizontal frictionless table whose surface is 1.75 m above a horizontal floor as shown in the Figure. Block 1 has an initial speed of v = 5.50 m/s toward block 2 which is initially at rest. A) (7 pts) Block 1 collides with block 2 and coalesces (forms one object). Calculate the velocity of the coalesced object. B) (10 pts) The...
A ball of mass m1 =5.2 kg and a block of mass m2 =2.0 kg are...
A ball of mass m1 =5.2 kg and a block of mass m2 =2.0 kg are connected with a lightweight string over a pulley with moment of inertia I and radius R=0.25m. The coefficient of kinetic friction between the table top and the block of mass m2 is μk = 0.4. If the magnitude of the acceleration is a=2.7 m/s2. torque_rotational a)What are the tensions T1 and T2 in the string. T1= N T2= N b)Calculate the moment of inertia...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT