Development and application of methods for identifying and quantifying chemical substances
Analytical chemistry involves the qualitative and quantitative analysis of chemical substances. I help with method development, instrument analysis, sample preparation, data interpretation, and quality control. I cover techniques including chromatography, spectroscopy, mass spectrometry, electroanalytical methods, and classical wet chemical methods.
import numpy as np
from typing import List, Dict, Tuple
from scipy import stats
class AnalyticalMethod:
def __init__(self, name: str, detection_limit: float = 0.0):
self.name = name
self.detection_limit = detection_limit
self.calibration_data = []
def linear_calibration(self, concentrations: List[float],
responses: List[float]) -> Dict:
slope, intercept, r_value, p_value, std_err = stats.linregress(
concentrations, responses
)
self.calibration_data = list(zip(concentrations, responses))
return {
'slope': slope,
'intercept': intercept,
'r_squared': r_value**2,
'standard_error': std_err
}
def calculate_unknown(self, response: float, calibration: Dict) -> float:
return (response - calibration['intercept']) / calibration['slope']
def detection_limit_3sigma(self, blank_responses: List[float]) -> float:
blank_mean = np.mean(blank_responses)
blank_std = np.std(blank_responses)
return blank_mean + 3 * blank_std
def standard_addition(self, original_response: float,
added_concentrations: List[float],
spiked_responses: List[float]) -> float:
slope, intercept, _, _, _ = stats.linregress(
added_concentrations, spiked_responses
)
return -intercept / slope
def precision_check(self, measurements: List[float]) -> Dict:
return {
'mean': np.mean(measurements),
'std_dev': np.std(measurements),
'relative_std_dev': np.std(measurements) / np.mean(measurements) * 100,
'confidence_interval_95': stats.t.interval(
0.95, len(measurements)-1,
loc=np.mean(measurements),
scale=stats.sem(measurements)
)
}
method = AnalyticalMethod("HPLC Quantification")
cal = method.linear_calibration(
[0, 10, 20, 30, 40],
[0.02, 0.45, 0.89, 1.32, 1.78]
)
unknown = method.calculate_unknown(0.65, cal)
print(f"R²: {cal['r_squared']:.4f}")
print(f"Unknown concentration: {unknown:.2f}")