signed_bernoulli2(N​,p1,p2,r)

Generate and Sample Two Signed Bernoulli Variables with Given Correlation

You are now following this Submission

The function first constructs two(2) signed {-1, +1} Bernoulli variables Y_1, Y_2 such that p(Y_1 = -1) = p1, p(Y_2 = -1) = p2, and E[Y_1Y_2] = r. Constraints: 0 < p1,p2 < 1, -1 < r < 1. Next, it draws N realizations of the two variables in Y(m,:), m = 1,2. The sample pdf and cross correlation converge as N -> infinity (obviously).
Example: generate N realizations of variables with mean 0, variance 1, and correlation 0.3: Y = signed_bernoulli2(N,0.5,0.5,0.3).

Cite As

Aravindh Krishnamoorthy (2026). signed_bernoulli2(N,p1,p2,r) (https://www.mathworks.com/matlabcentral/fileexchange/65164-signed_bernoulli2-n-p1-p2-r), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0