James Hamilton has a good explanation. If you live in a place with above average gas prices, his map may give you a clue.
Nutshell: overall gas prices are a product of normal seasonal fluctuation and the price of crude oil. Combining the two effects produces an estimate of gas prices very close to actual.
As for state-to-state variations, look at taxes and other gasoline-related regulations. (Hamilton doesn’t address this, but his map makes clear the significant role that states play. Otherwise, why would adjacent counties in differing states have such widely different prices?