# Probability of a point fitting a line

I am trying to classify between two groups a set of points given two variables (size of the space = L and points of the space occupied = N).

At the moment I have a sample size of 620 samples with their size and number of points covered and a training set of labelled samples coming from the two groups I want to classify (trendy / unpopular).

I want to use the value r = N/L to classify new points.

The picture of my current situation is this:

The x axis is the N value and y is the L value, in red the samples labelled as popular and unpopular in green.

My goal now is to classify the blue points as popular, unpopular or undefined (if they are in a zone that is not clear for example).

Following some internet posts I found a solution could be to use the next formula:

Where we consider two different r, rP = 0.8 and rU = 0.012, rP being the mean of the N/L for all the popular gold set and rU the same for unpopular. According my references, if we apply this formula for each point:

• P(P) > 0 and P(U) = 0; classified as popular
• P(U) > 0 and P(P) = 0; classified as unpopular
• Any other result will be undefined.

Is this the best approach for my goal? Should I apply a different methodology?

In case this is the best way to classify my points, how can I program the equation in R in order to avoid NaN problems? As there are points with very high N, I am not able to perform the calculation using:

(((r*L)^N)/(factorial(N)))*exp(-r*L)


Which could be a modification that will allow me to perform the computation of it maintaining the outcome?

• I find myself longing for a loss function. Can you quantify--if only approximately--the damage that would be caused by mis-classifying any point? As far as the computational issues go, they are discussed in some other threads here; the bottom line is that you should compute the logarithms (using lgamma(N+1) instead of log(factorial(N))).
– whuber
Commented Feb 5, 2016 at 16:54
• The solution was to use ppois(). Here the link it. Commented Mar 24, 2016 at 10:50