Similar Items: Learning and Designing Stochastic Processes from Logical Constraints