How to calculate the maximum safe load on a horizontal wooden beam?
There are lots of span calculators available online, which help you determine what size lumber to use in home or deck construction.  For example 

http://www.awc.org/codes-standards/calculators-software/reversecalc 

and 

http://www.awc.org/codes-standards/calculators-software/spancalc 

You could try to figure out what the live loads and dead loads for the bed are and go from there.  

Shortcut - I might try to get by with 2x4's spaced 2' or less apart if they run side to side across a single mattress,  but I'd want 2x6's if they run long ways, or for a full or larger.