Random numbers

October 10th, 2009

Whenever I need a random number, I always use srand or some other simpe random number generator function.

I didn’t give a damn on how is it generated or how random the number is. That’s because, I just wanted a few random numbers(a few 100’s) and almost any decent algorithm can give me a random number within this range.

Now, I want to find a really good random number and I have a real need for it. The requirement is so strict that if the random number is not distributed fairly, I can easily notice that.

The challenge increases with the output range the user needs. There are pseudo random number generators(PRNG) which has a HUGE random number range, but it’s not distributed randomly.

Even I can give a dummy algorithm which will guarantee that I will not give out a number which I have already given out since past n requests.

I can write a simple program to answer your needs for fairly large n.

i=0; i+=1000 && i<n ; i++

This will 100% run until n, then start from i=1 and so on until 999.

But is it random? Depends on the need of the user.

This is 100% not random because it has an algorithm which predicts how to generate the next number and hence it’s not random.

I define random as something that’s unpredictable. I am in search for such a random number.

Truly random number generators should be definition should not be based on mathematics but shud be as a result of some natural events.

kernel random number generator picks such events and fills in it’s entropy tool to get various unrealted events and generates a random number based on that. But it’s too slow.

I want in the range of millions of numbers per second.

After days of searching on internet, i could find just 1 good random number genrator.

Thanks to the god of random number generator: “Dr. Marsaglia”. He has generated around 600 MB of almost true random numbers which he has given out in the website: http://stat.fsu.edu/pub/diehard/

This is failrly distributed and covers the entire range. Every bit in this file is random.

Hence any combination of bits you take should be random. So I am free to get any number size and my number is almost random.

User – kernel thread

August 15th, 2009

What are Users threads and kernel threads?
Are they 2 different entities or are they part of a single entity?
Why do we need user threads and kernel threads?
what do they do?

Read the rest of this entry »

Concurrency in OS

August 15th, 2009

What are the different types of concurrency mechanisms in Operating system?
When should we use mutex, simple lock, MCS lock, complex lock, semaphore?

Read the rest of this entry »

Sony P990i mobile

August 15th, 2009

Sony Ericsson P990i is one beauty with a beast body.

The perfect choice for a budget conscious person and who still wants to have a phone with all options.

You can find hazaar options in this phone.

It took me almost 1 month to get a hold on this phone. I am still masked off from some applications. It’s that huge!!!!!

The only disadvantage of this phone is it’s size. There were initial hiccups in the firmware, but from 2006-2007, it’s rectified. You can also update this phone with the latest software from sony ericsson website.

Read the rest of this entry »

Sony DSC H5

August 15th, 2009

Sony DSC H5 is one of the best digital cameras I’ve seen. I am proud to be the owner of it. It’s large LCD screen is the biggest attraction.

It offers a spectacular array of advantages for creative expression, including 7.2 megapixel performance for editing, cropping and making big prints, top-quality Carl Zeiss® 12X Optical zoom lens and Super SteadyShot® stabilization system for rock-steady long-distance photos.

Read the rest of this entry »

Honda Unicorn

August 15th, 2009

This is the perfect bike for Indian Roads. Honda engines are one of the best in industry.

I like the way the engine runs. It runs very silently, smoothly and has the perfect maneuvering capability.

I however never compare these bikes to Bullet bikes. They are a class apart.

In the 150 CC segment, Unicorn Rules.

Now comes the million dollar question:

Is pulsar better than Unicorn? Well…I have my own reservations on this.

Read the rest of this entry »

Filter – Sony DSC H5 camera

August 15th, 2009

I own a Sony DSC H5 camera since 2 years. It’s very tempting to capture sunrise and sunset pictures. But the harmful UV rays pose threat to the lens and more damage to our eyes!
UV rays consists of 2 parts: UVA and UVB rays.
UVA rays are present from sunrise to sunset, irrespective of clouds, glasses or any other transparent/translucent medium.
UVB rays are present only when we are directly exposed to sun. Of course there is ozone layer protecting us from it, but some amount of light still reaches earth and that’s enough to cause us long lasting damage.

So while capturing sunrise or sunset photos, be careful not to over expose the camera lens after sunrise or before sunset.
You can avoid much damage by putting a UV filter in front of the lens.

UV filters reflect the UV rays and hence avoids burning of camera lens and and other sensitive materials close to the lens.
Cost of UV filters depend on the size of the lens.
My Sony DSC H5 camera has a 58 mm lens and hence I need a 58 mm filter.
It cost me 250Rs. (FOTO circle, Chikpete, Bangalore).
There are other varieties too. (100, 250, 400Rs).
But for a average camera like mine, I feel 250Rs is fine.

Most of the lens available in the market are of this size itself.
Even lens for some of the DSLR cameras like: Nikon, Canon are 58 mm in size.

Polarize filters do not protect any UV rays. They only avoid perpendicular rays without seeing color, caste or religion of the rays!

Anyway they cost 750Rs for my camera. (58mm).
Maintaining polarize filter is a huge pain.
It should not be exposed for a long time, because dust particales can cause small scratches to the filter and that will fail to filter perpendicular rays, thus rendering the filter useless.

So loading and unloading the filter every now and then is lot of discomfort and hence I didn’t buy it.

North India Uttaranchal

August 15th, 2009

Uttaranchal is the abode of god. It’s a magnificent place to tour around.
I went in with my family and relatives.
We covered lots of places and it was a very well planned trip.
We went to: Delhi, Haridwar, Rishikesh, Mussorie, Jim Corbett National Park, Nainital, Mukteshwar, Mathura and Agra.
It was a complete trip with lots of activities and fun.
Read the rest of this entry »

South India

August 15th, 2009

My South India trip was one of the most un planned ones!
Just in 1 day I and my dad started sketching a plan to cover South India.
We started from DevarayanaDurga and ended up in Guruvayur!
Places we visited: Dharmastala, Kukke Subramanya, hornadu, Sringeri, Udupi, Padkakshetra, Madikeri(coorg), Ooty and Guruvayur.
That was an awesome effort to plan the entire journey and get transport ready by the next day and that too in Christmas holidays!

Read the rest of this entry »

North West India

August 15th, 2009

Recession is hitting hard. No hikes! No extra money! But the desire to travel was looming large in my mind. I am lucky to have a travel freak family. My parents love to travel and more importantly adjust to whatever is available. Be it food, hotel or transport, we go with whatever is best available and do not complain about what’s not available. That’s very important to enjoy any tour.
I planned my tour with a few important places that I desperately wanted to visit. Then accommodate other’s interests and then build up a route. So we wanted to visit: Golden temple (Amritsar), Wagah border, Thar Desert, Dwarka and Gir forest.
Photo Gallery: http://dilip.nijagal.com/photo_gallery/index.php?cat=66
Read the rest of this entry »