Wednesday, February 1, 2017

Voting Districts Day 4: Starting with Random Points

Now that we've got the center points for our voting district shapes, we need to figure out how to create central points where we can start our clustering.  

There is a random library included with Python that I hope can do the job.  It has a uniform function that will give me a random float between two numbers that I designate.  I'll just loop through to generate these random coordinates based on how many clusters I want to build.

First, I want to make sure these starting coordinates fall somewhere approximately within the state of NC.  So, I'm going to get the total min and max x and y axis values by writing ALL of the x and y points to two lists and pull a min and max from those lists to create a range for the random numbers.

import random
...
xmids = list()
ymids = list()

for x in range(0,len(shapes)):

    for y in range(0,len(shapes[x].points)):

        xmids.append(shapes[x].points[y][0]) 
        ymids.append(shapes[x].points[y][1])


start_points = list()
xmax_o = max(xmids)
xmin_o = min(xmids)
ymax_o = max(ymids)
ymin_o = min(ymids)

From there, we'll use the random.uniform method through a loop to create whatever number of points we want to start with.
start_point_count = 12 for z in range(0,start_point_count):
 start_points.append([random.uniform(xmin_o,xmax_o),random.uniform(ymin_o, ymax_o)])

And we now have our random starting points!

Next up, we are going to build ourselves a matrix consisting of the distances between the centroids of our voting district shapes and our starting points.  From there, we will then figure out which voting district should be associated with each point by going through the voting districts draft style where each point will take a turn picking its closest voting district.

2 comments:

terry james said...

I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..







I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..














I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..

Tamara Barrow said...

I have been suffering from (HERPES SIMPLEX VIRUS) disease for the past four years and had constant pain. During the first year, I had faith in God that i would be healed someday.This disease started circulating all over my body and i have been taking treatment from my doctor, few weeks ago i came on search on the internet if i could get any information concerning the prevention of this disease, on my search i saw a testimony of someone who has been healed from Herpes Simplex Virus by this by Dr voodoo and she also gave the email address of this man and advise anyone to contact him for any kind of problem that he would be of help, so i wrote to Dr voodoo telling him about my (Herpes Virus) he told me not to worry that i was going to be cured!! Though i never believed it,, well after all the procedures and remedy given to me by this man few weeks later i started experiencing changes all over me as the Dr voodoo assured me, after some time i went to my doctor for test and it confirmed that i have be finally healed behold it was TRUE, So friends if anyone have such problem and need help contact Dr voodoo on his email: voodoospelltemple66@gmail.com Add Dr voodoo on whatsApp +2348140120719