0% found this document useful (0 votes)
28 views2 pages

Numpy Heart Rate Analysis

The document outlines a process for simulating and analyzing heart rate data for 100 patients over one day using NumPy. It includes steps for generating random heart rate data, calculating average heart rates per patient, and plotting a histogram to visualize the distribution of these averages. Additionally, it highlights the advantages of using NumPy over Python lists in terms of speed, memory efficiency, built-in functions, and integration capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Numpy Heart Rate Analysis

The document outlines a process for simulating and analyzing heart rate data for 100 patients over one day using NumPy. It includes steps for generating random heart rate data, calculating average heart rates per patient, and plotting a histogram to visualize the distribution of these averages. Additionally, it highlights the advantages of using NumPy over Python lists in terms of speed, memory efficiency, built-in functions, and integration capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

💓 NumPy Heart Rate Analysis – 100

Patients, 1 Day
We simulate heart rate data for 100 patients, recorded every minute for a full day (1440
minutes). This gives us a NumPy array of shape (100, 1440).

✅ Step 1: Generate Heart Rate Data


Code:

heart_rates = [Link](60, 120, size=(100, 1440))

What it does:
Generates a 2D array where:
- Each row represents one patient
- Each column represents heart rate at a specific minute
- Values range between 60 bpm and 119 bpm (inclusive of 60, exclusive of 120)

✅ Step 2: Calculate Average Heart Rate per Patient


Code:

average_heart_rates = [Link](heart_rates, axis=1)

What it does:
Calculates the average heart rate over the whole day for each patient.

Result: You get an array of 100 values—one average heart rate per patient.

✅ Step 3: Plot Histogram of Averages


Code:

[Link](figsize=(10, 6))
[Link](average_heart_rates, bins=15, color='skyblue', edgecolor='black')
[Link]('Histogram of Average Heart Rates (per Patient)')
[Link]('Average Heart Rate (bpm)')
[Link]('Number of Patients')
[Link](True)
plt.tight_layout()
[Link]()

What it does:
Draws a histogram that shows how many patients fall into each range of average heart
rates.

Result: You get a visual understanding of how heart rates are distributed among patients.

💡 Why Use NumPy Instead of Python Lists?


Feature NumPy Python Lists

✅ Speed Faster using vectorized C- Slower due to loops


level operations

✅ Memory Uses less memory with More memory-intensive


fixed data types

✅ Functions Built-in mean, sum, etc. Manual implementation


needed

✅ Integration Works with pandas, Less integration support


matplotlib, scikit-learn

You might also like