user
This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.

A new medical treatment was tested on a population of 

n
+
m
{\displaystyle {\displaystyle n+m}}
volunteers, with each volunteer randomly assigned either to a group of

n
{\displaystyle {\displaystyle n}}
 treatment subjects, or to a group of 

m
{\displaystyle {\displaystyle m}}
 control subjects.

Members of the treatment group were given the treatment,
and members of the control group were given a placebo.
The effect of the treatment or placebo on each volunteer
was measured and reported in this table.

:   :   :   :   :   :   :   Table of experimental results

                            | Treatment group | Control group |
                            | --- | --- |
                            | 85 | 68 |
                            | 88 | 41 |
                            | 75 | 10 |
                            | 66 | 49 |
                            | 25 | 16 |
                            | 29 | 65 |
                            | 83 | 32 |
                            | 39 | 92 |
                            | 97 | 28 |
                            |  | 98 |

Write a program that performs a
permutation test to judge
whether the treatment had a significantly stronger effect than the
placebo.

* Do this by considering every possible alternative assignment from the same pool of volunteers to a treatment group of size 

  n
  {\displaystyle {\displaystyle n}}
   and a control group of size 

  m
  {\displaystyle {\displaystyle m}}
   (i.e., the same group sizes used in the actual experiment but with the group members chosen differently), while assuming that each volunteer's effect remains constant regardless.
* Note that the number of alternatives will be the binomial coefficient 

  (


  n
  +
  m
  n

  )
  {\displaystyle {\displaystyle {\tbinom {n+m}{n}}}}
  .
* Compute the mean effect for each group and the difference in means between the groups in every case by subtracting the mean of the control group from the mean of the treatment group.
* Report the percentage of alternative groupings for which the difference in means is less or equal to the actual experimentally observed difference in means, and the percentage for which it is greater.
* Note that they should sum to 100%.

Extremely dissimilar values are evidence of an effect not entirely due
to chance, but your program need not draw any conclusions.

You may assume the experimental data are known at compile time if
that's easier than loading them at run time. Test your solution on the
data given above.
assistant
(formerly Perl 6)
The use of `.race` to allow concurrent calculations means that multiple 'workers' will be updating `@trials` simultaneously. To avoid race conditions, the `⚛++` operator is used, which guarantees safe updates without the use of locks. That is turn requires declaring that array as being composed of `atomicint`.

**Works with**: Rakudo version 2018.09

```
sub stats ( @test, @all ) {
    ([+] @test / +@test) - ([+] flat @all, (@test X* -1)) / @all - @test
}

my int @treated = <85 88 75 66 25 29 83 39 97>;
my int @control = <68 41 10 49 16 65 32 92 28 98>;
my int @all = flat @treated, @control;

my $base = stats( @treated, @all );

my atomicint @trials[3] = 0, 0, 0;

@all.combinations(+@treated).race.map: { @trials[ 1 + ( stats( $_, @all ) <=> $base ) ]⚛++ }

say 'Counts: <, =, > ', @trials;
say 'Less than    : %', 100 * @trials[0] / [+] @trials;
say 'Equal to     : %', 100 * @trials[1] / [+] @trials;
say 'Greater than : %', 100 * @trials[2] / [+] @trials;
say 'Less or Equal: %', 100 * ( [+] @trials[0,1] ) / [+] @trials;

```

Output:

```
Counts: <, =, > 80238 313 11827
Less than    : %86.858343
Equal to     : %0.338825
Greater than : %12.802832
Less or Equal: %87.197168

```