Wednesday, January 3, 2018

We were discussing Monte Carlo simulations. Historically simulations were used to test a previously understood deterministic problem. The sampling was used to generate uncertainties in the simulations. Monte Carlo simulations inverted this approach. It tries to solve deterministic problems using optimizations based on probabilistic interpretations. It draws samples from a probability distribution. We had seen another such method earlier. It was called Simulated Annealing. This is a special case of Monte Carlo. In Simulated annealing, we computed the current cost and the new cost based on the direction of change. If it improves, we decrease the temperature.

#codingexercise
We were discussing the bottom up manner of counting ways to climb the staircase
int GetCountWays(uint n)
{
    int [] dp = new int[n+2];
    dp [0] = 0;
    dp [1] = 1;
    dp [2] = 2;
    dp [3] = 4;

    for (int k = 4; k <= n; k++) {
       
            
                 dp [k] = dp [k-1] + dp [k-2] + dp [k-3];
        
    }
   return dp [n];
}
Some people like to start the dp[0] as 1 so that this follows the Fibonacci pattern for 1 and 2 steps

The above memoization can be reused for computing results for consecutive integers 

No comments:

Post a Comment