Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9226769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:54:34+00:00 2026-06-18T04:54:34+00:00

Given a grid (or table) with x*y cells. Each cell contains a value. Most

  • 0

Given a grid (or table) with x*y cells. Each cell contains a value. Most of these cells have a value of 0, but there may be a “hot spot” somewhere on this grid with a cell that has a high value. The neighbours of this cell then also have a value > 0. As farer away from the hot spot as lower the value in the respective grid cell.

So this hot spot can be seen as the top of a hill, with decreasing values the farer we are away from this hill. At a certain distance the values drop to 0 again.

Now I need to determine the cell within the grid that represents the grid’s center of gravity. In the simple example above this centroid would simply be the one cell with the highest value. However it’s not always that simple:

  1. the decreasing values of neighbour cells around the hot spot cell may not be equally distributed, or a “side of the hill” may fall down to 0 sooner than another side.

  2. there is another hot spot/hill with values > 0 elsewehere within the grid.

I could think that this is kind of a typical problem. Unfortunately I am no math expert so I don’t know what to search for (at least I have not found an answer in Google).

Any ideas how can I solve this problem?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:54:35+00:00Added an answer on June 18, 2026 at 4:54 am

    You are looking for the “weighted mean” of the cell values. Assuming each cell has a value z(x,y), then you can do the following

    zx = sum( z(x, y) ) over all values of y
    zy = sum( z(x, y) ) over all values of x
    
    meanX = sum( x * zx(x)) / sum ( zx(x) )
    meanY = sum( y * zy(y)) / sum ( zy(y) )
    

    I trust you can convert this into a language of your choice…

    Example: if you know Matlab, then the above would be written as follows

    zx = sum( Z, 1 ); % sum all the rows
    zy = sum( Z, 2 ); % sum all the columns
    
    [ny nx] = size(Z); % find out the dimensions of Z
    
    meanX = sum((1:nx).*zx) / sum(zx);
    meanY = sum((1:ny).*zy) / sum(zy);
    

    This would give you the meanX in the range 1 .. nx : if it’s right in the middle, the value would be (nx+1)/2. You can obviously scale this to your needs.

    EDIT: one more time, in “almost real” code:

    // array Z(N, M) contains values on an evenly spaced grid
    // assume base 1 arrays
    
    zx = zeros(N);
    zy = zeros(M);
    
    // create X profile:
    for jj = 1 to M
      for ii = 1 to N
        zx(jj) = zx(jj) + Z(ii, jj);
      next ii
    next jj
    
    // create Y profile:
    for ii = 1 to N
      for jj = 1 to M
        zy(ii) = zy(ii) + Z(ii, jj);
      next jj
    next ii
    
    xsum = 0;
    zxsum = 0;
    for ii = 1 to N
      zxsum += zx(ii);
      xsum += ii * zx(ii);
    next ii
    xmean = xsum / zxsum;
    
    ysum = 0;
    zysum = 0;
    for jj = 1 to M
      zysum += zy(jj);
      ysum += jj * zy(ii);
    next jj
    ymean = ysum / zysum;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem setting the CSS class for each cell in a given
I have grid view which contains five radio buttons per row. Out of these
I have grid of images, when the mouse is over any given image a
Given a certain date, I want to set the value of a cell with
I have a table with multiple tbody's, each of which has a classed row,
I have a sudoku grid with 81 cells(asp:textboxes) which I've labeled: _c11.._c12.._c13.._c99 I'm trying
When a Slickgrid is added to a table-cell styled div , the grid becomes
I have a table with 8 <tr> s, each with 8 <td> s, each
I'm looking for a way to make a grid (for now using Table, but
I Have used objectlist to display data like a grid for mobile. but when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.