### Stats Problem, how to approach?

solved thank you
Last edited on
http://www.cplusplus.com/reference/algorithm/generate/

this seems like it could be pretty helpful, if anyone could confirm with me though that'd be great
bumping this, anyone able to help? is there an easier way than creating 625 arrays
closed account (D80DSL3A)
I think you can make do with a single array of 625 doubles (or floats) for the mean of each sample.

Calculation of the mean value for a given sample of 25,600 random numbers can be done on the fly, the 25,600 numbers need not be saved.

For B: Find the mean of the means.
This could be done on the fly as well.

For C: Find the standard deviation of the means.
Finally, some data storage is called for. I think you will need to save all the values of the means before you can find the standard deviation among them.

EDIT: I see your other thread. You don't need to generate float values for the random numbers! The float part happens when you calculate the average.

 ``123456`` ``````int total = 0; for(unsigned i=1; i<=25600; ++i) { total += 1 + rand()%2;// adding up integers } float average = (float)total/25600.0f;// here comes the 1.43, etc. values ``````
Last edited on
 ``1234`` ``````for (int i = 0; i

I tried doing this but I'm not sure how to make it be 1.43 1.56 etc instead of just 1's and 2's the entire time.

Wait..reading the question again...are my numbers supposed to be doubles like 1.4 1.7 etc or just 1's and 2's and then just the mean could be a double like 1.45 or something?
Last edited on
closed account (D80DSL3A)
I think you are misunderstanding the problem.

You have 625 samples of data.

Each sample consists of 25600 integers which equal either 1 or 2.
You shall find the mean value for each sample. This is the float value, not the individual numbers in the sample.
to find the mean of one of them, i'm confused why this isn't working. i get the sum to be 1999480783 and the mean to be 78104.7....shouldn't the mean be between 1 and 2

 ``123456789101112131415161718`` ``````int main() { double arrayLength = 25600; double array[25600]; int count = 0; int sum; for (int i = 0; i

nevermind found my mistake, didn't initialize sum to 0
Last edited on
Also, you don't need an array here. Replace `array[i]` with a simple `int`.
Last edited on
Topic archived. No new replies allowed.