sum distribution of points on 2d graph
I have a 10,000 2d points in a pytorch tensor.
The points are between between -1 and 1. i.e. x ∈ {-1, 1}^2
I want to output a heat map to show the distribution of the points.
In order to print the graph I am using matplotlib like so
torch.meshgrid(torch.linspace(-1, 1, 1000), torch.linspace(-1, 1, 1000))
ax.contourf(x_grid, y_grid, grid_values)

However I dont know how to calculate the grid values for this
I would you calculate the grid_values given the tensor of shape (10,000, 2) of points on the graph (note that a point can appear multiple times on the graph and we want to sum the distribtion of these points)

You are describing a normal 2D histogram, possibly weighted (not sure if your points had a value associated with them as well)?
plt.hist2d(x, y, weights=w, range=[[-1,1],[-1,1]], bins=1000)

will also spit out the associated matrix, with values binned accordingly which you can use to make contours.
