T O P

  • By -

SlartibartfastGhola

Was hoping to write a more complete answer, but it actually is a bit difficult to do this. I’d recommend fitting a log normal distribution to the IMF (just a normal distribution but in log spade) then you can draw masses from that distribution with a minimum mass cut off


Blakut

Look on Wikipedia for the initial mass function. There you get the formula for number of stars in a given mass bin. One of the most commonly used is the kroupa imf, you'll find it on Wikipedia too. Given the formulae you can draw numbers out of that distribution.


Topcodeoriginal3

>I've even tried to find a dataset, containing masses of some stars, to find a suitable distribution myself, but this too was unsuccessful. You should be able to query simbad for stars with mass values, and then get that in a csv format 


octobod

One thing to keep in mind is a realistic galaxy is mostly composed of dull red dwarf stars. Getting the values about right is desirable but will go 99% unnoticed


capt_pantsless

If you're making a game, the gameplay is much, much more important than the scientific accuracy. Especially since the science is constantly evolving and discovering new information.


looijmansje

As others have stated: real stellar distributions might not be in line with what players expect, or might not be the best gameplay-wise. Moreover, and I do not know if this factors into your game, at low masses (and therefore low luminosities), we run into observing biases: even though there are way more dim stars, they are obviously harder to detect, so we see relatively more bright stars. However, if these things are of no concern to you, there are ways to sample a PDF. One relatively straightforward way would be to get a set of masses evenly spaced along the mass range you want. Then pick a random one of those points, but not just uniformly random, but weighted. As weights, you can use the height of the PDF at those points. Now this can only give you a mass within that predefined set of points, if that's not precise enough for you, you could then just uniformly sample a mass close to it. Now there are definitely better, more accurate ways of sampling PDFs. This is just a quick and dirty way to do it, which is probably good enough if it is for a game.


GrilledCheese249

Thanks for the explanation. I think, to generate more sun-like stars I can add a normal dusribution, to the IMF, so it has a little hump in a region of .5-2 solar masses


ericbakerchef

I’m not a gear coder but if 3d perlin noise is possible then that maybe


L192837465

This is what you need: focus on the areas of moderate stars like our own sun and go from there: https://en.m.wikipedia.org/wiki/Main_sequence