$\begingroup$

The question comes down to buoyancy: is the mass of the flatus inside the body divided by its volume less than or greater than the mass of an equal volume of atmospheric air?

To answer this we need to look at the density of atmospheric air, as well as the density of flatus. Let's start with the atmosphere. We usually see the density of air quoted as 1.2 kg/m3, but of course this varies with temperature and pressure. We can take out the pressure factor as we will assume that variations in atmospheric pressure are reflected in equal variations in pressure inside the body. But the external temperature is a real factor: air at 5°C is quite a bit more dense than air at 35°C - by about 11%. See this online calculator or just use the ideal gas law for an approximation.

The density of flatus inside the body is a function of the composition and the temperature / pressure. The composition is a function of the processes in your gut - what you eat, and what bacteria you have. There is remarkable variability - see for instance this detailed book chapter. Quoting:

Only one out of three adults consistently possesses the strictly anaerobic bacteria capable of producing significant quantities of methane

Other bacterial processes can produce hydrogen and carbon dioxide. Methane (16) and hydrogen (2) have a much lower atomic mass than atmospheric air (mean ~ 29); carbon dioxide (44) is the only one that is significantly greater.

A diagram of the various processes is found here:

Most of the hydrogen produced is absorbed into the blood stream and exhaled - which is why breath analysis can be used to look at the state of health of the gut. Whether methane is present in significant quantities or not at all depends on your gut flora.

The pressure inside the colon has been measured. According to the "The Ascrs Textbook of Colon And Rectal Surgery", the maximum squeeze pressure in a man can be as high as 266 mm Hg - almost 1/3 of an atmosphere. That is not enough to offset the lower density of hydrogen or methane.

So, as is often the case, the answer is "it depends". If you have the bacteria to generate methane, you will get heavier after expelling a flatus. If you produce mostly carbon dioxide, you will get lighter.

If you used the composition proposed by @Ernie, and did the math correctly, the molar mass would be 0.5*28+0.2*2+0.2*44+0.05*32+0.05*16 = 26 - just less than the density of air. But even moderate pressure (much less than the 266 mm Hg quoted above) would be sufficient to push the density above that of atmospheric air, even taking account of the difference in temperature. At which point you would be lighter after relieving yourself.