20071201, 03:14  #1 
May 2007
Kansas; USA
2·3·11·157 Posts 
Odds of prime / expected # of primes
To all,
This might be useful for some of you... I created the attached spreadsheet shortly after I found RPS and have been using it to determine the odds that a prime will be found within a sieved file. It also tells you about how many primes that you can expect for a sieved file and calculates the odds of finding a twin, triplet, or quadruplet. I used it to determine how large of a range to sieve for the twin and quads that I found. You just plug in the k, base, avg. n, sieve depth, and # of candidates and it does the rest. The base crux of the formulas came from Axn1 in a thread here at RPS. I just took it a little further to account for changes in k and base and to add the twin/triplet/quad odds calculations. (The k makes very little difference except at very low values of n.) Gary 
20071201, 09:45  #2 
Sep 2004
2·5·283 Posts 
That's a very useful tool. Thanks!

20071201, 21:33  #3 
"Jason Goatcher"
Mar 2005
3·7·167 Posts 
If I may ask a stupid question, what is the best way to run this? I've tried various things in Linux and none of them worked. Googling was an exercise in frustration, there's lot's of php stuff but I'm not totally sure what I'm looking for.

20071201, 21:44  #4 
Jul 2007
Tennessee
2^{5}×19 Posts 
OpenOffice spreadsheet?

20071202, 21:43  #5 
May 2007
Kansas; USA
2×3×11×157 Posts 
It's a Microsoft Excel spreadsheet. If you have Excel, just open the zip file and doubleclick the spreadsheet and it should open. If you don't have Excel, you would need to get it.

20071203, 04:23  #6 
A Sunny Moo
Aug 2007
USA (GMT5)
1100001101001_{2} Posts 

20101013, 13:47  #7 
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
17×251 Posts 
The odds of prime spreadsheet is very useful, but when the n (or, to a lesser extent, the k) varies greatly, (as is common in CRUS work, or over large areas of any work) it is hard to choose the right average n to get accurate results.
I've made a simple command line Java app that has the same function as the odds of prime spreadsheet, but instead of making you pick the average k and n, it reads each k/n pair and works off of that. It reports relevant numbers for primes and twin primes (not triplet or quadruplet). It is attached as a .jar, along with the source (it's not commented, and it includes some other code unused here, but I figured better messy source than no source ). Run it without any arguments (or with h or whatever) to get help on how to use it ("java jar calcPrimes.jar" will do it). Note that it is pretty picky with the sieve depth and sieve file. The sieve depth parser is extremely simple: first replace "G" with 9 zeroes and "T" with 12 zeroes, then use Java's Long.parseLong (e.g. 1.5*10^12, 1.5T, and 15M are all invalid, while 1T, 1500G, and 15000000 are valid). And the sieve file must be in NewPGen format ("k n" on each line) with no header of any sort, just the k and n. This has had very little testing, but I've checked it against the spreadsheet on one file, and the results seems to be accurate. 
20101013, 17:04  #8 
Just call me Henry
"David"
Sep 2007
Cambridge (GMT/BST)
5,869 Posts 
Nice program. Could you make it ignore header lines(or read the stuff from them)?
Last fiddled with by henryzz on 20101013 at 17:48 
20101013, 20:33  #9 
Account Deleted
"Tim Sorbera"
Aug 2006
San Antonio, TX USA
4267_{10} Posts 
Done, attached, along with cleaner and slightlycommented code. Run it without any arguments to see how it works now. In short, "java jar calcPrimes.jar filePath [sieveDepth]" where filePath is a NewPGenlike file with a header with the necessary info, and the sieve depth can optionally be manually set by sieveDepth.

20101014, 06:36  #10  
Just call me Henry
"David"
Sep 2007
Cambridge (GMT/BST)
16ED_{16} Posts 
Quote:


20101014, 11:27  #11 
Feb 2003
2^{2}·3^{2}·53 Posts 
That's a really useful tool!
Thank you, MiniGeek! 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Status page with expected number of Mersenne primes in each interval?  CRGreathouse  PrimeNet  2  20180110 06:13 
The expected number of primes  Batalov  Computer Science & Computational Number Theory  5  20160811 01:17 
Expected number of primes in OEIS A007908  ewmayer  Probability & Probabilistic Number Theory  6  20151110 16:33 
I get 13% less primes than I expected:(  mart_r  Math  2  20101029 17:31 
Twin primes expected first k formula  robert44444uk  Math  18  20080402 21:19 