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

code sample: the standard normal distribution #2

Open
YujiSODE opened this issue Mar 1, 2018 · 2 comments
Open

code sample: the standard normal distribution #2

YujiSODE opened this issue Mar 1, 2018 · 2 comments

Comments

@YujiSODE
Copy link
Owner

YujiSODE commented Mar 1, 2018

No description provided.

Repository owner locked and limited conversation to collaborators Mar 1, 2018
@YujiSODE YujiSODE closed this as completed Mar 1, 2018
@YujiSODE YujiSODE reopened this Mar 1, 2018
@YujiSODE
Copy link
Owner Author

YujiSODE commented Mar 1, 2018

sample codes to fit the standard normal distribution

#normalDist_sample_regLines.tcl
#test codes for "regLines.tcl"
source ./regLines.tcl;
#normal distribution
proc F {X} {
	set X [expr {double($X)}];
	set pi 3.141592653589793;
	return [expr {exp(-($X**2)/2)/sqrt(2*$pi)}];
};
set x {};set y {};
set I [format %.4f -4.0];
set dI [format %.4f 0.025];
while {$I<(4.0+$dI)} {
	lappend x $I;
	lappend y [format %.4f [F $I]];
	set I [format %.4f [expr {$I+$dI}]];
};
#input data range: 1.0
::regLines::reglines $x $y "reglinesSample[clock seconds]";
#estimating p-value
set i 0;set j 0;
set v0 0.0;set v 0.0;
while {$i<10} {
	while {$j<1000} {
		set r [format %.4f [expr {linesVar()}]];
		set v0 [expr {$r<1.96?$v0:$v0+1}];
		incr j 1;
	};
	set v [format %.4f [expr {$v+($v0/1000)}]];
	incr i 1;
};
set p [expr {$v/10}];
puts stdout "P(x>=1.96):$p";

output script is here
1519969884_nrmdist

@YujiSODE YujiSODE changed the title code samples code sample: the standard normal distribution Mar 4, 2018
@YujiSODE
Copy link
Owner Author

YujiSODE commented Mar 4, 2018

Generated random variables

normal_randomvar

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

No branches or pull requests

1 participant