Help needed in Python
There are two files with ASCII type.
You can program by using python as follows: 1. Your program read two files in respectively. 2. Each file is composed of xyz value in float type(in real value). You can calculate the distance by using randomly choosing between two points. Sampling number depends on you. Then you can make the histogram composed of distances and frequencies. 3. Program calculate the similiarity value by using histogram comparison(we already discuss this issues). 4. Program write the similarity value in file or console.
fileA ------------------------------------
35.884 30.895 49.120 36.177 29.853 50.124 37.296 30.296 51.074 38.553 30.400 50.259 38.357 31.290 49.044 39.559 31.209 48.082 34.968 30.340 48.234 34.923 29.775 50.910 37.441 29.265 52.113 39.572 30.954 51.086 37.155 30.858 48.364 39.261 32.018 46.920 ------------------------------------
fileB ------------------------------------
35.884 30.895 49.120 36.177 29.853 50.124 37.296 30.296 51.074 37.441 29.265 52.113 39.572 30.954 51.086 37.155 30.858 48.364 39.261 32.018 46.920
thank you in advance
step 1. focus on your presentation.
step 2. learn python. try codecademy or other free tutorial sites.
step 3. code solution.
Having someone else do your schoolwork is unethical. So is doing someone else's schoolwork.
If you already know how to program in some other language e.g. Visual Basic, C or Java, then you should find it easy to learn Python.
One interesting feature of the language is that it does not use twirly brackets to delimit code blocks. Indentation is used instead. For example, here's a snippet of code from something I'm working on now:
ml_brains = catalog(object_provides=IBikaFolder.__identifier__, logical_title="root: Member Labs") if len(ml_brains) == 0: member_labs_folder = createObject('bika.interlab.bikafolder') member_labs_folder.title = "Member Labs" member_labs_folder.logical_title = "root: Member Labs" member_labs_folder.reindexObject() addContentToContainer(portal, member_labs_folder, checkConstraints=False) else: member_labs_folder = ml_brains[0].getObject() alsoProvides(member_labs_folder, IMemberLabsFolder)
Other than that it's a pretty normal language. It supports object orientation, but you probably don't need to go into that for a simple assignment like this. You'll probably need to use lists and/or dictionaries, though. There's a nice tutorial on that here: http://www.sthurlow.com/python/lesson06/. I see there's links there to other topics too, that should be enough to get you going.
This sounds like a statistics class. I wish we could have done statistics with something real like Python. Instead we used a dumb program called SPSS.
This is a good time to try writing some psudocode. Just write down the steps that you would go through to accomplish this task, and then go through each step and make it more specific by breaking down each step into smaller ones. Actually, the instructions your were given is already a high level psudocode, so the professor is trying to help you. (And you though he was being mean.)
By the time you've fleshed out the psudocode enough, each step should correspond to a simple google search. Like how to read files in python, how to generate random numbers in python, how to create loops in python, how to create arrays in python, and so forth.
His instructions with a little editing and some psudocode. (sheesh, I'm doing your work)
1. Your program read two files in respectively. Each file is composed of xyz value in float type(in real value).
read in file 1 (probably going to be a loop, but I don't know)
store in array1
read in file 2 (probably going to be a loop, but I don't know)
store in array2
2. Calculate the distance by using randomly choosing between two points. Sampling number depends on you
set sample_number to something big but not too big
loop i from 1 to sample_number
get random point from array1
get random point from array2
calculate distance between points and append value onto array3
3. Make the histogram composed of distances and frequencies
make histogram array for bins initialized to zeros
loop i with array3
figure out which bin number i goes in
increment the histogram array indexed by the bin number by 1
4. Calculate the similarity value by using histogram comparison
what in the tarnations is a similarity?
4. Print out the similarity value in file or console
one step baby, print that number
It's bad groove to code without planning unless you already have great groove, in which case it supers your groove.