so i have to write regression line program which is hard enough seeing as i just started so i need help,
1st thing is how do i write a loop for mouse clicks of any number,
then write the average of whatever the amount of mouseclicks, thanks!

Yeah, that's a challenging newbie project.

Start by solving your problem in English -- write a plan that closely imitates how you would do this by hand.

Then we can help turn your plan into code.

Jeff

ok so
we need a window(graphWin) done!
need mouse clicks getMouse()done!
need to loop these until a button is clicked!
loop these then an "elif" click in the button????

then find the mean of all the x,y-values and make the line!!

Hi gusbear,

Are you using the Zelle graphics module? If you are, I think you should try the following strategy. Create a GraphWin, then in one of the corners make a button by drawing a rectangle, and inside it printing "Compute" or something like that. The API for the graphics module I am thinking of can be found here. This should tell you how to draw lines, points, rectangles, text, and all that other stuff.

After making the "button" also create an empty list called 'points' and set a flag variable to false. Now run a loop while the flag variable is false. In every iteration of the loop, do a getMouse() call. This function returns a Point object which tells you where on the GraphWin the mouse was pressed. Once you get the Point object, look at it: if it was inside the range of the "button" then set the flag to true (which causes the loop to exit). Otherwise, append the Point to our 'points' list and draw a point or small circle on that spot on the GraphWin. After the loop, use the 'points' list to do the linear regression.

In code, it would sort of look like this:

width, height = 300, 300
gw = GraphWin("Linear Regression", width, height, true)
make_button(gw) # draw the button on the GraphWin
points = []
quit_loop = false
while not quit_loop:
     p = getMouse()
     quit_loop = user_clicked_button(p) # check for button clicks
     if not quit_loop:
          points.append(p)
          draw_point(p, gw) # draw the Point on the GraphWin
compute_regression(points) # compute the linear regression

Of course, you'd need to come up with the make_button(), user_clicked_button(), draw_point(), and compute_regression() functions on your own.

Hope this helps!

did you get this done. Because I could use the code!!!?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.