Sunday, March 22, 2009

How to restore dell factory image when PC restore does not work?

Here I will give you instructions as to how you can reformat your dell laptop hard disk and restore the factory image ( the hard disk contents with which your laptop came when you bought it). You will need your vista dvd for this.

I will be assuming that C: is your Operating system partition and D: is your recovery partition.

1. Boot the computer using your vista dvd.
2. Select Repair. Then select command line.
3. Goto your recovery drive and then to the tools folder by typing following on the command prompt :

d:
cd tools

4. Then type this on the command prompt :

imagex /apply d:\dell\image\factory.wim 1 c:\

5. This will start the recovery process which will complete itself in 10-15 minutes.
6. Type exit on the command prompt.
7. Reboot your computer from your hard disk.

Saturday, March 21, 2009

How to burn videos to play on a dvd player?

Older dvd players cannot play data dvd's , only newer divx compatible players can play them.
So if you wish to play them on such a dvd player, you would have to first convert the files to a dvd format.
There are many softwares which do both the conversion and burning for you. If you are using windows vista, you can use windows dvd maker.
Otherwise Total Video converter is a very good option.
But beware that the conversion process takes a lot of time ( say an hour for a 2 hour video or may be even more)

Wednesday, March 18, 2009

Generate numbers in Gaussian (normal) Distribution in C

C doesn't have direct function to generate numbers which follow Gaussian Distribution. Here is how one an do this. We can use the cumulative distribution function of the Normal Distribution to generate the required. The code below illustrates how to generate a point between -3 to +3 with resolution of .005 and which follows the standard Normal Distribution. The code can accordingly be changed for other normal distribution and other range. step size multiplied by the no of points/2 in CDF array gives the range.



#include "stdio.h" // change accordingly
#include "stdlib.h"
#include "math.h"

double CDF[1202];//gloabal array which contains the CDF of the normal distribution

double generateAWGN(){
double temp;
int i=0,j=0;
temp = CDF[1]+(CDF[1201]-CDF[1])*rand()/RAND_MAX;//uniformly distributed temp
if(temp>.5)
{
for(i=602;i<1202;i++){>=temp){
return (i-601)*.005;
}
}
}
else
{
for(j=600;j>0;j--){
if(CDF[j]<=temp) return (j-601)*.005; } } } int main(int argc, char *argv[]) { int i=0; double step = .005,tmp,avg,pns; double past_tmp = .399, extra,a; CDF[601]=.5;//mean has CDF .5 for(i=1;i<=600;i++) { tmp = .399*step*exp(-((step*i)*(step*i))/2);//value at step*i of pdf extra = (past_tmp-tmp)*step*.5; past_tmp = tmp; CDF[601+i] = CDF[601+i-1]+tmp+extra; CDF[601-i] = CDF[601-i+1]-tmp-extra; } //printf("%f and %f \n",CDF[1201],CDF[1]); printf("the elements which follow gaussina distribution\n"); for(i=0;i<1000;i++) { pns = generateAWGN(); printf("%f\n",pns); avg = pns/1000; } printf("average of the elements = %f",avg); }