Nanoelectronic devices, despite their energy efficiency and unique features, are often hindered by high variability and unpredictability. Bayesian reasoning, a machine learning technique dealing with random variables, can be a remarkable lead to exploiting nanodevices without suffering from these issues. In this paper, we present two realizations of Bayesian computing concepts based on memristors. First, using memristors as random variables allows the accurate recognition of cancerous tissue images. Second, a "Bayesian machine" is presented, which uses near-memory and stochastic computing for low-energy Bayesian inference.