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

Login

Username

Password

Not registered yet?

#26 2012-07-30 06:16:11

bobbym
Administrator

Online

Re: An expectation problem:

Yes, it is quite small.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#27 2012-07-30 06:17:39

anonimnystefy
Real Member

Offline

Re: An expectation problem:

How small?


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

#28 2012-07-30 06:20:33

bobbym
Administrator

Online

Re: An expectation problem:

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 have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#29 2012-07-30 06:24:25

anonimnystefy
Real Member

Offline

Re: An expectation problem:

Oh. Okay.


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

#30 2012-07-30 06:26:22

bobbym
Administrator

Online

Re: An expectation problem:

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 have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#31 2012-07-30 16:56:21

phrontister
Real Member

Offline

Re: An expectation problem:

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

#32 2012-07-30 17:52:40

anonimnystefy
Real Member

Offline

Re: An expectation problem:

Hi phrontister

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


The limit operator is just an excuse for doing something you know you can't.
“It's the subject that nobody knows anything about that we can all talk about!” ― Richard Feynman
“Taking a new step, uttering a new word, is what people fear most.” ― Fyodor Dostoyevsky, Crime and Punishment

#33 2012-07-30 21:11:39

bobbym
Administrator

Online

Re: An expectation problem:

Hi phrontister;

I got a shade over 223 also.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#34 2012-07-30 23:44:11

phrontister
Real Member

Offline

Re: An expectation problem:

Hi Bobby,

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

My initial code was slow because I was testing for '200 ones' from the first pick ( sad ), 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.

Code:

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-04 18: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

#35 2012-07-31 01:39:48

bobbym
Administrator

Online

Re: An expectation problem:

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.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#36 2012-07-31 01:48:34

phrontister
Real Member

Offline

Re: An expectation problem:

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. smile


"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

#37 2012-07-31 01:55:30

bobbym
Administrator

Online

Re: An expectation problem:

Hi;

Go at your own pace. You did well.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#38 2013-09-02 23:04:06

gAr
Star Member

Offline

Re: An expectation problem:

J:

Code:

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."

#39 2013-09-02 23:11:25

bobbym
Administrator

Online

Re: An expectation problem:

Hi gAr;

What was your time?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#40 2013-09-02 23:58:45

gAr
Star Member

Offline

Re: An expectation problem:

Hi bobbym,

About 15.8 seconds for 10000 trials.


Code:

(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."

#41 2013-09-03 00:27:07

bobbym
Administrator

Online

Re: An expectation problem:

Hi;

Okay, thanks.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#42 2013-09-03 00:34:51

gAr
Star Member

Offline

Re: An expectation problem:

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."

#43 2013-09-03 00:59:47

bobbym
Administrator

Online

Re: An expectation problem:

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.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#44 2013-09-03 01:10:47

gAr
Star Member

Offline

Re: An expectation problem:

That's okay, he has mentioned his time for simulation.
I thought you had posted your code in this thread.


"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."

#45 2013-09-03 01:16:10

bobbym
Administrator

Online

Re: An expectation problem:

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.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#46 2013-09-03 01:19:27

gAr
Star Member

Offline

Re: An expectation problem:

That's right.


"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."

#47 2013-12-09 03:41:39

gAr
Star Member

Offline

Re: An expectation problem:

Loopless J code, about 30x faster:

Code:

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

"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."

Board footer

Powered by FluxBB