15,968,353 members
0.00/5 (No votes)
See more:
Inhave to get probability mass function of length of first continuous string of 0 in a string of 0s and 1s.

Eg: 1,1,0,0,0,1,1,0,1 ... the length of first continuous string of zeros is 3. Please help ASAP. It will turn out to be Geometric. I am new to it and cannot simulate it properly.

What I have tried:

I created a random string of 0's and 1s and tried to iterate over it to find 0, 1, 2 etc length of string but that does not turn out to be geometric in plot. Please help.
Posted
Updated 26-Nov-22 18:08pm
v3
Comments
Richard MacCutchan 26-Nov-22 15:30pm
Exactly what help do you need? If there is a problem in your code then please provide full details.
Dave Kreskowiak 27-Nov-22 9:51am
Destroying your question is frowned upon.

## Solution 1

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 Richard Deeming 95 Pete O'Hanlon 85 Luc Pattyn 50 OriginalGriff 23 Member 16338716 10
 OriginalGriff 361 Pete O'Hanlon 265 Dave Kreskowiak 155 merano99 115 Richard Deeming 95

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900