An example used to compute cell probabilities in a 2x2 table
Case study:
We have two groups ('psychotic' and 'other disorder'); 25% of cases of disorders are expected to be psychotic and 35% of cases are expected to be able to make informed decisions about their medical treatment ie have capacity. Given 10% more of the other disorders are expected to have capacity how many people with a disorder do we need to sample to have 80% power and a onetailed type I error rate of 5%?
If 25% of people with disorders are psychotic that means there are three times as many people with disorders other than psychosis than have psychosis. Ratio other disorders:psychosis = 3.
If a total of 35% have capacity and 10% more of the other disorders have capacity then for p1, the probability of a psychotic case having capacity it follows
0.35 = 0.25 p1 + 0.75 (p1 + 0.1) so p1 = 0.275, p2 = 0.275 + 0.1 = 0.375.
We can input into the power calculator for comparing two independent proportions
p1 = 0.275, p2 = 0.375, ratio (group 2: group1) = 3, power = 0.80, type I error (twotailed) = 0.1 giving 771 cases required.

Capacity 
No Capacity 

Psychotic 
0.275 
0.725 

Other disorders 
0.375 
0.625 
becomes the contingency table (with probabilities summing to 1 and apriori marginals) below upon multiplying the top row by 0.25 and the bottom row by 0.75 which gives P(Psychotic) = 0.25 = 1  P(Having a disorder other than Psychosis) and P(capacity) = 0.35 = 1  P(no capacity)

Capacity 
No Capacity 

Psychotic 
0.0688 
0.1812 

Other disorders 
0.2813 
0.4688 
so for example 0.0688/(0.0688+0.1812) = 0.25 of psychotics have capacity and 0.2813/(0.2813+0.4688) = 0.375 of those with another disorder have capacity.