News for hackers. Stuff that matters.
Re:Peculiar pattern found in 'random' prime numbers by JustSomeNobody on Monday March 14, 2016 @10:45AM (#11283133)
Why is random in quotes? Random numbers can have patterns, too.
Re:Peculiar pattern found in 'random' prime numbers by jessaustin on Monday March 14, 2016 @10:50AM (#11283156)
Prime numbers may be generated in deterministic fashion, so in a real sense they can't be random.

More discussion at https://news.ycombinator.com/item?id=11282480

Re:Peculiar pattern found in 'random' prime numbers by theoh on Monday March 14, 2016 @01:45PM (#11284227)
This is a technicality, but isn't it the case that if the deterministic algorithm required takes up as much space at the mathematical object itself, the object can be considered random?(according to Gregory Chaitin etc.)

https://en.m.wikipedia.org/wiki/Algorithmically_random_seque...

Re:Peculiar pattern found in 'random' prime numbers by jessaustin on Monday March 14, 2016 @04:34PM (#11285371)
That is one sense of the concept "random", but the primes are trivially disqualified from that (please forgive my coffeescript):

  $ wc -c primes.coffee
  110 primes.coffee
  $ cat primes.coffee 
  ps=[n=2]
  until ps.join(',').length>110
    n++
    ps.push n unless ps.some (p)->not(n%p)
  console.log ps.join ','
  $ coffee primes.coffee | wc -c
  115
  $ coffee primes.coffee 
  2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151
Re:Peculiar pattern found in 'random' prime numbers by radarsat1 on Monday March 14, 2016 @11:11AM (#11283252)
Can they? Genuine question.
Re:Peculiar pattern found in 'random' prime numbers by mturmon on Monday March 14, 2016 @12:10PM (#11283645)
It's actually a very good question. Even up to the Renaissance, we had no real conception of "probability" -- even though there were games of chance that depended on it. The Greeks had notions of impossible/possible/likely, but no way to link the notions to the world.

It was finally in the correspondence of Pascal and Fermat in 1654 that a mathematics for probability started to emerge. With the emergence of the laws of large numbers, this mathematics could be linked to observable real-world occurrence rates. (Ian Hacking's book "The Emergence of Probability" is a standard reference, http://www.jstor.org/stable/2184357?seq=1#page_scan_tab_cont...)

Suppose you were confronted with a stream of random numbers, and no intellectual or mathematical framework for quantifying them. Just coming up with a notion of a frequency curve (i.e., a density), and statistical independence of "unlinked" events would be a huge leap.

I used to TA an undergrad probability class, and in the first weeks, I'd ask the students to quantify some random variable, and they'd sometimes blankly look back and say, "it's just random" -- what we taught them is how you break that down in terms of the familiar quantities (densities, independence, correlations) and operations (multiplying for independence, integrating for expectation, integrating and renormalizing for conditioning).

So to get back to your original question, even a deterministic sequence, like

  0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, ...
could be regarded as random, and given a density and all the other folderol. And a "completely random" sequence of 0/1 equiprobable bits also has a density, etc. And so does everything in between.
Re:Peculiar pattern found in 'random' prime numbers by radarsat1 on Monday March 14, 2016 @01:05PM (#11283948)
Thank you, that is a very good answer. So "random" is how you look at a sequence. It's more a model (context in which to interpret a sequence) than an observable fact. Is that a fair interpretation?

By saying "this is a random sequence," you enable a statistical view of the problem. Even for purely deterministic sequences, this can be useful.

Last question, something I've never been perfectly clear on, what is the difference between "random" and "stochastic"? My understanding is that a stochastic model is a model featuring stochastic variables, which are variables that draw from some random distribution. Is the terminology I am using correct?

Re:Peculiar pattern found in 'random' prime numbers by mturmon on Monday March 14, 2016 @02:36PM (#11284584)
For almost all purposes, "stochastic" is literally a synonym for "random". But sometimes the usage favors one and not the other.

You would talk of a "random variable" (loosely, a quantity that exhibits random behavior, although there is a technical definition that is more precise and has a different flavor), not a "stochastic variable".

Sometimes, you would talk about a "stochastic matrix" (which is actually deterministic, an example of a namespace clash), because a "random matrix" would indeed be random be filled with "random variables".

But, you would often talk about a "stochastic process" like Brownian motion. Although you can also say "random process", and that's the same thing.

You would not talk about a "random distribution", that sounds like you mean "arbitrary distribution" (as in, "I picked out some random socks today"). But you don't mean arbitrary, you mean a "statistical distribution" or "probability distribution".

To get all this right, you have to live in that world, you can't just visit. If an outsider could just speak the language using clear rules, there would be no point in all those advanced classes, right? ;-)

Re:Peculiar pattern found in 'random' prime numbers by radarsat1 on Monday March 14, 2016 @07:06PM (#11286242)
Thank you!
Re:Peculiar pattern found in 'random' prime numbers by noamyoungerm on Monday March 14, 2016 @01:49PM (#11284255)
Well, we're all familiar with https://xkcd.com/221/ or http://dilbert.com/strip/2001-10-25

The possibility, however remote, exists that you will randomly select a sequence with patterns and order. In cryptography, we define the term 'pseudorandom' in order to discuss a class of functions that look random. Pseudorandom sequences are sequences where, given the first n bytes of the sequence, an adversary cannot guess the n+1th byte with probability significantly higher than 1/2. Basically, it's important to distinguish between blindly selecting a sequence out of all possible sequences, and finding a particular sequence with no discernible internal order.

Re:Peculiar pattern found in 'random' prime numbers by tripzilch on Monday March 14, 2016 @05:52PM (#11285839)
I used to have a version of that Dilbert comic as a forum signature for a while, except I hacked a little PHP script so it would insert a random number instead of "nine" into that panel (still repeated), different on every reload. Just to confuse people :)
Re:Peculiar pattern found in 'random' prime numbers by jrochkind1 on Monday March 14, 2016 @01:19PM (#11284041)
The idea of what "random" means turns out to not be very simple after all. I think in a typical definition (at least as used for CS?), a "random" sequence of numbers _by definition_ has no predictable pattern to it -- that's what makes it random. Of course, a given sequence of random numbers could _happen_ to have all sorts of patterns in it (and indeed, you could find patterns to post-fit to any sequence), but if you can predict it in advance... it's not "random"? I think?
Re:Peculiar pattern found in 'random' prime numbers by sp332 on Monday March 14, 2016 @11:44AM (#11283473)
Yeah, it depends on the distribution you're sampling from. It's possible (often desirable) to introduce a bias when picking a random number. http://www.boost.org/doc/libs/1_42_0/libs/random/index.html
Re:Peculiar pattern found in 'random' prime numbers by radarsat1 on Monday March 14, 2016 @12:07PM (#11283624)
Right, but then they aren't random, right? I feel like this is a problem of semantics.. what do we mean by "random number"? I thought the definition was basically, "lack of pattern." What is a better definition?
Re:Peculiar pattern found in 'random' prime numbers by parenthephobia on Monday March 14, 2016 @01:31PM (#11284125)
In mathematical terms, random refers to a quantity which is "randomly" picked from a distribution. In a sense, things are only random in reference to a distribution.

A "random number" in the lay sense is a "random number from a uniform probability distribution"; a uniform distribution being one where each element is equally likely.

You might note there are still patterns in uniform distributions. e.g. Uniformly random integers are never not integers, and they also fit within a particular range: we have no way to pick random numbers uniformly between -infinity and infinity.

Re:Peculiar pattern found in 'random' prime numbers by sp332 on Monday March 14, 2016 @12:45PM (#11283840)
Well it's degrees of random. You just shift the probabilities. Rolling a die is still random even though you'll never roll a 7, or a 3.5, or a "b". Picking a number from a normal distribution is still random even though it's more likely to get you a sample from the center than from the edges.
Re:Peculiar pattern found in 'random' prime numbers by fahadkhan on Monday March 14, 2016 @11:15AM (#11283284)
Yes, it's normally one of the first programs most people tackle when learning a new programming language.
Re:Peculiar pattern found in 'random' prime numbers by radarsat1 on Monday March 14, 2016 @11:38AM (#11283435)
What is? My question was about whether random numbers can have patterns.

I thought a sort of general definition of patterns was the existence of correlation from one state to another, while the definition of randomness was the lack of the same correlation. So I'm wondering how random numbers can have patterns? It's possible my view of "random numbers" and "patterns" is not sufficiently nuanced.

I have no idea what your comment means in this context.

Re:Peculiar pattern found in 'random' prime numbers by fahadkhan on Tuesday March 15, 2016 @11:58AM (#11290571)
Sorry I thought the context of your question was "Prime numbers may be generated in deterministic fashion"

Of course you know that random numbers will have a distribution. I think this is an example of that. Most people would have expected a uniform distribution here but it isn't the case.

Re:Peculiar pattern found in 'random' prime numbers by ipsin on Monday March 14, 2016 @11:32AM (#11283398)
I think it's in quotes because prime numbers have a probability distribution, but it's (obviously) not a uniform distribution. I think that the article is trying to say that there are more subtle rules around the distribution than just probability density.

By "probability density", I mean that the probability of a number around n being prime are about 1/ln(n) -- see the Prime Number Theorem[1] for more -- but of course any given integer is either prime or not.

[1] https://en.wikipedia.org/wiki/Prime_number_theorem