Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Yes, it is quite small.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,796

How small?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

I do not know. But looking at the data the values are very close.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,796

Oh. Okay.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

To get the sd we would have to run the simulation many times and use the formula. But by inspection you can see the dispersion is going to be small.

**In mathematics, you don't understand things. You just get used to them.**

**I agree with you regarding the satisfaction and importance of actually computing some numbers. I can't tell you how often I see time and money wasted because someone didn't bother to run the numbers.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,933

Hi Bobby and stefy,

I've run several 10,000-cycle simulations in LB and each result was a smidge over 223.0. The result of a 100,000 cycle was 223.03524.

My Excel results varied more, but all were still only just < or > 223. I only tested up to about 1,000 cycles, which would account for the variation difference between the two programs.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 15,796

Hi phrontister

I started running 10 100000-cycles, but I wasn't at the computer long enough to check.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Hi phrontister;

I got a shade over 223 also.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,933

Hi Bobby,

Here's my M code. As you'll see, I was thinking LB while coding M...but it works.

My initial code was slow because I was testing for '200 ones' from the first pick ( ), but changing the test to commence after 199 picks reduced processing time to 1/7th of previous.

My LB code for 100,000 cycles took well over 9 hours c.f. M's 271 seconds.

```
In[1]:= Timing[sum = 0; c = 0; s = Table[0, {1000}];
N[While[c < 100000, t = 199; ss = s;
Do[ss[[RandomInteger[{1, 1000}]]] = 1, {t}]
While[Count[ss, 1] < 200, ss[[RandomInteger[{1, 1000}]]] = 1;t++];
sum = sum + t; c++]; sum/c]]
Out[1]= {270.985, 223.00152}
```

So, again, just a touch > 223.

*Last edited by phrontister (2012-08-03 20:23:22)*

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Hi phrontister;

That is fine. It is okay to go from one language to another looking for the same type of commands in each language.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**phrontister****Real Member**- From: The Land of Tomorrow
- Registered: 2009-07-12
- Posts: 3,933

Hi Bobby,

That's really the only way I'll get anywhere with M for now. Anything that would require more dedicated study effort will have to wait until I get more time to be able to spend at it...but little by little I'm picking a few things up. Thanks for dangling the "extra credit" carrot...it motivated me.

"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Hi;

Go at your own pace. You did well.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

J:

```
sim =: monad define
cnt =: 0
a =: y$0
while. (+/a) < 200 do.
a =: 1 (?y)} a
cnt =: cnt + 1
end.
return. cnt
)
(+/%#) (sim "0) 1000$1000 NB. (sim&+) also works
```

≈ 223.024

There may be a way to eliminate the loop and speed up.

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Hi gAr;

What was your time?

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Hi bobbym,

About 15.8 seconds for 10000 trials.

`(6!:2) '%. (+/%#) (sim "0) 10000$1000' NB. gets the running time`

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Hi;

Okay, thanks.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

What's the time taken by the mathematica code?

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

Hi;

I do not know, I never ran a simulation of this one that did not use the answer to speed it up.

I am trying phrontister's code.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

That's okay, he has mentioned his time for simulation.

I thought you had posted your code in this thread.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 91,501

His code will do about 30 seconds but it is procedural and does not make use of the faster functional paradigm. Also it is not compiled.

**In mathematics, you don't understand things. You just get used to them.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

That's right.

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Loopless J code, about 30x faster:

```
sim =: 3 : '1+{.I.200=+/\~:?1000#1000'
(+/%#)(sim "0) 100000#0
```

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline