I would like to check if a coin flips randomly, based on observational data. The catch is, the coin can have two sides, but also three, four, up to nine. The number of sides differs in each observation (each toss).
I can generate observations but it's relatively costly, so generally the sample size is small, like 20, 30, maybe 50, although I could probably go for more if needed.
What's the statistical test to apply here, and how, if there are any tricky aspects?
How many observations do I need? Am I correct in thinking that the more pronounced the bias is, the fewer observations I need to detect it?
EDIT to answer the comments: I know how many sides there are each time and I can control it to some degree. The coin is supposed to flip randomly but I suspect it does not. If it indeed does not flip randomly, I would like to be able to say: "here is the sound statistical evidence that this coin does not flip randomly". Probably something about p-value being less than 0.05, as usual.
By "randomly", I meant each side should have the same probability of "coming up" (1/d, d being the number of sides). The alternative hypothesis is that one of the sides (heads, or the "first" one, it's the same the whole time, it's always present) has a higher probability. I don't care about different tails.
TLDR: I think the coin is biased towards heads. The coin can have more than one tails and the number of tails can change from observation to observation. In other words, the expected probability of heads differs in each observation.
UPDATE: Here are the calculations of p-values for the coin being biased towards heads, based on the answer about Poisson-binomial distribution. Two sets of observations, real data.
> x = c(2,4,6,7,8,2,3,3,4,4,3,3)
> 1-poisbinom::ppoisbinom(9-1,1/x)
[1] 0.0009309207
> b = rep(9, 34)
> b
[1] 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
> 1-poisbinom::ppoisbinom(7-1,1/x)
[1] 0.02906178
It would seem that the coin is indeed biased, even though the sample sizes are small.
For the interested, the described situation is from a computer game where you can have up to nine units on board. A certain unit gives a bonus to one of your units (including itself) each turn. It is supposed to do it randomly (specifically, the implicit expectation is uniform random), but in practice it seems to select itself more often than it should.
The bonus itself doesn't matter for the purposes of this question. The units are the sides of the coin, and the unit that gives the bonus is heads. Each turn there's a coin flip and the bonus lands on one of the units. @Sextus Empiricus