clbustos / distribution

Statistical Distributions multi library wrapper. Uses Ruby by default and C (statistics2/GSL) or Java extensions where available.
Other
141 stars 52 forks source link

Remove unnecessary computation #22

Open ssowonny opened 8 years ago

ssowonny commented 8 years ago

I don't think this line is required. Or please let me know if I miss something.

envp commented 8 years ago

The code you refer to is not unnecessary. The purpose it serves is to execute the second statement only if the first returns true, so that the who expression is truthy.

See here for a running example.

The reason for having that tidbit there is to exploit the symmetry of the error-function so that only values for qn <= 0.5 need to be computed.

ssowonny commented 8 years ago

But the updated value doesn't effect the final value. Even if the first statement is true, the w3 value is same.

2016년 3월 3일 (목) 오후 10:07, Vaibhav Yenamandra notifications@github.com님이 작성:

The code you refer to is not unnecessary. The purpose it serves is to execute the second statement only if the first returns true, so that the who expression is truthy.

See here http://ideone.com/c3D6Ki for a running example.

The reason for having that tidbit there is to exploit the symmetry of the error-function so that only values for qn <= 0.5 need to be computed.

— Reply to this email directly or view it on GitHub https://github.com/clbustos/distribution/pull/22#issuecomment-191753617.

envp commented 8 years ago

Ah, my bad there. w3 is defined as a function of w1*(1-w1), so updating w1 to be < 0.5 wont matter as such. So you're right

With that in mind, thanks for noting this @ssowonny!

The Sciruby files also suffer from this issue, I think its better to post this there for completeness. Since the Sciruby fork is ahead in terms of commits & functionality.

ssowonny commented 8 years ago

I posted it on the repository. Thanks :wink: