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

You are not logged in.

#1 2013-03-07 14:59:55

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Simulations

Hi;

This problem appears in the Devore book "Probability and Statistics" and has various answers on the internet.

The weekly demand for propane gas (in thousands of gallons) from a particular facility is a random variable X with PDF

What is the expected usage for gas for the coming week?

A number of different answers are given. How can we get the answer using a CAS and simulating the process?

1) Define the PDF in mathematica as:

myPDF[]=ProbabilityDistribution[2(1-1/x^2),{x,1,2}];

2) Run the simulation a million times.

data=RandomVariate[myPDF[],10^6];

Below is a histogram of data.

3) Get the expected value:

Mean[data]

1.61357 is returned. So the facility expects to use about 1613 gallons of propane this week.

View Image: 2013-03-07_184646.gif

Last edited by bobbym (2013-03-07 15:35:57)


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#2 2013-03-07 21:04:34

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

Re: Simulations

And it agrees with my answer of 3-2ln(2).


“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

Offline

#3 2013-03-07 21:12:25

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

More importantly were you able to duplicate the answer with your package?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#4 2013-03-07 21:14:32

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

Re: Simulations

I will try later.


“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

Offline

#5 2013-03-07 21:17:50

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

Okay, you will find it interesting.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#6 2013-03-07 21:57:29

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

Re: Simulations

What kind of distribution would that be?


“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

Offline

#7 2013-03-07 22:08:50

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

The one given in post #1 of course!


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#8 2013-03-07 22:11:16

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

Re: Simulations

Yes, but what kind is it? Maxima needs me to specify if it is a normal, geometrical, exponential,...


“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

Offline

#9 2013-03-07 22:36:38

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

It is none of them.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#10 2013-03-07 22:41:35

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

Re: Simulations

I am not sure how to do it, then.


“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

Offline

#11 2013-03-07 22:43:05

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

Would you like one way how?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#12 2013-03-07 22:45:55

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

Re: Simulations

Yes.


“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

Offline

#13 2013-03-07 22:49:02

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

Hi;

I am playing with a method right now but do not have all the kinks ironed out of it. I will post what I have.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#14 2013-03-07 22:50:20

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

Re: Simulations

That is 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

Offline

#15 2013-03-07 23:02:23

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

I want to draw random numbers from the PDF y = 3x^2 from 0 to 1.

So I solve for x

Follow?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#16 2013-03-07 23:02:56

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

Re: Simulations

Yes.


“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

Offline

#17 2013-03-07 23:08:25

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

Then I take the RHS of that equation where I solved for x and integrate wrt y.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#18 2013-03-07 23:12:27

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

Re: Simulations

Okay. What now?


“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

Offline

#19 2013-03-07 23:13:42

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

I replace each y in the answer with a random variable that is uniformly distributed between 0 and 1.


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#20 2013-03-07 23:31:29

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

Re: Simulations

Hm, why does it work?


“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

Offline

#21 2013-03-07 23:33:31

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

It doesn't, I think I have it now though. To follow you must know how to generate random numbers between a and b in maxima. Do you follow?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#22 2013-03-07 23:36:42

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

Re: Simulations

Yes. I have the function.


“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

Offline

#23 2013-03-07 23:38:30

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

Okay a little theory before we go any further. If you generate 10000 random numbers between 0 and 1 what do you call that distribution?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

#24 2013-03-07 23:40:37

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

Re: Simulations

Uniform.


“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

Offline

#25 2013-03-07 23:41:31

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 87,267

Re: Simulations

You will need to know how to get a histogram of those 10000 points with 10 boxes. Do you know how?


In mathematics, you don't understand things. You just get used to them.
Of course that result can be rigorously obtained, but who cares?
Combinatorics is Algebra and Algebra is Combinatorics.

Online

Board footer

Powered by FluxBB