Topic 2 / 4📁 Unit Index
BP101T • Unit 2Topic 2 of 4⏱ 5 Min Read

2. Array Indexing, Slicing & Matrix Operations for Formulation

💡 Core Concept & Clinical Context:

In pharmaceutical formulation development, dissolution profiles and stability testing generate 2D matrices (rows = time points, columns = sample batches). NumPy provides zero-indexed indexing and slicing (`[start:stop:step]`) to extract specific time points, replicate runs, or calculate column-wise means and standard deviations.

Pharmaceutical Code & Calculation Examples:
1Multi-Batch Dissolution Profile Matrix Analysis

Analyzing drug release percentages across 3 distinct production batches at 5, 15, 30, 45, and 60 minutes.

example_1.py
import numpy as np

# Rows = Time points (5, 15, 30, 45, 60 min), Columns = Batches (Batch A, Batch B, Batch C)
dissolution_matrix = np.array([
    [28.4, 26.9, 29.1],  # 5 min
    [54.2, 52.8, 55.0],  # 15 min
    [78.9, 77.4, 80.2],  # 30 min
    [91.5, 89.8, 92.4],  # 45 min
    [98.7, 97.2, 99.1]   # 60 min
])

# Mean dissolution across all batches at each time point (axis=1 calculates row-wise)
mean_profile = np.mean(dissolution_matrix, axis=1)
std_profile = np.std(dissolution_matrix, axis=1)

time_points = [5, 15, 30, 45, 60]
for t, mean, std in zip(time_points, mean_profile, std_profile):
    print(f"Time {t:2d} min: Mean = {mean:.2f}% | SD = ±{std:.2f}%")
📋Key Takeaways & Exam Highlights
  • `axis=0` performs operations down columns (per batch/variable).
  • `axis=1` performs operations across rows (per time point/sample).
  • Matrix multiplication `np.dot(A, B)` or `@` operator is used in linear pharmacokinetic compartment modeling.
🇮🇳 हिन्दी व्याख्या (2. Array Indexing, Slicing & Matrix Operations for Formulation)

2D मैट्रिक्स में पंक्तियां (Rows) समय बिंदु और कॉलम (Columns) अलग-अलग बैच होते हैं। axis=1 से हर समय बिंदु पर औसत डिसोल्यूशन निकाला जाता है।

Need to see the complete unit overview, solved numericals, or exam checklist?Open Unit 2 Overview Hub →