Generating random finite groups

I would like a method to efficiently generate a random finite group of a given order $n$. If there are $g(n)$ non-isomorphic groups of order $n$, ideally each group would occur with probability $1/g(n)$. So if $n=64$, each of the $267$ groups would be generated with equal probability. ($g(n)$ is A000001 in OEIS.) Groups of order $n=2^k$ would be of special interest.

This is far from my expertise, and my searches must be using the wrong terminology, because I have not found such methods. I'd appreciate pointers—Thanks!

Addendum. The comments indicate that this appears to be an open problem, with little chance of resolution in the near future. Now so tagged.

-
You may want to weight groups by their automorphism groups. That is, if $a(G)$ denotes $1/\#\text{Aut}(G)$, and $b(n)$ is the sum of $a(G)$ over all groups $G$ of order $n$, then have an order-$n$ group $G$ occur with probability $a(G)/b(n)$. This is the philosophy behind the Cohen-Lenstra heuristics. For instance, see Qiaochu Yuan's answer to mathoverflow.146861. – Michael Zieve May 2 '14 at 11:58
This sounds very pessimistic, but I would be very surprised if there were any reasonably accurate way of doing that except in cases where it is possible to produce a complete list of all groups of order $n$. It would be challenging to come up with any plausible ideas for this for groups of order a power of $2$, and even if you could do so, the results would be dependent on unproved conjectures that "almost all" such groups are $2$-step nilpotent with elementary abelian layers. – Derek Holt May 2 '14 at 13:16
When I was a student, I thought about the problem of generating a random group in search of an improvement of the Elliptic Curves Method (ECM) for factoring integers. The idea was that since most finite groups are 2-groups, in particular one would almost always hit a group with smooth order, and hence under reasonable circumstances obtain a factorization almost instantly -- in contrast to ECM, which uses abelian groups only. However, thinking a bit more about the issue, I realized the problems with feasibility ... . – Stefan Kohl May 2 '14 at 13:47
As other have said, getting a uniform distribution on groups of order $n$ looks unlikely. Most groups of order $n$ are nilpotent, and most nilpotent ones have class at most $2$- these statements can be made reasonably precise. – Geoff Robinson May 2 '14 at 14:32
This is related in spirit :) mathoverflow.net/questions/36735/… – Gjergji Zaimi Jul 9 '15 at 1:29

Are you running computer experiments to verify conjectures? If so, the GAP SmallGroups library will give you exactly what you want up to $n = 1023$.

For example, the GAP commands

  n:=16;; G:=SmallGroup(n, Random(1,NumberSmallGroups(n)));

will return you a group chosen uniformly at random from the groups of order $n=16$. Similar commands will work up to $n=1023$. Indeed, it will work for also for all orders up to 2000 except for 1024, and for a considerable number of other orders.

You might also find the SmallGroups library web page to be helpful:
http://www.icm.tu-bs.de/ag_algebra/software/small/

It describes some of the methods involved. If you're willing to select a group uniformly at random from a subcollection of all the groups of order $2^k$, then there are several papers on groups of order $2^k$ (for varying values of $k$) cited there. Applying the methods therein might be enough for you, depending on what your specific needs are.

-
As there are $49487365422 \approx 5 \times 10^{10}$ groups of order $2^{10}$, it is reasonable for GAP to pass over $1024$! – Joseph O'Rourke Jul 13 '15 at 13:04
Indeed, GAP even knows the count of these groups with NumberSmallGroups (but it won't let you get at the groups themselves via the SmallGroups library). – Russ Woodroofe Jul 13 '15 at 13:07
You may be interested also in SmallGroupsInformation function - it gives some more details how the groups of a given order are sorted in the library. – Alexander Konovalov Jul 14 '15 at 15:03

Here is a stupid approach: Fill in a $n\times n$ multiplication table randomly, then check whether if satisfies the properties of a group.

(The hard part is associativity, apart from that we basically want our multiplication table to be a "magic square", maybe there's more efficient ways to uniformly generate magic squares, and then only check associativity).

Repeat until you actually get a group.

The end result should be uniformly distributed over all group multiplication tables, and since each group $G$ admits $(n-1)!/\left|Aut(G)\right|$ different multiplication tables, this leads to a distribution as described in Michael Zieve's comment.

This is of course far from practical, but illustrates that what you want is, in principle, possible.

-
Somewhat related: "How many binary operations are associative?." – Joseph O'Rourke Jul 13 '15 at 13:07
It's not clear to me that the procedure described above wouldn't favor certain isomorphism classes. The original question wanted an equal chance at each isomorphism class of groups of order $n$. – Russ Woodroofe Jul 13 '15 at 13:10
Yeah, it doesn't do that, as I explained. Rather, it weights the probability of each isomorphism class by the inverse of the order of the automorphism group, as I explained. (Which is apparently the more natural thing according to Michael Zieve's comment) – Achim Krause Jul 13 '15 at 21:39