Very hard math problem

Results 1 to 2 of 2

Thread: Very hard math problem

  1. #1
    tepic Guest

    Default Very hard math problem

    I have to analyse students marks from a particular module. The module is split into sub components: Assignments and Exams (which I will call components), for each Module the number of Assignments and Exams vary so I dont know how many components there are. <BR><BR>I have to work out the standard deviation for the set of student marks in a component, but due to the way the data is stored I have to put the marks into a 2D Array.. 1st Dimension the component number, and the second the mark for that individual student on that component. (Confused?) <BR><BR>So I now have a 2D Array which holds all the marks for the whole module: eg if 3 students and 2 components the array looks like this: <BR>(1,45)(1,56)(1,34)(2,65)(2,43)(2,74) <BR><BR>Now I have to get the standard deviation for each component. How can I do it?? <BR><BR>Sorry for the long explanation.. but any help would be gratefully recieved.

  2. #2
    Join Date
    Dec 1969

    Default Math part is easy...

    ...the organization of the data might be the hard part!<BR><BR>First of all, you need to re-think what you *mean* by the elements of your two-D array.<BR><BR>Consider:<BR><BR>&#060;%<BR>Componen tCount = 2 &#039; or any number!<BR>StudentCount = 3 &#039; or any number!<BR>Dim marks<BR>ReDim marks( ComponentCount, StudentCount )<BR>%&#062;<BR><BR>And once you have done that, then you can *choose* which way to "run" through the array, looking for values and generating statistics.<BR><BR>To keep this simple, I&#039;ll just generate means (instead of std deviations). And I&#039;ll generate two DIFFERENT means, based on the order I process the array!<BR><BR>Example 1: Find the mean value of each component.<BR><BR>&#060;%<BR>Dim componentMean<BR>ReDim componentMean( ComponentCount )<BR><BR>For compNum = 1 To ComponentCount<BR>&nbsp; &nbsp; temp = 0<BR>&nbsp; &nbsp; For studentNum = 1 To StudentCount<BR>&nbsp; &nbsp; &nbsp; &nbsp; temp = temp + marks(compNum, studentNum)<BR>&nbsp; &nbsp; Next<BR>&nbsp; &nbsp; componentMean(compNum) = temp / StudentCount<BR>Next<BR>%&#062;<BR><BR>Presto! Done. See how easy it is if you keep straight what the indexes are? I started my arrays here at 1, even though VBS always starts them at 0. I simply ignored the 0 element, for simplicity. The space wasted is insignificant, and it can make the coding much clearer.<BR><BR>And now, we can find each student&#039;s mean score by a completely parallel chunk of code, just changing which is the outer/inner loops:<BR><BR>&#060;%<BR>Dim studentMean<BR>ReDim studentMean( StudentCount )<BR><BR>For studentNum = 1 To StudentCount<BR>&nbsp; &nbsp; temp = 0<BR>&nbsp; &nbsp; For compNum = 1 To ComponentCount<BR>&nbsp; &nbsp; &nbsp; &nbsp; temp = temp + marks(compNum, studentNum)<BR>&nbsp; &nbsp; Next<BR>&nbsp; &nbsp; studentMean(studentNum) = temp / ComponentCount<BR>Next<BR>%&#062;<BR><BR>Okay?<BR> <BR>Again, the math is easy. The logic may be what you found hard.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts