Saturday, February 28, 2015

The Land Acquisition debate

A debate with my dear friend Neelkamal, on facebook, is about the #LandAcquisition bill (Act of 2015) of India.

The questions and thoughts Neel has about the #LandAcquisition bill:


Here is what I have to say about it - part 1 and part 2.

Land acquisition bill should be about "right to fair compensation against (someone's) property being acquired". Fair is what seems good to all parties involved. 4X is not fair any more to the farmers, having figured that the land would later sell for perhaps 40x or even more (fetched by the land acquired for "affordable housing" and other such projects). The fairness ends there. Economics is not taught, it just prevails.

A misconception amongst many is that all farmers have several hectares of land and hence they become rich by selling land. Fact is that for 1 such huge land bank holder there are hundreds with little land, tilling which they earn bread. 

They are uneducated and can't afford, for their children, the education promised by our constitution to every child (BTW! Do you consider it as a freebie as well?). Having sold their land they will end up as unskilled labour, the class of society that seldom make their ends meet. It is a class of the society that ends up feeling deprived and often ends up into a negative spiral and may even lead to crime. 

Those who have enough land to become affluent, have experienced that though they had money but they never knew what to do with it and ended up wasting the fortune. Their children ended up as spoilt youth. Once bitten, twice shy. 

Why was an ordinance required as first step to this law? Was it because the Govt believed that they force it in the lower house, for the opposition would not be able to a thing about it? Kudos to those who walked-out, a walkout is a very polite means of showing disagreement and is massively effective. It is a clear expression that those who walkout WILL NOT BE A PART TO IT while the law could still be formed. Applaud them for the befitting response, do not criticize them.

Respected FM responded to this question - "Bharat ke pehlay pradhaan-mantri (Shri J. L. Nehru) 70 ordinance laye thay". 
Kintu prashan to ye hai ki iss adhya-aadesh ki kya aavashyakta thi? Yeh na batayein ki kon kitnay adhya-aadesh kab or kis prakaar laya. 

A hugely illiterate India has been a nation of farmers (70% till a few years ago, still not less than 60%), independent earners. Land acquisition not supported with education and professional skills development is turning poor farmers towards begging and crime. 

BTW, I will be glad if we (as a nation) view farming as entrepreneurship or at least as a cottage industry and support it with various funds and means? Further, why does farming not fit the concept of "Make in India"?

Let us bring colour to the "fairness", the now bills suggests that when Govt is acquiring the land for defence purpose the consent of the farmer is not necessary. The bill presented by the previous Govt was more reasonable, it suggested only when a state of emergency is declared (already) any land can be acquired for defence without the consent of the affected farmer(s).
Add insult to injury, the compensation is said to be paid (by the now proposed bill) not when the recipient signs on receipt but when the Govt signs on the release of compensation.

A commonality amongst revolts around the world is the peasants, they are not the opposition nor do they sit as those in power - but they are the real power. Give them the due.


Neel's reply:

What I have to say on this:

 Neel, please appreciate that land for a farmer is not an asset that they have maintained for generations to make money. Unlike many non-farming land-hoarders (look at the farmhouses around spewing affluence), land for a farmer is the only means to earn a living and manage a respectful life. 

किसान के खेत उसकी सम्पन्नता का प्रतीक नहीं अपितु उसके आर्थिक रूप से समर्थ बनने का एक या एकमात्र साधन हैं। आज के परिपेक्ष में देशभक्ति का माप आर्थिक, शारीरिक या किसी और प्रकार के सामर्थ्य का त्याग तो नहीं होना चाहिए। 

How are then - you, I, respected PM, the rich of rich or anyone else more or less patriotic as compared to any farmer? 

आज देशभक्ति मापने के लिए यह देखें कि कौन देश के किन संसाधनो पर किस प्रकार का और कितना बोझ डाल रहा है और वह देश को कितना और कितने प्रकार से समृद्ध बना रहा है। आप पाएंगे कि किसान भी बाकि सभी जितना देशभक्त है। 

I think the question to be asked is not "Why are you (the farmers) not convinced to give away the land?", the right question is "How can we convince our brothers to give their land (or even skin) for the purpose we say is National Development?". A few points to take care of in my opinion are:

1. Bring agriculture on "Make in India" agenda. Treat farmers as entrepreneurs. (As I said earlier, give to them "the due".)

2. Farming is a means of living that has helped generations of farmers sustain. When you ask them to part of from their land, give them not only the "now" fair value of it but also give to them (a) skills that bring to them somewhat similarly sustaining means of living and (b) give them the value of land that will be, until they acquire such a means of living - it may really be 4x or 400x.

3. If one is not convinced, do not force them. Alter your plans instead (a little at least) where possible and let them know that they are being dealt with compassion.

4. Publish and explain the plans for which one's land is being acquired. Make sure that the land is being used as it was asked for and make transparent a deviation and its reasons if it occurs.

Some will be convinced soon, some later a very few perhaps never - but we need to work on a long term solution that brings people together not divide people into classes (them vs. us, they are farmers, we are middle class etc etc etc). 

Invariably everyone needs to takes the above in perspective, lest the said ordinance turns into "The Land Grab Bill".

Human greed? The coats of rich and powerful will be auctioned to fetched 50x the original price (if 10 L is believed) and the land of the poor can be grabbed instead at a dictated price!

Thursday, January 08, 2015

Passing an array by reference

I am blessed to have colleagues to debate with, interesting ones. Today's was about passing an array as a reference. Usually one ends-up passing the array as pointer and the size in the second parameter.

Given below is the code where one is able to pass to a function an entire array of fixed size:


#include <iostream>

int func10(int (&tenIntArray)[10])
{
for (int i = 0; i < 10; i++)
{
if (i == 0) continue;
tenIntArray[i] = tenIntArray[i - 1] + 1;
}
return 0;
}

// Only to show how it is typedef'd
typedef int FiveIntArray[5];

int func05(FiveIntArray &fiveIntArray)
{
return 0;
}

int main(int argc, char* argv[])
{
int tenIntArr[10] = { 1 };
FiveIntArray fiveIntArr = { 1 };

func10(tenIntArr); // we can't pass fiveIntArr here

for (int i = 0; i < 10; i++)
{
std::cout << tenIntArr[i] << std::endl;
}

func05(fiveIntArr); // a tenIntArr is not acceptable here

return 0;
}


It is easier to understand if one has typedef it.

The general rule with the use of typedef is to write out a declaration as if you were declaring a variable of the type you want. Where the declaration would have given a variable name of the particular type, prefixing the whole thing with typedef gives a new type-name instead. The new type-name can then be used to declare new variables.

Tuesday, January 06, 2015

Monte Carlo simulations to determine the value of PI

Consider a circle with radius R. The area of the circle is PI x R^2. The area of the square that just embeds our circle (as in image below) is (2R)^2.


One takes a print of the image, sticks it on a cardboard and throws a dart at it. The chance the dart will fall within the circle is the ratio of area of the circle to the area of the square.

Chance of dart landing within the circle =  Area of circle 
                                                                    Area of square

                                                                 =  PI x R^2 
                                                                       (2R)^2

                                                                 =  PI x R^2 
                                                                      4 x R^2

4 x (Chance of dart landing within the circle) = PI

Whether the dart is within the circle or beyond the circle is simply determined by the distance at which it is from the centre of the figure (as illustrated).



To determine the chance that a dart thrown at the figure will land within the circle, one throws the dart several times and notes the distance of its landing from the origin. 

The ratio  number of times the dart lands at a distance less than equal to the radius of the circle 
                                                              total number of throws

gives us the probability (i.e. chance) of the dart landing within the circle in total number of throws.

There is no bias expected. Hence, the probability of the dart falling within the quarter circle shown in the red square above is the same as that of the dart falling within the entire circle.

Programatically one now needs to randomly select (x, y) to represent a point at which the dart lands, determine if it is at a distance greater than R or not. If it was a unit circle (i.e. R = 1) the comparisons are a little easier since there is no need to take a root of (x^2 + y^2). 

Below is a program that gives us the probability of selecting a point (x, y) such that it falls in the quarter circle:


    #include <iostream>
    #include <ctime>
    
    void usage()
    {
     std::cout << "Usage: find_pi <number of tries>" << std::endl;
     return;
    }
    
    int main(int argc, char* argv[])
    {
     if (argc != 2)
     {
            usage();
            return -1;
     }
    
     int numTries = atoi(argv[1]);
    
     int total = 0;
     int inCircle = 0;
    
     srand(static_cast<unsigned>(time(0)));
    
     for (int total = 0; total < numTries; total++)
     {
            double x = static_cast<double>(rand()) / RAND_MAX;
            double y = static_cast<double>(rand()) / RAND_MAX;
            double z = x*x + y*y;
            
            if ((z - 1.0) <= DBL_EPSILON)
         {
     ++inCircle;
            }
     }
    
     std::cout << (double)inCircle * 4.0 / numTries << std::endl;
    
return 0;
    }