# What transformation should I use for a bimodal distribution?

I have some bimodal data like the one generated down (R language), and I don't know how to transform it to have a normal distribution or homoscedasticity. I'm running a linear discriminant analysis and I need homoscedasticity, but I'm not able to get it with this kind of distribution. Do you have an alternative to this problem?

Generating fake data

x = rnorm(100, mean = 10, sd = 2)
y = rnorm(100, mean = 20, sd = 2)
bimodal =c(x,y)
shapiro.test(bimodal)
hist(bimodal)


Transformation with Box-Cox

library(geoR)
lambda=boxcoxfit(bimodal)\$lambda
bin.tr.bc=((bimodal^lambda)-1)/(lambda)

shapiro.test(bin.tr.bc)
hist(bin.tr.bc)


Log

shapiro.test(log(bimodal))
hist(log(bimodal))


Square root

shapiro.test(sqrt(bimodal))
hist(sqrt(bimodal))


Log squared

shapiro.test((log(bimodal))^2)
hist((log(bimodal))^2)


log exponent 1.5

shapiro.test((log(bimodal))^1.5)
hist((log(bimodal))^1.5)


Cube root

shapiro.test((bimodal)^(1/3))
hist((bimodal)^(1/3))


Desperate arcsin complex transformation

shapiro.test(asin((bimodal/max(bimodal))^(1/2)))
hist(asin((bimodal/max(bimodal))^(1/2)))

• I thought that for any discrimination analysis you would want the opposite of unimodality: bimodality is one indication that a simple discrimination function is likely to work well! – whuber Apr 25 '16 at 21:41
• That sounds right! Haha. But then, is there a way to make the data more homoscedastic? – M. Beausoleil Apr 25 '16 at 23:17

Your variable binomial is not binomial. Did you mean bimodal?

Try this:

transformed <- abs(binomial - mean(binomial))
shapiro.test(transformed)
hist(transformed)


which produces something close to a slightly censored normal distribution and (depending on your seed)

        Shapiro-Wilk normality test

data:  transformed
W = 0.98961, p-value = 0.1564


In general, arbitrary transformations are difficult to justify. You need a reason for doing this sort of thing, independent of the actual data

• You're right, it's bimodal. The thing is that I want to predict new value with my linear discriminant analysis (LDA). So it's not possible to run something that calculates the mean. For example, if i'm putting log(oxygen) in my model, then I can calculate log(new_oxygen_value) and feed it to my model so that I know to which group it's belonging. – M. Beausoleil Apr 25 '16 at 20:42
• @M.Beausoleil - in that case you really do not want to remove the bimodality, as it will reduce the discrimination of your analysis – Henry Apr 25 '16 at 20:51
• The problem in my data is that it's not homoscedastic. So I'd like to apply something to make it homoscedastic and use the LDA. Beside normalization, I don't know what could be possible... – M. Beausoleil Apr 25 '16 at 23:09
• @Henry What was the intuition behind abs(binomial - mean(binomial)) ? How did you figure that out? Is it a standard method or adhoc ? – talegari Sep 6 '17 at 7:23
• @talegari: it is not a standard transformation, but looking at the mixture distribution, it was a simple way in this case of superimposing the two modes to make a single mode. It would not have worked so well if there there had been differing numbers of observations from the two original normals or if they had had different standard deviations – Henry Sep 6 '17 at 8:09

No monotonic transformation can do what you wish and a non-monotonic transformation is usually a bad idea. Typically, you should model the bimodality either empirically or with a mixture model.

For example, place a point into the left lobe or right lobe with an indicator variable as though two processes are generating two different distributions but you can only see the combined result. Without knowing more about your problem, I don't have any more particular suggestions.