Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actual b value falls outside slider range #92

Open
KatieWoe opened this issue Dec 18, 2024 · 5 comments
Open

Actual b value falls outside slider range #92

KatieWoe opened this issue Dec 18, 2024 · 5 comments
Assignees
Labels

Comments

@KatieWoe
Copy link
Contributor

Test device
Lenovo
Operating System
Win 11
Browser
Chrome
Problem description
For phetsims/qa#1190. Occurs in the published version.
The best fit line for Temperature(C) vs Latitude has a b value of 42.5. The My Line slider only goes up to 40. The actual value only falls slightly outside the slider range and this seems to be the only set with this issue, so it likely isn't worth addressing.

Troubleshooting information:

!!!!! DO NOT EDIT !!!!!
Name: ‪Least-Squares Regression‬
URL: https://phet-dev.colorado.edu/html/least-squares-regression/1.2.0-dev.1/phet/least-squares-regression_all_phet.html
Version: 1.2.0-dev.1 2024-12-18 13:54:12 UTC
Features missing: applicationcache, applicationcache, touch
Flags: pixelRatioScaling
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Language: en-US
Window: 1280x631
Pixel Ratio: 1.5/1
WebGL: WebGL 1.0 (OpenGL ES 2.0 Chromium)
GLSL: WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)
Vendor: WebKit (WebKit WebGL)
Vertex: attribs: 16 varying: 30 uniform: 4096
Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32)
Max viewport: 32767x32767
OES_texture_float: true
Dependencies JSON: {}

@samreid
Copy link
Member

samreid commented Dec 19, 2024

@amanda-phet what do you recommend?

@samreid samreid assigned amanda-phet and unassigned samreid Dec 19, 2024
@amanda-phet
Copy link
Contributor

I took a look at some of the other data sets, and they all have b ranges of [-n, n] that vary based on the graph's scale, except for Temperature (C) vs. Longitude and Temperature (C) vs. Latitude. I'm not sure how they are all calculated, but these two definitely seem out of place, as they have a range of [-80,40].

My recommendation would be to change those two b ranges to be [-80,80].

@samreid
Copy link
Member

samreid commented Dec 20, 2024

I discovered this part of the implementation is awkward. The range of the slider is always -1.5 to 1.5 and there is a linear transform of its value to determine what to show in the equation. I found that this code:

/**
* Sets the horizontal and vertical graph domain of dataSets and the corresponding multiplicative factor
* for the slope and intercept.
*/
public setGraphDomain( xRange: Range, yRange: Range ): void {
this.slopeFactor = ( yRange.max - yRange.min ) / ( xRange.max - xRange.min ) / ( this.bounds.height / this.bounds.width );
this.interceptFactor = ( yRange.max - yRange.min ) / this.bounds.height;
this.interceptOffset = ( yRange.min );
}
/**

was setting the y-intercept offset to be 0 in most of the cases, and negative in the case of the Celsius temperatures (which are the only ones with nonzero y minimum). I would like to try hard-coding the interceptOffset to 0, which will ideally keep the other behavior the same and center the Celsius. However, it will go -60 to 60 rather than -80 to 80 due to the remainder of that calculation. Is that OK?

@amanda-phet
Copy link
Contributor

In theory, yes, [-60,60] would be fine, but on phettest I'm seeing this equation, which will mean we still have a problem:
image

@samreid
Copy link
Member

samreid commented Dec 21, 2024

I'm stunned since I changed the y axis range from (-20,20) to (-30,30) and while this expanded the range of the b slider to +/-90, it surprisingly also changed the values of the best fit line from y=-1.17x +62.5 to y=-1.17+72.5:

image

I do not believe that changing the chart axis range should affect the best fit line at all. So something very mysterious and fragile is happening, or I am very confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants