Feb 13, 2019 #1 C Chinmaye Full Member level 3 Joined Jan 18, 2016 Messages 164 Helped 0 Reputation 0 Reaction score 1 Trophy points 1,298 Activity points 3,145 How do i generate a random sequence of 1's and minus -1's in matlab with mean 0?
Feb 13, 2019 #2 pancho_hideboo Advanced Member level 5 Joined Oct 21, 2006 Messages 2,847 Helped 767 Reputation 1,536 Reaction score 733 Trophy points 1,393 Location Real Homeless Activity points 17,490 Code: x0 = 1:40; y0 = 2*int32( randn( size(x0) ) >= 0.0 ) - 1; Also see https://www.edaboard.com/showthread.php?373245#6
Code: x0 = 1:40; y0 = 2*int32( randn( size(x0) ) >= 0.0 ) - 1; Also see https://www.edaboard.com/showthread.php?373245#6
May 18, 2019 #3 C Chinmaye Full Member level 3 Joined Jan 18, 2016 Messages 164 Helped 0 Reputation 0 Reaction score 1 Trophy points 1,298 Activity points 3,145 This doesnt always give a mean of zero
May 18, 2019 #4 W wwfeldman Advanced Member level 4 Joined Jan 25, 2019 Messages 1,102 Helped 231 Reputation 461 Reaction score 298 Trophy points 83 Activity points 8,562 Re: generate random 1's and -1's in matlab the rand function generates uniformly distributed random numbers if you tell it to generate random numbers between 0 and 1, you can convert those less than 0.5 to -1 and those greater than 0.5 to 1
Re: generate random 1's and -1's in matlab the rand function generates uniformly distributed random numbers if you tell it to generate random numbers between 0 and 1, you can convert those less than 0.5 to -1 and those greater than 0.5 to 1
May 18, 2019 #5 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 52,420 Helped 14,749 Reputation 29,780 Reaction score 14,101 Trophy points 1,393 Location Bochum, Germany Activity points 298,099 This doesnt always give a mean of zero Click to expand... By nature of random distribution, an arbitrary selected sample can't have exactly zero mean otherwise it's not random. You may want to specify additional properties of the random distribution, e.g. maximal imbalance for a given sample length.
This doesnt always give a mean of zero Click to expand... By nature of random distribution, an arbitrary selected sample can't have exactly zero mean otherwise it's not random. You may want to specify additional properties of the random distribution, e.g. maximal imbalance for a given sample length.
May 18, 2019 #6 pancho_hideboo Advanced Member level 5 Joined Oct 21, 2006 Messages 2,847 Helped 767 Reputation 1,536 Reaction score 733 Trophy points 1,393 Location Real Homeless Activity points 17,490 Chinmaye said: This doesnt always give a mean of zero Click to expand... If length of random sequence is enough large, average is zero.
Chinmaye said: This doesnt always give a mean of zero Click to expand... If length of random sequence is enough large, average is zero.