Implement a function to calculate the Expected Calibration Error (ECE) for evaluating how well a binary classification model's predicted probabilities are calibrated.
Given true binary labels (0 or 1) and predicted probabilities for the positive class, compute the ECE by:
The first bin should include both endpoints [0, 1/n_bins], while subsequent bins should exclude their lower boundary (lower, upper].
The function should return the ECE value rounded to 3 decimal places. Lower ECE values indicate better calibration, with 0 being perfectly calibrated.