Maximum-likelihood determination of anomalous substructures