3
$\begingroup$

This code produces straight lines, I'd like to find which n values are on which of the lines:

ListPlot[Differences[
  Table[PrimePi[Min[Prime[n + 1]^2, Product[Prime@i, {i, n}]]] - 
    n, {n, 3000}]]]

enter image description here

Is there a way to sort the n values accurately for a general case of multiple straight or curved lines?

cheers, Jamie

$\endgroup$

1 Answer 1

2
$\begingroup$

The angles of the points capture rather well their belonging to one line or another. Combine that with Mathematica's clustering algorithms and you have a possible way of solving this:

data = Differences[Table[PrimePi[Min[Prime[n + 1]^2, Product[Prime@i, {i, n}]]] - n, {n, 3000}]];
pts = Transpose[{Range@Length[data], data}];
angles = ArcTan @@@ pts;
clusters = FindClusters[angles -> pts, Method -> "Agglomerate"];
ListPlot[clusters]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.