Well, here's what I was able to find out: Using the Tiny, Small, and Medium maps I generated galaxies with the value of "Stars" in MapSetupDefs.xml running from 0.1 to 1.0. Galaxy type was scattered. Number of opponents was the minimum possible (Major=1, Minor=0) and all resources were set to NONE. These latter because the map generator seems to either create or guarantee a star for each opponent and the nebulae, black holes and asteroids presumably take up space from the stars.
With each value of MapSetupDefs.Stars (both with Tiny and Small) I run the map generator 10 times except when the number of resulting stars got so large (~50) that my eyes couldn't make an accurate count any more. Nevertheless, the result indeed presented a pattern:
Tiny / Small / Medium
0.1 : 3 stars / 6 stars / 11 stars
0.2 : 6 stars / 12 stars / 22 stars
0.3 : 9 stars / 19 stars / 33 stars
0.4 : 12 stars / 25 stars / 44 stars
0.5 : 16 stars / 32 stars / 55 stars
0.6 : 19 stars / 38 stars / *
0.7 : 21-22 stars / 40-44 stars / *
0.8 : 23-25 stars / * / *
0.9 : 24-27 stars / * / *
1.0 : 21-26 stars / * / *
The range 0.1-0.6 always resulted in the same number of stars every time of the 10 tries sample. When the MapSetupDefs.Stars value hit 0.7+ the number started to vary and also it didn't seem to grow any more, either.
I interpret the results to mean that the map generator *first* calculates the number of stars using the value of MapSetupDefs.Stars as a straight percentage instead of a probability, and then tries to place them on the map to random positions (presumably adjusted by the galaxy shape choice). At the percentage position around 2/3 the stars likely start "bumbing" into each other (some minimum distance between systems, I think) and/or possibly hitting the other non-resource map stuff i.e. gas clouds and radiation storms, the result being that not all of the theoretical maximum of the stars could be placed on the map which we then see as the random variation in their number from that point upwards.
Would anyone know the map sizes? My guess is that the "max number of stars" formula is something like:
NumberOfStars = NumberOfHexesOnTheMap * MapSetupDefs.Stars * AdjustmentFactor
where the "AdjustmentFactor" is related to the "size of the star system" i.e. the minimum distance between stars so that all the planets and asteroids fit comfortably around their parent stars without hitting their neighbors.