I know next to nothing about Python so I don't know if this is what you mean but Googling gave me:
https://docs.python.org/2/download.html
At the top you can select what version you desire.
Today, 03:32 AM
I know next to nothing about Python so I don't know if this is what you mean but Googling gave me:
https://docs.python.org/2/download.html
At the top you can select what version you desire.
Today, 02:46 AM
I second the recommendation for a Nexus. I have a Nexus 5 which I think it wonderful, no-bloatware, no fuss when programming for it. Always one of the first devices to get newer versions of Android.
For me the main points were a phone without loads of junk that I don't need, don't want and can't get rid of. I also wanted a phone I could program for without hassle and if you do intend to make any Android apps (you sound quite flexible when it comes to OS from the phones you listed) then having a 'pure' device is a good first step.
Nexus 5 is reasonably old now but it is plenty powerful. I don't know if there is a more modern equivalent of it that has a similar sized screen (any bigger would be too big I think).
Yesterday, 12:21 PM
What about doing your first option (forming a distribution and then distributing) then work out how much is left and scattering them randomly?
int value = 1000000; const int numElements = 8; float weights[numElements]; float weightTotal = 0; int elements[numElements]; for (int i = 0; i < numElements; i++) { weights[i] = RandomFloat(0, 1); weightTotal += weights[i]; } for (int i = 0; i < numElements; i++) weights[i] /= weightTotal; int elementTotal = 0; for (int i = 0; i < numElements; i++) { elements[i] = roundf(weights[i] * value); elementTotal += elements[i]; } int difference = value - elementTotal; for (int i = 0; i < difference; i++) elements[RandomInt(0, numElements - 1)] += 1;
That does seem to go back to the 'convoluted' that you were aiming to avoid though.
Yesterday, 11:48 AM
I don't have an elegant way but when I read your title my method for doing this is almost exactly how you are approaching it. There are 2 steps, first define your distribution, second distribute.
You are defining your distributions with random floats and then normalizing them and finally you distribute that integer. This sounds like a solid approach to me rather than a convoluted mess.
When you actually distribute the int are you doing something like:
elementValue[i] = (int)(weight[i]*initialValue);?
Are the random numbers in the range 0-1?
Thats essentially what im doing, the problem however is that you are slicing off the decimal numbers, the result is that in the end the numbers dont add up to the initial input. With the example of spreading 50 across 8 elements randomly the total sum of the output is ~45 rather than 50. I have some extra code to deal with this issue, and that is where it starts to feel messy and convoluted.
I'm not sure that is the best way to deal with it or if there is a more elegant solution.
EDIT: Yes, random numbers are initially between 0 and 1, after normalizing them all numbers combined add up to 1
I see what you mean with truncating the decimal you will have some left over. Ferrous' method seems to avoid this. It does seem susceptible to having one huge value which might not be desirable (your original method seems to be less vulnerable to that).
Another method you could try:
int value = 50; const int numElements = 8; int elements[numElements]; // all zeroed int random = 0; for(int i = 0; i < value; i++) { random = RandomInt(0, numElements - 1); elements[random] += 1; }
Essentially pulling one off at a time and throwing it in a random box. Might not be the best approach if numElements is large. But it is simple, doesn't suffer from having anything left over and should be less susceptible to having one element be very large compared to the rest. I don't know a great deal about distributions and probability but with Ferrous' method I think that if you get a very large first number then that will force subsequent elements to have low values (which then isn't quite random any more, well it is random but there are different randoms.. I'm confusing myself now).
Yesterday, 07:00 AM
I don't have an elegant way but when I read your title my method for doing this is almost exactly how you are approaching it. There are 2 steps, first define your distribution, second distribute.
You are defining your distributions with random floats and then normalizing them and finally you distribute that integer. This sounds like a solid approach to me rather than a convoluted mess.
When you actually distribute the int are you doing something like:
elementValue[i] = (int)(weight[i]*initialValue);?
Are the random numbers in the range 0-1?
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC