What are probabilities of finding a star with the specific stellar type?

I am a programming tutor, and with my student we were writing a program simulating a flight through the cosmos.

I thought that it would be great to make the circles representing stars more realistic. I have found the table showing size and colour of a star by its stellar type, but what is the probability that any given star is going to be of a specific type?1 The simple solution would be to just to select at random from the list, but that is too trivial.

If there would be some data showing the total counts of stars by the type, it would be trivial to convert into the probability. But i cannot find such.

1 Answer

Luminosity class \ Spectral type O B A F G K M All
Main Sequence (V,VI) 0.000029% 0.12% 0.59% 2.9% 7.3% 12% 73.5% 93%
Giant (I-IV) 0.5% 0.5% 1%
White Dwarf 0.5% 1.5% 1.5% 1.5% 1% 6%
Total 0.000029% 0.12% 1.09% 4.5% 8.8% 14% 75% 100%

This is very rough: What I've done is used the classification into Main sequence/Giant/White dwarf from What is the frequency distribution for luminosity classes in the Milky Way Galaxy? and the distribution for stars in the main sequence from Wikipedia. So, for example 3.1% of main sequence stars are F type, and 93% of stars are main sequence, then about 2.9% of stars are main sequence F-type stars. I've then eyeballed the distribution of Giants and White dwarf stars from the graphs on the linked question.

I've then added up and tried to make the numbers make 100%. This is probably a start, but not the final word, so I'll make the a CW.

The main takeaway is that most stars are small dim and reddish, they are red dwarfs - but none of these are visible with the naked eye. Most of the naked eye stars are B,A,F type, or K and M type giants, as these are visible across many light years.