From the airport you will need to get the bus into edinburgh. It is very regular and you can catch it from just outside the terminal. It costs £3 single and £5 for an open return ticket. Get off at Haymarket and across the road you will see Haymarket train station. From there you will have to get a train to Fife and then one or possibly two buses depending on what time fo day you travel.
www.travelinescotland.com will give you all the options.
Hope this has been of help.