how to generate samples uisng pseudo random generator

how to generate xor samples using pseudo random number generator

2 Kommentare

doc rand % and friends for the RNGs in Matlab
what, and how, xor comes into play is totally unclear from what little was provided.
XOR input samples were generated by using a threshold function for 1000 values from a uniformly distributed pseudorandom number generator. The threshold function had a threshold level of 0.5. Sample = ( 1 ; value > 0:5 0 ; value >= 0:5

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Star Strider
Star Strider am 27 Aug. 2014
I am not certain that I understand what you want to do, but I will make an attempt at answering:
nrows = 5;
s = logical(randi(2, nrows, 2)-1);
out = xor(s(:,1),s(:,2));

4 Kommentare

XOR input samples were generated by using a threshold function for 1000 values from a uniformly distributed pseudorandom number generator. The threshold function had a threshold level of 0.5. Sample = ( 1 ; value > 0:5 0 ; value >= 0:5
If you need a uniform continuous vector of 1000 samples:
rv = rand(1000,1); % Column vector
This doesn’t make sense, though:
( 1 ; value > 0:5 0 ; value >= 0:5
You probably mean:
rn = [0*(rv <= 0.5) + 1*(rv > 0.5)]; % rv converted to (0,1)
value is 1 when sample value greater than 0.5 and 0 when it is less than or equal to 0.5
That is exactly what ‘rn’ does. (The original continuous vector is ‘rv’.)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kategorien

Mehr zu Random Number Generation finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by