# Using Mathematica for Group Statistics

### In this post, a data expert, math whiz, and developer goes through how to work with Mathematica to create graphs for Abelian and non-Abelian groups.

Join the DZone community and get the full member experience.

Join For FreeI just ran across `FiniteGroupData`

and related functions in Mathematica. That would have made some of my earlier posts easier to write had I used this instead of writing my own code.

Here's something I find interesting. For each *n*, look at the groups of order at most *n* and count how many are Abelian versus non-Abelian. At first, there are more Abelian groups, but the non-Abelian groups soon become more numerous. Also, the number of Abelian groups grows smoothly, while the number of non-Abelian groups has big jumps, particularly at powers of 2.

Here's the Mathematica code:

```
fgc = FoldList[Plus, 0, Table[FiniteGroupCount[n], {n, 1, 300}]]
fga = FoldList[Plus, 0, Table[FiniteAbelianGroupCount[n], {n, 1, 300}]]
ListLogPlot[ {fgc - fga, fga },
PlotLegends -> {"Non-Abelian", "Abelian"},
Joined -> True,
AxesLabel -> {"order", "count"}]
```

I see the plot legend on my screen, but when saving the plot to a file the legend wasn't included. Don't know why. The jagged blue curve is the number of non-Abelian groups of size up to *n*. The smooth gold curve is the corresponding curve for Abelian groups.

Here's the same plot carried out further to show the jumps at 512 and 1024.

Published at DZone with permission of John Cook, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Comments