We also need a supply curve for offenses, which shows, for any level of deterrence, how many offenses will occur. If that is more than the marginal cost of deterrence, we should keep raising the expected punishment. Compare the efficiency of imprisonment, flogging, and stigma as punishments. Stigma produces a net benefit, since the information generated by conviction provides net value to potential employers etc. Flogging has punishment cost roughly equal to amount of punishment.
Imprisonment has punishment cost equal to amount of punishment plus cost of maintaining the prison.
So the inefficiency, the ratio of punishment cost to amount of punishment, is greatest for imprisonment, then flogging, then imprisonment.