Re: [Tutor] Connecting my users

2010-10-03 Thread leo kirotawa
Hi,
I asked to my mate college and he said that:

The ichat use bonjour(avahi/zeroconf) no server, has chat and exchange file,
but should be in the same net level.
There are too  the milticas chatts, like this in python:
http://my.opera.com/manojsheokand666/blog/chat-application-in-python.




On Sat, Oct 2, 2010 at 8:28 PM, Steven D'Aprano  wrote:

> On Sat, 2 Oct 2010 08:06:14 pm Timo wrote:
> > On 01-10-10 11:25, Nitin Pawar wrote:
> > > have a look at this
> > >
> > > http://bytes.com/topic/python/answers/826973-peer-peer-chat-program
> >
> > Thanks, but that still uses a server. And even one that I can't
> > control! If it has to be with server interaction, than as little as
> > possible is preferred and option to put it on my own.
>
> You obviously didn't read the article carefully enough. It describes a
> peer-to-peer chat program, and I quote from the project page:
>
> "kaishi is a chat program without any central servers. Currently all
> users connected to kaishi are on the same level of the network, meaning
> no user has more control over the others."
>
>
> --
> Steven D'Aprano
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Leônidas S. Barbosa (Kirotawa)
[DesenvolvedorWeb/CEFET/RN]
[Ciências da Computação/UFRN]
[pós-graduando em Inteligência Computacional/Processamento Gráfico /UFRN
[Estudante de japonês nível Intermediário I  - Japanese Student]
[Desenvolvedor em python, PyGame]
blog nerd: corecode.wordpress.com/
blog music: essenaomanja.blogspot.com
blog tirinhas: elminiche.wordpress.com/

"Mais sábio é aquele que sabe que não sabe" (Sócrates)

日本語の学生です。
コンピュータサイエンスの学位.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Smart posting - Was: Re: Tutor Digest, Vol 80, Issue 11

2010-10-03 Thread Alan Gauld


"James Mills"  wrote


I'm actually really surprised anyone actually uses and subscribes to
mailing lists and wants to get digests. It's far easier (for me at 
least)

to just get each email as it comes in.


I use digests for several mailing lists - and used to use it on the 
tutorlist

untilGMane made it available as a news feed which is better still.

The advantage of a digest is that I can read it all in one go rather 
than
having to search for the mails intermingled with all the other stuff 
that
comes in (around 200 mails per day of which list mail  is low in 
priority)

If there are 50 messages a day from tutor - which can happen - then
that would push my inbox load up to 250/day but using a digest
means it is only 201 - far easier to scan and search.

I could do the same by setting up a rule to auto file it in a folder 
but

the digest effectively does that for me and I'm lazy by nature :-)

So digest is good, but posting the whole digest is bad!

My personal view.

Alan G. 



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] list comprehension, efficiency?

2010-10-03 Thread bob gailer

 On 10/2/2010 8:02 PM, Steven D'Aprano wrote:

On Sun, 3 Oct 2010 01:17:39 am bob gailer wrote:


I ran dis on a for loop and the equivalent comprehension.

I was surprised to see almost identical code.

I had assumed (and now wish for) that a comprehension would be a
primitive written in C and thus much faster!

How could it be? A list comp is syntactic sugar. It needs to perform the
same steps as a for-loop, and call an arbitrary Python expression. It's
not like map() that takes a function object. Unless you had a separate
primitive for every imaginable Python expression -- which is
impossible -- list comps need to generate relatively similar code to
for-loops because they do relatively similar things.


Thank you. I needed that!

Besides, in recent versions of Python the speed of for-loops is quite
good. The bottleneck is rarely the loop itself, but the work you do in
the loop or the size of the loop.


--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] subprocess.call warning

2010-10-03 Thread Norman Khine
hello, from the docs http://docs.python.org/library/subprocess.html i
see there is a WARNING about deadlock when using the subprocess.call.
in my code i have this

http://pastie.org/1197024

the first calls the 'sox' library which joins all the .wav files into
one file and then i use the 'wav2swf' library to create a SWF output
of the file.

can the code be improved?

thanks

-- 
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (de)serialization questions

2010-10-03 Thread Albert-Jan Roskam
Hi Lee, Alan and Steven,

Thank you very much for your replies!

First, Lee:
>> That does not seem like it will work. What happens when
>> 2 addresses have the same zip code?

--> Sorry I didn't answer that before. When the zipcode is known, that's not a 
problem. The data typist simply has to enter the zip code and the street number 
and voilà, the street name and city name appear. A big time saver. When the 
zipcode is the UNknown, indeed I need street name, apt number, and city to get 
the right zip code. Without the street number, I might end up with a list of 
zip 
codes. But having no street number would automatically invalidate the given 
address. We couldn't possibly mail a letter without having the apt. number!

I just ordered a book on sqlite this morning 
(http://www.amazon.com/SQLite-Chris-Newman/dp/067232685X/ref=sr_1_2?ie=UTF8&s=books&qid=1256736664&sr=1-2)
 
 It indeed seems like the way to go, also in the wider context of the program. 
It makes much more sense to maintain one database table instead of 3 csv files 
for the three data typists' output.

Alan: I forwarded your book to my office address. I'll print and read it!
Btw, your private website is nice too. Nice pictures! Do you recognize where 
this was taken:http://yfrog.com/n0scotland046j .You're lucky to live in a 
beautiful place like Scotland 


Cheers!!
Albert-Jan


~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the 
Romans ever done for  us?
~~





From: Lee Harr 
To: tutor@python.org
Sent: Sat, October 2, 2010 12:56:21 AM
Subject: Re: [Tutor] (de)serialization questions


>>> I have data about zip codes, street and city names (and perhaps later also 
of
>>> street numbers). I made a dictionary of the form {zipcode: (street, city)}
>>
>> One dictionary with all of the data?
>>
>> That does not seem like it will work. What happens when
>> 2 addresses have the same zip code?

You did not answer this question.

Did you think about it?


> Maybe my main question is as follows: what permanent object is most suitable 
to
> store a large amount of entries (maybe too many to fit into the computer's
> memory), which can be looked up very fast.

One thing about Python is that you don't normally need to
think about how your objects are stored (memory management).

It's an advantage in the normal case -- you just use the most
convenient object, and if it's fast enough and small enough
you're good to  go.

Of course, that means that if it is not fast enough, or not
small enough, then you've got to do a bit more work to do.


> Eventually, I want to create two objects:
> 1-one to look up street name and city using zip code

So... you want to have a function like:

def addresses_by_zip(zipcode):
'''returns list of all addresses in the given zipcode'''



> 2-one to look up zip code using street name, apartment number and city

and another one like:

def zip_by_address(street_name, apt, city):
'''returns the zipcode for the given street name, apartment, and city'''



To me, it sounds like a job for a database (at least behind the scenes),
but you could try just creating a custom Python object that holds
these things:

class Address(object):
street_number  = '345'
street_name = 'Main St'
apt = 'B'
city = 'Springfield'
zipcode = '9'

Then create another object that holds a collection of these addresses
and has methods addresses_by_zip(self, zipcode) and
zip_by_address(self, street_number, street_name, apt, city)


> I stored object1 in a marshalled dictionary. Its length is about 450.000 (I 
>live
> in Holland, not THAT many streets). Look-ups are incredibly fast (it has to,
> because it's part of an autocompletion feature of a data entry program). I
> haven't got the street number data needed for object2 yet, but it's going to 
be
> much larger. Many streets have different zip codes for odd or even numbers, or
> the zip codes are divided into street number ranges (for long streets).

Remember that you don't want to try to optimize too soon.

Build a  simple working system and see what happens. If it
is too slow or takes up too much memory, fix it.


> You suggest to simply use a file. I like simple solutions, but doesn't that, 
by
> definition, require a slow, linear search?

You could create an index, but then any database will already have
an indexing function built in.

I'm not saying that rolling your own custom database is a bad idea,
but if you are trying to get some work done (and not just playing around
and learning Python) then it's probably better to use something that is
already proven to work.


If you have some code you are trying out, but are not sure you
are going the right way, post it and let people ta

[Tutor] Matching relational data

2010-10-03 Thread David Hutto
I'm creating an app that charts/graphs data. The mapping of the graphs
is the 'easy' part with matplotlib,
and wx. My question relates to the alignment of the data to be processed.

Let's say I have three sets of 24 hr graphs with the same time steps:

-the position of the sun
-the temp.
-local powerplant energy consumption


A human could perceive the relations that when it's wintertime, cold
and the sun goes down, heaters are turned on
and energy consumption goes up, and the opposite in summer when it the
sun comes up.

My problem is how to compare and make the program perceive the
relation. So, I think what I'm asking is if there is anything similar
to this
in use that anyone knows of, or if anyone has encountered a similar
problem, and what approach they may have taken?

TIA,
David
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Change to Class-level Variable

2010-10-03 Thread Robert
Why is "f1" not affected by the Class-level variable change below ?

>>> class Foo( object ):
... myid = 'Foo'
... def __init__( self ):
...pass
...
>>> f1 = Foo()
>>> f2 = Foo()
>>> f1.myid = 'Bar'
>>> Foo.myid = 'SPAM'
>>> f1.myid <--- Why is "f1" not affected by the 
>>> Class variable change ?
'Bar'
>>> f2.myid
'SPAM'
>>> f4 = Foo()
>>> f4.myid
'SPAM'
>>>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Change to Class-level Variable

2010-10-03 Thread Steven D'Aprano
On Mon, 4 Oct 2010 09:06:39 am Robert wrote:

> Why is "f1" not affected by the Class-level variable change below ?


The Python terminology is "attribute", not variable. You have class 
attributes and instance attributes.


> >>> class Foo( object ):
> ... myid = 'Foo'
> ... def __init__( self ):
> ...pass

That __init__ method does nothing. Leave it out:

class Foo(object):
myid = 'Foo'


> >>> f1 = Foo()
> >>> f2 = Foo()
> >>> f1.myid = 'Bar'

This creates an instance attribute called myid which masks the class 
attribute.


> >>> Foo.myid = 'SPAM'

This directly changes the class attribute.


Think of it this way: when you lookup an attribute, Python searches:

* the instance
* the class
* any superclasses

in that order, and returns the first matching value it finds. When you 
set an attribute, Python follows the same pattern, but naturally the 
first attempt (instance) will always succeed. (Note: this may not be 
what Python *actually* does, but conceptually it has always helped me 
reason about the behaviour.)

Python won't let you accidentally modify a class attribute. You have to 
do it explicitly. Here are three ways to do it:

type(f1).myid = 'Bar'
f1.__class__.myid = 'Bar'
Foo.myid = 'Bar'


(You might be able to do some sort of metaclass magic to change this 
behaviour, but consider that *very* advanced.)


-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Matching relational data

2010-10-03 Thread Steven D'Aprano
On Mon, 4 Oct 2010 08:33:07 am David Hutto wrote:
> I'm creating an app that charts/graphs data. The mapping of the
> graphs is the 'easy' part with matplotlib,
> and wx. My question relates to the alignment of the data to be
> processed.
>
> Let's say I have three sets of 24 hr graphs with the same time steps:
>
> -the position of the sun
> -the temp.
> -local powerplant energy consumption
>
>
> A human could perceive the relations that when it's wintertime, cold
> and the sun goes down, heaters are turned on
> and energy consumption goes up, and the opposite in summer when it
> the sun comes up.
> My problem is how to compare and make the program perceive the
> relation.

This is a statistics problem, not a programming problem. Or rather, 
parts of it *uses* programming to solve the statistics problem.

My statistics isn't good enough to tell you how to find correlations 
between three independent variables, but I can break the problem into a 
simpler one: find the correlation between two variables, temperature 
and energy consumption.

Without understanding how the data was generated, I'm not entirely sure 
how to set the data up, but here's one approach:

(1) Plot the relationship between:
x = temperature
y = power consumption

where x is the independent variable and y is the dependent variable.

(2) Look at the graph. Can you see any obvious pattern? If all the data
points are scattered randomly around the graph, there you can be
fairly sure that there is no correlation and you can go straight on
to calculating the correlation coefficient to make sure.

(3) But if the graph clearly appears to be made of separate sections, 
AND those sections correlate to physical differences due to the time 
of day (position of the sun), then you need to break the data set
into multiple data sets and work on each one individually.

E.g. if the graph forms a straight line pointing DOWN for the hours 
11pm to 5am, and a straight line pointing UP for the hours 5am
to 11pm, and you can think of a physical reason why this is
plausible, then you would be justified in separating out the data
into two independent sets: 5am-11pm, 11pm-5am.

If you want to have the program do this part for you, this is a VERY
hard problem. You're essentially wanting to write an artifical
intelligence system capable of picking out statistical correlations 
from data. Such software does exist. It tends to cost hundreds of
thousands of dollars, or millions. Good luck writing your own!

(4) Otherwise feel free to simplify the problem by just investigating
the relationship between temperature and power consumption during
(say) daylight hours.

(5) However you decide to proceed, you should now have one (or more) x-y
graph. First step is to decide whether there is any correlation at
all. If there is not, you can stop there. Calculate the correlation 
coefficient, r. r will be a number between -1 and 1. r=1 means a
perfect positive correlation; r=-1 means a perfect negative
correlation. r=0 means no correlation at all.

(6) Decide whether the correlation is meaningful. I don't remember how
to do this -- consult your statistics text books. If it's not
meaningful, then you are done -- there's no statistically valid
relationship between the variables.

(7) Otherwise, you want to calculate the line of best fit (or possibly
some other curve, but let's stick to straight lines for now) for the
data. The line of best fit may be complicated to calculate, and it
may not be justified statistically, so start off with something
simpler which (hopefully!) is nearly as good -- a linear regression
line. This calculates a line that statistically matches your data.

(8) Technically, you can calculate a regression line for *any* data,
even if it clearly doesn't form a line. That's why you are checking
the correlation coefficient to decide whether it is sensible or not.


By now any *real* statisticians reading this will be horrified :) What 
I've described is essentially the most basic, "Stats 101 for Dummies" 
level.

Have fun!



-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] subprocess.call warning

2010-10-03 Thread Steven D'Aprano
On Mon, 4 Oct 2010 06:44:54 am Norman Khine wrote:
> hello, from the docs http://docs.python.org/library/subprocess.html i
> see there is a WARNING about deadlock when using the subprocess.call.
> in my code i have this
>
> http://pastie.org/1197024


The warning says:

Like Popen.wait(), this will deadlock when using stdout=PIPE 
and/or stderr=PIPE and the child process generates enough 
output to a pipe such that it blocks waiting for the OS pipe 
buffer to accept more data.

Since you don't set either stdout or stderr to PIPE, you shouldn't have 
to worry about a deadlock.


> the first calls the 'sox' library which joins all the .wav files into
> one file and then i use the 'wav2swf' library to create a SWF output
> of the file.
>
> can the code be improved?

Code can always be improved :-) What do you consider an improvement? 
Easy to maintain in the future? Faster? Smaller?

What does get_abspath do? It sounds like it *may* be your own version of 
os.path.abspath. 

I'm not sure why you have a list called "imgtext" that doesn't contain 
text. It seems to be a list of partial file names rather than "image 
text".

Your code, as given, can't work, because you call isupper() on integers 
1 2 and 3. That will fail.

I'd probably prefer to generate the filenames differently:

def fix_filename(fname, base=sound_path):
fname = str(fname)
if fname.isupper():
fname = "upper_%s" % fname.lower()
return os.path.join(base, fname + '.wav')

and then call it:

filenames = ['A', 'b', 'c', 'D', 1, 2, 3]
for name in filenames:
name = fix_filename(name)
sox_filenames.append(name)


-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Networking

2010-10-03 Thread Chris King

 On 10/2/2010 3:40 PM, Evert Rol wrote:

Dear Tutors,
 I have attached my 2 programs for networking. It uses socket and 
SocketServer, but it just simplifies it even more. The problem is it won't 
work. The Client raises the error, (with trace back)
Traceback (most recent call last):
   File "G:\My Dropbox\My Dropbox\Chris\Not done\client.py", line 34, in
 print client.recv()
   File "G:\My Dropbox\My Dropbox\Chris\Not done\client.py", line 16, in recv
 return self.__sock.recv(1024)
error: [Errno 10053] An established connection was aborted by the software in 
your host machine
The server seems to get an error of some sort, but also seems to catch and 
print it. It prints

Exception happened during processing of request from ('127.0.0.1', 1424)
Traceback (most recent call last):
   File "C:\Python26\lib\SocketServer.py", line 281, in _handle_request_noblock
 self.process_request(request, client_address)
   File "C:\Python26\lib\SocketServer.py", line 307, in process_request
 self.finish_request(request, client_address)
   File "C:\Python26\lib\SocketServer.py", line 320, in finish_request
 self.RequestHandlerClass(request, client_address, self)
TypeError: 'NoneType' object is not callable

I look at both of the documentations of socket and SocketServer, but I couldn't 
firgue it out. I don't know much about networking. Please Help

I don't know much about networking, less so about it on Windows; also, I've 
only scanned quickly through the server script, but I notice your 
create_handler() function doesn't return anything. I guess it needs to return 
the Handler class.
The example in the Python docs doesn't use a factory function, but instead 
directly puts the class as the second argument to TCPServer.
So the second argument needs to be a class, but since your create_handler() 
function returns nothing, you presumably get this NoneType exception.

   Evert


Yeah, that could be a problem. It should return the class.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (de)serialization questions

2010-10-03 Thread Alan Gauld


"Albert-Jan Roskam"  wrote

It makes much more sense to maintain one database table instead of 3 
csv files

for the three data typists' output.


To be pedantic you will probably want several tables but they will all
be in one file... :-)


Btw, your private website is nice too. Nice pictures!


Well done, not many people notice that section :-)
I keep meaning to add another dozen or so pages,
but finding time


Do you recognize where this was taken:
http://yfrog.com/n0scotland046j .



Could be any of a dozen places but if pushed I'll guess the Rannoch 
Moor.
Maybe the top end of Glencoe? But the layer of low cloud wipes out too 
much

to be sure.


You're lucky to live in a beautiful place like Scotland


I think so :-)

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Matching relational data

2010-10-03 Thread Alan Gauld


"David Hutto"  wrote


My problem is how to compare and make the program perceive the
relation. So, I think what I'm asking is if there is anything 
similar
to this in use that anyone knows of, or if anyone has encountered a 
similar

problem, and what approach they may have taken?


Its a stats problem.

One of the best programming stats tools is R

http://en.wikipedia.org/wiki/R_%28programming_language%29

There is a python bionding for R too.

Although R may be overkill for what you want, but at least
you'll know the theory and math are correct!

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Change to Class-level Variable

2010-10-03 Thread Alan Gauld


"Robert"  wrote


class Foo( object ):

... myid = 'Foo'
... def __init__( self ):
...pass
...

f1 = Foo()
f2 = Foo()
f1.myid = 'Bar'


This creates a myid instance variable in f1 which hides the class 
variable.

You should always modify class variables via the class not an instance
(you can read them either way but I prefer to use the class for both 
read

and write)



Foo.myid = 'SPAM'
f1.myid <--- Why is "f1" not affected 
by the Class variable change ?

'Bar'


Because this is accessing the instance variable not the class one.

You can get at the class variable from the instance usind __class__
but usually you don'tneed to. You know the class in context or you
want the instance data not the class data.


f1.__class__.myid

'SPAM'

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Matching relational data

2010-10-03 Thread David Hutto
On Sun, Oct 3, 2010 at 6:37 PM, Steven D'Aprano  wrote:
> On Mon, 4 Oct 2010 08:33:07 am David Hutto wrote:
>> I'm creating an app that charts/graphs data. The mapping of the
>> graphs is the 'easy' part with matplotlib,
>> and wx. My question relates to the alignment of the data to be
>> processed.
>>
>> Let's say I have three sets of 24 hr graphs with the same time steps:
>>
>> -the position of the sun
>> -the temp.
>> -local powerplant energy consumption
>>
>>
>> A human could perceive the relations that when it's wintertime, cold
>> and the sun goes down, heaters are turned on
>> and energy consumption goes up, and the opposite in summer when it
>> the sun comes up.
>> My problem is how to compare and make the program perceive the
>> relation.
>
> This is a statistics problem, not a programming problem. Or rather,
> parts of it *uses* programming to solve the statistics problem.
>
> My statistics isn't good enough to tell you how to find correlations
> between three independent variables, but I can break the problem into a
> simpler one: find the correlation between two variables, temperature
> and energy consumption.


This was the initial starting point, but I thought that the comparing
multiples should set the tone
for how the data is interpreted, but you're right, I should start with
two, and then give relation to relation within the 2 object compared
structure.

So if x and y are compared and related, then it makes since that if x
and b are compared and related, that b and y are related in some way
because they have a in common in terms of 2 object comparison
relationals.

or:
(see below for comparative % based statistic analysis algorithm)
x and y = related
x and b = related
eg. y and b = related



but that gives the origin and the end comparison paradox of my end
desires for the program. Do I compare the end object to all or do
random 2 coordinate list comparisons and match the data over
corresponding timesteps, then eliminate the list of comparable based
on a hierarchy of matches, in other words?

if x relates to y and x relates to b:


So I have(really rough pseudo code for time constraints):

list1 = [+,+,+,+,-,+,-,+,-,+]
list2 = [-,+,+,+,-,+,-,+,-,+]

Above I have a 90% match to timestep increments/decrements, that over
say, one minute
periods, x and y both increased or decreased together 90% of the time,
or the opposite, that they diverged 90%
of the time.



>
> Without understanding how the data was generated, I'm not entirely sure
> how to set the data up, but here's one approach:
>
> (1) Plot the relationship between:
>    x = temperature
>    y = power consumption
>
>    where x is the independent variable and y is the dependent variable.
>
> (2) Look at the graph. Can you see any obvious pattern? If all the data
>    points are scattered randomly around the graph, there you can be
>    fairly sure that there is no correlation and you can go straight on
>    to calculating the correlation coefficient to make sure.
>
> (3) But if the graph clearly appears to be made of separate sections,
>    AND those sections correlate to physical differences due to the time
>    of day (position of the sun), then you need to break the data set
>    into multiple data sets and work on each one individually.
>
>    E.g. if the graph forms a straight line pointing DOWN for the hours
>    11pm to 5am, and a straight line pointing UP for the hours 5am
>    to 11pm, and you can think of a physical reason why this is
>    plausible, then you would be justified in separating out the data
>    into two independent sets: 5am-11pm, 11pm-5am.
>
>    If you want to have the program do this part for you, this is a VERY
>    hard problem. You're essentially wanting to write an artifical
>    intelligence system capable of picking out statistical correlations
>    from data. Such software does exist. It tends to cost hundreds of
>    thousands of dollars, or millions. Good luck writing your own!
>
> (4) Otherwise feel free to simplify the problem by just investigating
>    the relationship between temperature and power consumption during
>    (say) daylight hours.
>
> (5) However you decide to proceed, you should now have one (or more) x-y
>    graph. First step is to decide whether there is any correlation at
>    all. If there is not, you can stop there. Calculate the correlation
>    coefficient, r. r will be a number between -1 and 1. r=1 means a
>    perfect positive correlation; r=-1 means a perfect negative
>    correlation. r=0 means no correlation at all.
>
> (6) Decide whether the correlation is meaningful. I don't remember how
>    to do this -- consult your statistics text books. If it's not
>    meaningful, then you are done -- there's no statistically valid
>    relationship between the variables.
>
> (7) Otherwise, you want to calculate the line of best fit (or possibly
>    some other curve, but let's stick to straight lines for now) for the
>    data. The line of best fit may be complicated to calc