======================================================================
Example 12: Non-Compartmental Analysis (NCA)
======================================================================

Simulated 10 subjects — 1-compartment oral model
Dose: 100.0 mg  |  Sampling times: [0.0, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 24.0] hr
Population: CL=5.0 L/hr, V=50.0 L, Ka=1.5 hr^-1
IIV: CV=30%  |  Residual: CV=15%

Running NCA ...

======================================================================
NCA Summary Table
======================================================================
  ID      Cmax    Tmax    AUC_last     AUC_inf    t_half      CL/F    R2_lz
---------------------------------------------------------------------------
   1      1.54     3.0       21.03       25.35      8.64     3.945   1.0000
   2      1.54     4.0       18.54       22.20      8.99     4.504   0.9987
   3      1.33     3.0       17.37       26.89     15.87     3.719   0.9981
   4      1.85     3.0       17.32       18.24      5.11     5.482   0.9979
   5      1.51     2.0       15.81       20.98     11.49     4.766   0.9939
   6      2.09     3.0       13.18       13.37      3.73     7.482   0.9997
   7      1.84     1.5       12.42       12.82      4.77     7.798   0.9960
   8      2.74     2.0       30.42       33.99      6.82     2.942   0.9904
   9      1.71     1.5       12.22       12.60      4.62     7.939   0.9862
  10      1.47     2.0       14.59       15.85      6.29     6.311   0.9906
---------------------------------------------------------------------------
  Geometric mean AUC_inf: 19.18
  Geometric mean CL/F:    5.214
  Median t½:              6.56 hr

======================================================================
Bioequivalence Analysis: Group A (subjects 1-5) vs Group B (subjects 6-10)
======================================================================
(Illustrative only — same population, not a true crossover design)

AUC0-inf comparison:
Average Bioequivalence — AUC0-inf
  Status:       NOT bioequivalent
  GMR:          1.3786
  90% CI:      [0.9956, 1.9090]
  BE limits:    [0.80, 1.25]
  n subjects:   5
  p (lower):    0.0117
  p (upper):    0.7219
  df:           4.0

Cmax comparison:
Average Bioequivalence — Cmax
  Status:       NOT bioequivalent
  GMR:          0.8037
  90% CI:      [0.5911, 1.0927]
  BE limits:    [0.80, 1.25]
  n subjects:   5
  p (lower):    0.4881
  p (upper):    0.0187
  df:           4.0

======================================================================
Per-subject NCA parameters vs true simulation values
======================================================================

  ID     True CL   Est. CL/F     Ratio
----------------------------------------
   1       3.941       3.945     1.001
   2       4.873       4.504     0.924
   3       4.037       3.719     0.921
   4       6.504       5.482     0.843
   5       4.097       4.766     1.163
   6       7.370       7.482     1.015
   7       7.356       7.798     1.060
   8       2.780       2.942     1.058
   9       7.602       7.939     1.044
  10       6.289       6.311     1.003

Note: CL/F estimates ≈ true CL (since F=1.0 in simulation)

Done.
