mersenneforum.org Odds of prime / expected # of primes
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

2007-12-01, 03:14   #1
gd_barnes

May 2007
Kansas; USA

22×2,593 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
Attached Files
 odds of prime.zip (3.0 KB, 218 views)

 2007-12-01, 09:45 #2 em99010pepe     Sep 2004 2·5·283 Posts That's a very useful tool. Thanks!
 2007-12-01, 21:33 #3 jasong     "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.
 2007-12-01, 21:44 #4 AES   Jul 2007 Tennessee 25×19 Posts OpenOffice spreadsheet?
2007-12-02, 21:43   #5
gd_barnes

May 2007
Kansas; USA

22×2,593 Posts

Quote:
 Originally Posted by jasong 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.
It's a Microsoft Excel spreadsheet. If you have Excel, just open the zip file and double-click the spreadsheet and it should open. If you don't have Excel, you would need to get it.

2007-12-03, 04:23   #6
mdettweiler
A Sunny Moo

Aug 2007
USA (GMT-5)

3·2,083 Posts

Quote:
 Originally Posted by gd_barnes It's a Microsoft Excel spreadsheet. If you have Excel, just open the zip file and double-click the spreadsheet and it should open. If you don't have Excel, you would need to get it.
It seems to work fine for me with OpenOffice on Linux (Ubuntu 7.10).

2010-10-13, 13:47   #7
Mini-Geek
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.
Attached Files
 calcPrimes.zip (4.9 KB, 203 views)

 2010-10-13, 17:04 #8 henryzz Just call me Henry     "David" Sep 2007 Cambridge (GMT/BST) 2·5·587 Posts Nice program. Could you make it ignore header lines(or read the stuff from them)? Last fiddled with by henryzz on 2010-10-13 at 17:48
2010-10-13, 20:33   #9
Mini-Geek
Account Deleted

"Tim Sorbera"
Aug 2006
San Antonio, TX USA

10000101010112 Posts

Quote:
 Originally Posted by henryzz Nice program. Could you make it ignore header lines(or read the stuff from them)?
Done, attached, along with cleaner and slightly-commented code. Run it without any arguments to see how it works now. In short, "java -jar calcPrimes.jar filePath [sieveDepth]" where filePath is a NewPGen-like file with a header with the necessary info, and the sieve depth can optionally be manually set by sieveDepth.
Attached Files
 calcPrimes.zip (5.0 KB, 146 views)

2010-10-14, 06:36   #10
henryzz
Just call me Henry

"David"
Sep 2007
Cambridge (GMT/BST)

2×5×587 Posts

Quote:
 Originally Posted by Mini-Geek Done, attached, along with cleaner and slightly-commented code. Run it without any arguments to see how it works now. In short, "java -jar calcPrimes.jar filePath [sieveDepth]" where filePath is a NewPGen-like file with a header with the necessary info, and the sieve depth can optionally be manually set by sieveDepth.
Brilliant that's a lot less fiddling.

 2010-10-14, 11:27 #11 Thomas11     Feb 2003 77416 Posts That's a really useful tool! Thank you, Mini-Geek!

 Similar Threads Thread Thread Starter Forum Replies Last Post CRGreathouse PrimeNet 2 2018-01-10 06:13 Batalov Computer Science & Computational Number Theory 5 2016-08-11 01:17 ewmayer Probability & Probabilistic Number Theory 6 2015-11-10 16:33 mart_r Math 2 2010-10-29 17:31 robert44444uk Math 18 2008-04-02 21:19

All times are UTC. The time now is 09:26.

Mon May 17 09:26:11 UTC 2021 up 39 days, 4:07, 0 users, load averages: 1.49, 1.47, 1.48