Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please help, how you I write a code to get the averages of groups in a 2d jagged array and find SSW

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Can anyone please help me with my java coding.I have a 2d double jagged array (named jag), which contains 17rows(people id) and 19 columns(bloodlevels). I have calculated the average of each column and calculated the sum squared total.This works ok. My problem, is that the people are also arranged into groups, which is set as 5,6,6 in the coding below. So I need to write code to get me the averages of the individual groups in every columns and then calculate the sum squared within.

what we know is that for each one of the bloodlevel measurements (19) there are 17 patients results, and the 17 patients fall into 3 groups, the group sizes being (5,6,6). So using the theory(below) given to me, how do I code to get the averages of the groups in every bloodlevel measurement

the logic is that these groups have say a different genetic variation to the next group etc etc,

Below is the theory behind getting the groups averages but I do not know how to work the theory into coding. Any advice would be great. Apologies, I am not proficient in programming. I have no background in programming, I am from medical perspective.So if this makes no sense, just ask me a question. Thanks

Have a for-loop that runs from 0 up to num_groups (call this variable i). Using the group_sizes array you've already created, inside this i for-loop you create a second for loop (call it j) that adds up all the group_sizes entries from 0 up to i-1, ie sum = groupsizes[0]+groupsizes[1]+...+groupsizes[i-1], then you create two variables, lowerlimit = sum and upperlimit sum+groupsizes[i]. Once the j-for-loop has complete you create another for loop (inside the i loop still, but not inside the j loop), call this one k, which goes (for int k=lowerlimit; k<upperlimit; k++). Inside this k loop you can calculate mean of the i-th patient group and the ssw for the i-th patient group.



int [] group_sizes;


 
Saloon Keeper
Posts: 15488
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Lucy, welcome to CodeRanch!

Please CarefullyChooseOneForum when you start a new topic. I will lock this one, and we will continue in the other: https://coderanch.com/t/665235/java/java/averages-groups-SSW-double-jagged
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic