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

Issues with bivariate statistics variables #1426

Open
prismv opened this issue Mar 9, 2025 · 1 comment
Open

Issues with bivariate statistics variables #1426

prismv opened this issue Mar 9, 2025 · 1 comment
Labels
bug Something isn't working user Reported by an actual user, yay!

Comments

@prismv
Copy link

prismv commented Mar 9, 2025

I tried to implement as RPL expressions standard deviation of linear regression results as sLR vector.
Furthermore In the HP50g user guide (hp50g-ug-en.pdf) page 18-52/-53 there are formulas of confidence intervals - cfLR is the vector name here.

Input was merely possible as a direct expression (or more precise multiplication of 2 expressions), because e.g. (ΣSize) is needed in input mode for proper evaluation, but the brackets are removed on saved expression on stack. There seems to be also a clash with ΣX² and (ΣX)².

The workaround was to use local variables for the dubious acting parameters.
The following shown implementation works for cfLR without any bad indications, but sLR gets a wrong output every second time Correlation is evaluated in alternation!

	dStats
		Directory {
			cfLR
				«
					'ΣSize' 'ΣX' 'ΣX²'
					'ΣY²' 'Correlation'
					→ N SX SXX SYY
					r
					«
						'√((N-1)÷(N-2)·SYY·(1-r²))'
						[ '√((N+SX²÷SXX)÷N²)'
							'1÷√ SXX' ]
						× →Num
					»
				»
			sLR
				«
					'ΣSize' 'ΣX' 'ΣY'
					'ΣXY' 'ΣX²' 'ΣY²'
					→ N SX SY SXY SXX
					SYY
					«
						'√((SYY-Slope·SXY-Intercept·SY)·SXX÷(N-2)÷(N·SXX-SX²))'
						[ 1 '√(N÷SXX)'
						] × →Num
					»
				»
			ΣParameters
				{ 1 2 49/5 1 LinearFit
				}
			ΣData
				[[ 1 11 ]
				  [ 2 19 ]
				  [ 3 33 ]
				  [ 4 39 ]]
		}

Because of several other reference implementations I can be sure that for given ΣData the result of sLR has to be [ 2.846 1.0392 ], so Slope is 49/5 with std.dev. of 1.0392.

Note: The result of cfLR with [ 6.838 1.8441 ] is not a fully expected result, because it cannot be calculated from the std.dev. values for intercept and slope by a single factor. So either there is still a typing error in my code, or an error in the HP50g user guide. But in effect this function showed me also the side effect of Correlation call on the other function sLR.

@c3d c3d added bug Something isn't working user Reported by an actual user, yay! labels Mar 13, 2025
@c3d
Copy link
Owner

c3d commented Mar 13, 2025

Thanks for the resport, @prismv. I will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working user Reported by an actual user, yay!
Projects
None yet
Development

No branches or pull requests

2 participants