Monday, October 31, 2005

Memoization Rocks

// Testing.cpp : Defines the entry point for the console application.

#include "iostream"

using namespace std;

int results[50];

long memoized_fibonacci_recurs(int results[],int n) {

long val = 0;
if (results[n] != -1)
return results[n];

if (n == 1)

val = 1;

else if (n == 2)

val = 1;

else {

val = memoized_fibonacci_recurs(results,n - 2);
val = val + memoized_fibonacci_recurs(results,n - 1);

results[n] = val;

return val;


long fib(int num)
if ( num == 0 )
return 0;
if ( num == 1)
return 1;
return (fib(num-1) + fib(num-2));

long memoized_fibonacci(int n) {

for(int i = 0; i < 50; i++)

results[i] = -1; // -1 means undefined

return memoized_fibonacci_recurs(results,n);


int main(int argc, char*argv[])
long num = fib(40);

long num1 = memoized_fibonacci(40);

cout << "Computed Value is:" << num << endl;
cout << "Memoized Computed Value is:" << num1 << endl;

Wednesday, October 26, 2005

Maximum Likelihood

Let X=( $ X_1,\ldots,X_n$) be a random vector and

$\displaystyle \lbrace f_{\mathbf{X}}(\boldsymbol{x}\mid\boldsymbol{\theta}) : \boldsymbol{\theta} \in \Theta \rbrace$
a statistical model parametrized by $ \boldsymbol{\theta}=(\theta_1,\ldots,\theta_k)$, the parameter vector in the parameter space $ \Theta$. The likelihood function is a map $ L: \Theta \rightarrow [0,1]\subset \mathbb{R}$ given by
$\displaystyle L(\boldsymbol{\theta}\mid\boldsymbol{x}) = f_{\mathbf{X}}(\boldsymbol{x}\mid\boldsymbol{\theta}).$
In other words, the likelikhood function is functionally the same in form as a probability density function. However, the emphasis is changed from the $ \boldsymbol{x}$ to the $ \boldsymbol{\theta}$. The pdf is a function of the $ x$'s while holding the parameters $ \theta$'s constant, $ L$ is a function of the parameters $ \theta$'s, while holding the $ x$'s constant.

When there is no confusion, $ L(\boldsymbol{\theta}\mid\boldsymbol{x})$ is abbreviated to be $ L(\boldsymbol{\theta})$.

The parameter vector $ \hat{\boldsymbol{\theta}}$ such that $ L(\hat{\boldsymbol{\theta}})\geq L(\boldsymbol{\theta})$ for all $ \boldsymbol{\theta}\in\Theta$ is called a maximum likelihood estimate, or MLE, of $ \boldsymbol{\theta}$.

Monday, October 24, 2005

Standard Deviation

Suppose we are given a population x1, ..., xN of values (which are real numbers). The arithmetic mean of this population is defined as For formulaes

Monday, October 17, 2005

Probability Distribution function

Random variables: Are the real valued functions defined on the sample space i.e they map the outcomes of an experiment from a non-real outcome to real numbers outcome.

Analogy: For e.g while tossing a dice we are not interested in the actual outcomes but are interested in the functions of the outcome

A random variable that can take at most a countable number of possible values is said to be discrete. For discrete random variable we define probability mass function

Picked from lecture notes :) for my reference ( thanks to whoever did it)

Cumulative Distributive function
What is the probability that x is less than or equal to x0?
The probability that x < x="-" infinity="" integral="" x0="" dx="">

This integral yields the area under the curve between x = -∞ and x = x0
and is called the cumulative density function or cdf denoted by ‘g’.

Variance – measure of the deviation from the mean for points in one dimension e.g. heights
Covariance as a measure of how much each of the dimensions vary from the mean with respect to each other.

Covariance is measured between 2 dimensions to see if there is a relationship between the 2 dimensions e.g. number of hours studied & marks obtained.

The covariance between one dimension and itself is the variance

Covariance Properties

Exact value is not as important as it’s sign.
A positive value of covariance indicates both dimensions increase or decrease together e.g. as the number of hours studied increases, the marks in that subject increase.

A negative value indicates while one increases the other decreases, or vice-versa e.g. active social life at RIT vs performance in CS dept.

If covariance is zero: the two dimensions are independent of each other e.g. heights of students vs the marks obtained in a subject

Covariance calculations are used to find relationships between dimensions in high dimensional data sets (usually greater than 3) where visualization is difficult

variance (X) = Σi=1n(Xi – X) (Xi – X)
(n -1)
covariance (X,Y) = Σi=1n(Xi – X) (Yi – Y)
(n -1)

the mass (probability) of a small section of wire is the mass per unit length (density) times it length of section (bin width) under consideration.

Analysis Server Database Backups

The backup extensions for analysis server are .abf, you connect to the analysis server database and right click on it to restore a database with .abf extension to restore the database.

Dunno what i wrote :)