It's based on size. In clowns, all fish are inherently male. In a group, the most dominant fish will turn into a female, increasing in size. The next in line becomes the dominant male that breeds with her. If she dies, the dominant male will in turn become female, etc. A clown that has been kept alone for a few months is likely well on the way to becoming female.