Consider the following hat guessing game. A bear sits on each vertex of a graph $G$, and a demon puts on each bear a hat colored by one of $h$ colors. Each bear sees only the hat colors of his neighbors. Based on this information only, each bear has to guess $g$ colors and he guesses correctly if his hat color is included in his guesses. The bears win if at least one bear guesses correctly for any hat arrangement.

We introduce a new parameter—fractional hat chromatic number $\hat{\mu}$, arising from the hat guessing game. The parameter $\hat{\mu}$ is related to the hat chromatic number which has been studied before. We present a surprising connection between the hat guessing game and the independence polynomial of graphs. This connection allows us to compute the fractional hat chromatic number of chordal graphs in polynomial time, to bound fractional hat chromatic number by a function of maximum degree of $G$, and to compute the exact value of $\hat{\mu}$ of cliques, paths, and cycles.