How to generate a sample from a generative model like a Restricted Boltzmann Machine? I am learning about the Boltzmann machine. So far, I have successfully written a code that can learn the coefficients of the energy function of a Restricted Boltzmann Machine. Now, since my model is generative (if I have understood things correctly so far) and I know for sure that RBMs can be used for inpainting in binary images at least, I want to know how I can generate a sample from my probabilistic distribution given by the Boltzmann machine. That is how a new binary image based on the training dataset is generated by my model.

However, even though mathematically the idea seems clear, I do not know how I can program a computer to sample from a distribution.
For a RBM, you run the stochastic network - forward and back from the "input" and hidden layers - multiple times. After a few steps it will converge into sampling from the data population it has learned from. If you have learned from a whole picture and want to fill in a patch, then hold the input values that are not in the patch (don't allow them to change randomly).

Other generative models may have different approaches. GANs and VAEs typically have a simpler approach where you generate a random input vector and run the generator part of network forward from that input.