Re: random distribution of number sequences



In article <ef113aa.1@xxxxxxxxxxxxxxxx>, Hubsi <huebchen@xxxxxx> wrote:

> thanx a lot!
> your right, it was my fault! i have mistake 1 for 0. Now i ll try it
> once more:
> i need a function (for a drop out function) which consists of ones
> and zeros. the percentage of zeros / ones can be entered. for
> example: 70% ones and 30% zeros. these 30% zeros are again divided
> into different percentages of sequences of zeros. for example: 5% of
> [0], 10% of [0 0], and so on, up to 100% of the 30% zeros. the
> sequences should be stochastical (within the 30%).
> i hope my question is now understandable...

Yeah, but I like your other question better. It was soooo
easy to answer. ;-) This question is not so easy.

I'd start by focusing on the sub-sequence order of "arrival"
and the total number of subsequences. If we know the total
number of sub-sequences, then we can back out the total
expected sample time, or go in the other direction.

So if we choose to sample n sub-sequences of all zeros,
suppose they will have lengths and probabilities:

sequence_lengths = [1 2 3 4];
P_zero = [.4 .2 .3 .1];

Now choose the order of n sub-sequences.

n = 500;
r = rand(1,n);
[junk,sind] = histc(r,cumsum([0,P_zero]));

seq_len = sequence_length(sind);

The total number of zeros in all of these sequences
will be sum(seq_len). So we can compute the total
length of the overall sequence as (approximately)

fraction_zero = 0.3;
overall_length = sum(seq_len)/fraction_zero;

We need to step back here and consider our goals
again. What is the distribution of ones between
sub-sequences of zero? There can be subtle variations
in our choice here. I'll be arbitrary though.

total_ones = overall_length - sum(seq_len);

Lets build up the complete sequence. Partition the
ones in our sequence into random chunks, a total of
n+1 of them. What I really want here is a partition
of the integer total_ones into exactly n+1 positive
integers. The approach I take here is a hack.

seq_ones = round(diff(sort(rand(1,n+1)*total_ones)));
seq_ones(seq_ones==0) = 1;

Now lets build up the complete sequence.

sequence = ones(1,sum(seq_len) + sum(seq_ones));
L = 0;
for i = 1:n;
L = L + seq_ones(i);
sequence(L+(1:seq_len(i))) = 0;
L = L + seq_len(i);
end

As a check, the total nomber of ones should be roughly
70% of the overall sequence.

sum(sequence)/3559
ans =
0.7036

At this point, feel free to shorten the sequence, or
append more to get a sequence of a given length.

John


--
The best material model of a cat is another, or
preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945
.



Relevant Pages

  • Re: Reducing Pseudorandomness
    ... I have a case where I need a pseudorandom number generated. ... the sequence can be generated very efficiently by a device called ... a linear shift register, by initializing ... the register to contain any seqeunce of n-bits (the all zeros being ...
    (comp.lang.pascal.delphi.misc)
  • Re: Why dont we just zero out FFT bins?
    ... supress and replace those bins in the FFT with zeros? ... append the time sequence from the IFFT with a bunch of zeros. ... let's say that you could create a filter with "brick wall" transitions ...
    (comp.dsp)
  • Re: Request for Review of ZF Inconsistency Proof
    ... denote the infinite set of denumerable binary strings with alphabet ... sequence of 0s and 1s (or alternatively, ... "tail of zeros"), via reverse binary notation. ...
    (sci.logic)
  • Re: 8 Bit Random Numbers
    ... only 1016 "zeros" for each complete cycle, since 8 zeros are left out. ... which approach would you say is more linear? ... The XOR gates are run in parallel rather than in serial, ... For your original sequence of 3,4,5,7, use 0xB8 or 0x1D, depending upon ...
    (sci.electronics.basics)
  • Re: Special Matrix examples??? Properties/Coding
    ... > I have three seperate matrices which I am sure are special cases and ... or context, a matrix is just well, a matrix. ... sequence of matrices has. ... The best material model of a cat is another, or preferably the same, cat. ...
    (comp.soft-sys.matlab)

Loading