Page 1 of 1

Normalizing data..........any suggestions?

Posted: Fri Mar 27, 2015 2:44 am
by Rage
Hello all, I'm brand new to livecode and have programmed in #c among others but I'm having a difficult time trying to figure this equation out with regards to livecode.
The code was written in Zeno and is as follows:

IP:=normalize((JD-2451550.1)/29.530588853)

I have scoured the Zeno programming reference but it seems to left out the definition for "normalize"
in researching the term, I've found statistical reference and waveform reference with regards to known mins and maxs but nothing seems to refer to the useage in this equation.

My question is: is there a comparable way to "normalize" an equation like this in livecode?

Thank you in advance for any ideas you might have that can shed some light on this for me.

Re: Normalizing data..........any suggestions?

Posted: Fri Mar 27, 2015 4:58 am
by dunbarx
Hi.

LC has a full complement of mathematical functions. It is simply a matter of writing a handler to do what you need. There seem to be several forms of normalization, for data, in statistics , in database manipulation, whatever.

If you will describe more completely what you need, we will find a method.

Craig Newman

Re: Normalizing data..........any suggestions?

Posted: Fri Mar 27, 2015 5:56 am
by Rage
Thank you Craig for your response. I'm writing a moon phase calculation which determines the ecliptic latitude/longitude of the moon on any day.
here is the snippet of code which concerns the function 'normalize' where IP,AG,NP, and RP are integers

% calculate moon's age in days
IP := normalize( ( JD - 2451550.1 ) / 29.530588853 )
AG := IP*29.53
% calculate moon's ecliptic latitude
NP := 2*PI*normalize( ( JD - 2451565.2 ) / 27.212220817 )
LA := 5.1*sin( NP )
% calculate moon's ecliptic longitude
RP := normalize( ( JD - 2451555.8 ) / 27.321582241 )
LO := 360*RP + 6.3*sin( DP ) + 1.3*sin( 2*IP - DP ) + 0.7*sin( 2*IP )

Since this isn't a series of number per se it would seem the normal process of applying normalization wouldn't be appropriate

Re: Normalizing data..........any suggestions?

Posted: Fri Mar 27, 2015 6:48 am
by WaltBrown
Rage,
What does "JD" stand for? Also, do you have an example of the calculation in Zeno with the output (what IP contains after the "normalize")? That would give some more clues.
Thanks,
Walt

Re: Normalizing data..........any suggestions?

Posted: Fri Mar 27, 2015 7:46 am
by WaltBrown
Normalize is a procedure defined at the bottom of the code you are using - lunarphasecalc.zen:

Code: Select all

% normalize values to range 0...1
function normalize( v : real ) : real
    v := v - floor( v ) 
    if v < 0 then
        v := v + 1
    end if
    return v
end function

Re: Normalizing data..........any suggestions?

Posted: Fri Mar 27, 2015 12:29 pm
by Rage
Thank you so much Walt, the answer was obvious but by concentrating so much on the problem I didn't see the answer that was right in the code........