Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: How come the mean is 7?

1. ## How come the mean is 7?

How do I calculate the mean?
The answer for this case is 7.
Why?

My assignment is here(if you want to know the question but I don't think you need it to answer "my" question):
http://www.cse.yorku.ca/course/2011/...201/Q2/Q2.html

The following is the tester class:

```
/**
* Tests the IntegralImage class.
*/
public class testIntegralImage {

public static void main(String[] args) {
int[][] image1 = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}};  // a 2d array. three rows, three columns.
int top,bottom,left,right;
double mean;

IntegralImage integralImage1;
top = 1;
bottom = 2;
left = 1;
right = 2;

try {
integralImage1 = new IntegralImage(image1);
} catch (InvalidImageException iix) {
System.out.println("Invalid Image Exception");
return;
}
try {
mean = integralImage1.meanSubImage(top,bottom,left,right);      //should be 7.0
System.out.println("The mean of the subimage from ("+top+","+left+") to ("+bottom+","+right+") is "+mean);
} catch (InvalidSubImageIndexException isiix)
{
System.out.println("Invalid SubImage Index Exception");
}

}
}```

I'm having trouble understanding the question. I think you have to look at the 2d array and calculate the mean, given the top, left, bottom and right. How do you get 7 from this?

2. ## Re: How come the mean is 7?

Originally Posted by IAmHere
I'm having trouble understanding the question. I think you have to look at the 2d array and calculate the mean, given the top, left, bottom and right. How do you get 7 from this?
The program description explains pretty clearly how to calculate the mean, and 7 is the correct answer in this case. What do you think the answer should be?