I am using village-level data, and I have three types of social groups in the villages. I want to create two indices using them. The first one is called the social diversity (fractionalization) index. 
Equation 1 gives the standard way followed in the literature for calculating it. Can someone help me in writing a code for calculating it.
Then, I want to use it in creating another index, called segregation index. This is given in the picture below

Here, 'i' is for village only, which lies in sub-district 'j'. How to code this index?
After creating these indices. I need to rescale them on a scale of 1 to 10. How to do that?
Thanks in advance
Equation 1 gives the standard way followed in the literature for calculating it. Can someone help me in writing a code for calculating it.
Then, I want to use it in creating another index, called segregation index. This is given in the picture below
Here, 'i' is for village only, which lies in sub-district 'j'. How to code this index?
After creating these indices. I need to rescale them on a scale of 1 to 10. How to do that?
Thanks in advance
Comment