Message Turncoat in a DM to get moderator attention

Users Online(? lurkers):
10 / 27 posts
0 votes

Computational Models


Posts: 2266

This thread will be the first of many I would assume. It specifically will focus on my exploration of different means of creating computational models that I'm using or planning on using for other areas of interest. 

 

Monte Carlo Integration

Monte Carlo integration is merely a means to solve some integral I(f) via the approximation

Posted Image

by means of using stochastic variables (random sampling), where Ω is a sample space containing the random variables  (X,_1, ..., X_m) and f is the density.

That is, 

Posted Image

We will approximate this integral by finding the empirical average via the Strong Law of Large Numbers.

The empirical average is computed as, 

Posted Image

 which converges to E_f[h(x)]  hence it can be used as an approximation. 

The generalized expected value is, 

Posted Image

 

I tested test the Monte Carlo integration on the function h(x) = (cos50x + sin20x)^2 whose graph can be found below. 

Posted Image

To approximate the integral I used the N(0,1) as my random variable and this outputted the following estimation and its error, 

Posted Image

The approximation graphed, 

Posted Image

 

We are also interested in knowing the speed in which  h_m converges to E_f[h(x)].

The rate of convergence be found by evaluating the approximation variance,

Posted Image

Which can be approximated from the random sample (X_1,…,X_m) via

Posted Image

By the Central Limit Theorem for large m,

Posted Image

The variance simplified:

Posted Image

 

We then can map the variance of our approximation which is signaled by the red lines, 

Posted Image

 

The standard deviation is proportional to, 

Posted Image

Hence, m must be quadrupled in order to reduce the variance by half.

 

I explored the proportionality between m and the variance through the approximation of Pi

m = 10,000

Posted Image

Posted Image

m=100,000

Posted Image

Posted Image

m=1,000,000

Posted Image

Posted Image

Posts: 587
0 votes RE: Computational Models

Fancy

Gotta focus... I'm shifting into soup mode...
Posts: 2266
0 votes RE: Computational Models

To add to my previous post, specifically the utilization of Monte Carlo integration to approximate pi, as  I shrank the variance the time it took to complete the convergence became really slow. It turns out the time complexity is O(sqrt(n)), so it's really not all that efficient given the proportionality between m and the variance. Given this issue I've begun to explore ways of speeding up the rate of convergence efficiently.

Importance Sampling

In monte carlo approximation the variance of a particular estimation is a primary concern given variance directly reflects the overall performance of the approximation. The smaller the variance the more accurate our approximation, hence a central issue in monte carlo is minimizing variance. We want to maintain the expected value and reduce variance by utilizing transformative techniques on our observations. 

Importance sampling can be used to create an alternative representation of  E_f[h(x)] which in turn can reduce the variance and maintain the expected value. The transformation of our observations in this case is achieved by changing our density f to some new density g where g is a set of sampled points that fit the integrand shape better than f – our sample mean shrinks and with it so does the variance.

We generate a sample X_1, ... , X_m from the distribution g  from which we get the probability density function g(x) .

Hence we obtain, 

Posted Image

Which is the expected value under density .

As a result the empirical average becomes,

Posted Image

whose convergence is guaranteed by the strong law of large numbers.

Simplified: 

Posted Image

 

To test this I started with the function h(x) = 10*exp(-2*abs(X-5)) and ran 10,000 iterations between in N(0, 10) which resulted, 

Posted Image

So under standard Monte Carlo integration I got a mean of 1.016182 and variance of 4.082602, this puts the expected value in question. 

I then used importance sampling to shrink the variance and improve my result. I still ran 10,000 iteration but now divided the original distribution N(0,10) by the PDF(mean=5, sd=1) which resulted, 

Posted Image

I then worked with the more complicated function h(x) = exp((-(x-3)^2)/2) + exp((-(x-6)^2)/2) and computed 10^3 iterations using standard monte carlo integration across the distribution N(0,1)

Posted Image

Posted Image

Using the standard monte carlo integration to explore the tails of the distribution is practically useless do to its inefficiency in finding such a rare event. I tested the same function  h(x) = exp((-(x-3)^2)/2) + exp((-(x-6)^2)/2) with 10^3 iterations over N(-8,-1) and couldn't get it to converge to the right value. 

Posted Image

To improve our efficiency and as consequence the accuracy of our approximation at the tails we must use importance sampling. In this the distribution will be (4.5, ∞) which reduces the number of necessary iterations and reduces the variance. g then becomes the density of the distribution εxp(1) truncated by 4.5. 

Hence the probability density function is, 

Posted Image

And as a result, the empirical average becomes,

Posted Image

By this process we not only get a convergence between the average and the expected value but also receive a reliable approximation. 

Posted Image

 

Posts: 9306
0 votes RE: Computational Models

https://url4ever.com/robust-computational-model-for-new-state-of-matter-strange-metals/?feed_id=19188&_unique_id=5f2170c2713d7&utm_source=Reddit&utm_medium=admin&utm_campaign=FS%20Poster 

what type of applications are you interested in? 

(fascinating btw love it)

last edit on 9/28/2020 3:36:21 AM
Posts: 2266
0 votes RE: Computational Models
Blanc said: 

Modeling physical systems and markets. 

This thread will be mostly about stochastics for a while as that's what I'm currently exploring. Stochastic is just a fancy word for something random, so by learning these methods of modeling the hope is that I'll be able to better understand random chaotic systems.

Such a system are derivative markets and their underlyings. I believe these types of models can give me a better understanding of volatility in the markets, the variance between mean and tail price action, and probabilities of a mean reversion of some asset. 

Posts: 419
0 votes RE: Computational Models

Importance Sampling

Funny you should mention this. Yesterday, I asked my student to learn how to use this and use it in one step of her project. It's a nice quick tool for many problems.

Have you heard of the great lord Bayes? Would you like to hear about Him?

Posts: 2266
0 votes RE: Computational Models
Legga said: 

Importance Sampling

Funny you should mention this. Yesterday, I asked my student to learn how to use this and use it in one step of her project. It's a nice quick tool for many problems.

Indeed, its been a life saver these last few days as I've dealt with more complex distributions. 

Along with it I was messing around with multinomial resampling to get a sample closer to f. It didn't work so well with smaller samples but I had no issues with larger ones. 

Have you heard of the great lord Bayes? Would you like to hear about Him?

 lol ofc but I would to hear your perspective on the Bayesian approach. 

 I was in fact working with beta distributions to get a feel for importance sampling under different densities. 

Posts: 419
0 votes RE: Computational Models

Indeed, its been a life saver these last few days as I've dealt with more complex distributions. 

Along with it I was messing around with multinomial resampling to get a sample closer to f. It didn't work so well with smaller samples but I had no issues with larger ones. 

Markov chain monte carlo is nice too, but sometimes too much like a bazooka. Wouldn't want to use it to kill a fly.

 

Have you heard of the great lord Bayes? Would you like to hear about Him?

 lol ofc but I would to hear your perspective on the Bayesian approach. 

 I was in fact working with beta distributions to get a feel for importance sampling under different densities. 

It is a mathematical framework to describe epistemology and warrants for beliefs, in my opinion.

The idea is essentially that the Bayes theorem allows for a mathematically rigorous definition of evidence and can be used to evaluate truth claims.

Here is a pdf doc for you (entitled introducing Alice to Lord Bayes):

https://www.privfile.com/download.php?fid=5f727684bc653-MzI5Mw==

last edit on 9/28/2020 11:50:42 PM
Posts: 2266
0 votes RE: Computational Models
Legga said: 

 lol ofc but I would to hear your perspective on the Bayesian approach. 

 I was in fact working with beta distributions to get a feel for importance sampling under different densities. 

It is a mathematical framework to describe epistemology and warrants for beliefs, in my opinion.

The idea is essentially that the Bayes theorem allows for a mathematically rigorous definition of evidence and can be used to evaluate truth claims.

Here is a pdf doc for you (entitled introducing Alice to Lord Bayes):

https://www.privfile.com/download.php?fid=5f727684bc653-MzI5Mw==

 Thanks. 

Posts: 2266
0 votes RE: Computational Models

Monte Carlo Optimization

Optimization is something very familiar to me given I’ve worked in the field professionally for 2+ years, having said that I’ve never used stochastics in my search so the overall methodology used in Monte Carlo will be new to me. Having said this the goal of any optimization is always the same, to find some extreme point in a search space.

It is customary to only concern ones self with maximization as any minimization problem can be handled through maximization via translating 1/h into h.

So, our fundamental concern will be,

Posted Image

In monte carlo terms an optimization problem can be executed numerically or stochastically and the method chosen is informed by the complexity of h and its domain -  if h is too complex or its domain irregular properties then it stochastic methods are preferable to numerical ones. The complexity of h or its domain is a challenge because the more irregular they are the more difficult it is to iterate through these domains and find the extrema point of interest and furthermore it can become increasingly more likely that we get stuck at local max or min instead of finding our global max or min. I am going to skip numerical given my familiarity and get right into the stochastic methods.

There are two kinds of stochastic optimization methods, the exploratory and probabilistic. In the exploratory method we hope to optimize h by describing its range and as such the properties of the range are more crucial than the properties of the function h. The probabilistic method uses the probabilistic properties of h in order to achieve optimization and as such the properties of h itself play a greater role than its domain.

Exploratory

Simulate from a uniform distribution, U_θ

Approximation,

Posted Image

As m -> oo there will be a convergence. 

Using the function,

Posted Image

to test the exploratory process.

Note: Are maximum in this case is the objective, 3.82. 

Posted Image

Posted Image

Posted Image

Recall that this process does not take h into account and as such the more complex our domain or h becomes the less effective such a methodology becomes.

We ideally would like to create a simulation that is uses the properties of both Θ and h.

If h is positive and, 

Posted Image

Then it is a simple task to find the modes of the density proportional to h.

Ideally, we would like to choose some density H that shares a maximum with function h,

That is, we generate sample Posted Image

From some density distribution H and estimate its standard mode.

All we are doing in this case is increasing the probability of simulating in regions were h is large and decreasing the probability of simulating were h is small.

By this means, revaluating h(x) results,

Posted Image

Posted Image

10 / 27 posts
This site contains NSFW material. To view and use this site, you must be 18+ years of age.