How to generate a $\pm 1$ sequence with mean $0.05$? I know how to generate a $\pm 1$ sequence with mean $0$. For example, in Matlab, if I want to generate a $\pm 1$ sequence of length $10000$, it is:
2*(rand(1, 10000, 1)<=.5)-1

However, how to generate a $\pm 1$ sequence with mean $0.05$, i.e., with $1$ being slightly preferred?
 A: Generate $N$ samples uniformly from $[0,1]$, recode numbers lower than 0.525 to 1 and rest to -1.
Then your expected value is
$1 \cdot 0.525 + (-1)\cdot (1-0.525) = 0.525 - 0.475 = 0.05$
I'm not a Matlab user, but I guess it sholud be
2*(rand(1, 10000, 1)<=.525)-1

A: You need to generate more 1s than -1s. Precisely, 5% more 1s because you want your mean to be 0.05. So, you increase the probability of 1s by 2.5% and decrease -1s by 2.5%. In your code it's equivalent to changing 0.5 to 0.525, i.e. from 50% to 52.5%
A: Your desired mean is given by equation:
$\frac{N\cdot p - N \cdot (1-p)}{N} = .05$
from which follows that the probability of the 1s should be .525
In Python:
x = np.random.choice([-1,1], size=int(1e6), replace = True, p = [.475, .525])

Proof:
x.mean()
0.050742000000000002

1'000 experiments with 1'000'000 samples of 1s and -1s:

For the sake of completeness (hat tip to @Elvis ):
import scipy.stats as st
x = 2*st.binom(1, .525).rvs(1000000) - 1
x.mean()
0.053859999999999998

1'000 experiments with 1'000'000 samples of 1s and -1s:

And finally drawing from uniform distribution, as suggested by @Łukasz Deryło (also, in Python):
u = st.uniform(0,1).rvs(1000000)
x = 2*(u<.525) -1
x.mean()
0.049585999999999998

1'000 experiments with 1'000'000 samples of 1s and -1s:

All the three look virtually identical!
EDIT
Couple of lines on Central limit theorem and the spread of resulting distributions.
First of all, the draws of means indeed follow Normal Distribution.
Second, @Elvis in his comment to this answer did some nice calculations on the exact spread of the means drawn over 1'000 experiments (circa (0.048;0.052)), 95% confidence interval.
And these are results of the simulations, to confirm his results:
mn = []
for _ in range(1000):
    mn.append((2*st.binom(1, .525).rvs(1000000) - 1).mean())
np.percentile(mn, [2.5,97.5])
array([ 0.0480773,  0.0518703])

A: A variable with values $-1$ and $1$ is of the form $Y = 2X - 1$ with $X$ a Bernoulli with parameter $p$. Its expected value is $E(Y) = 2 E(X) - 1 = 2p - 1$, so you know how to obtain $p$ (here $p = 0.525$).
In R you can generate Bernoulli variables with rbinom(n, size = 1, prob = p), so for example
x <- rbinom(100, 1, 0.525)
y <- 2*x-1

