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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How come the mean is 7?

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    21
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default 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?
    Last edited by IAmHere; January 23rd, 2012 at 01:32 AM.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: How come the mean is 7?

    Quote Originally Posted by IAmHere View Post
    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?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!