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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Rage
Posts: 12
Joined: Fri Mar 27, 2015 2:34 am

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

Post by Rage » Fri Mar 27, 2015 2:44 am

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

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

Post by dunbarx » Fri Mar 27, 2015 4:58 am

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

Rage
Posts: 12
Joined: Fri Mar 27, 2015 2:34 am

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

Post by Rage » Fri Mar 27, 2015 5:56 am

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

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

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

Post by WaltBrown » Fri Mar 27, 2015 6:48 am

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
Walt Brown
Omnis traductor traditor

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

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

Post by WaltBrown » Fri Mar 27, 2015 7:46 am

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
Walt Brown
Omnis traductor traditor

Rage
Posts: 12
Joined: Fri Mar 27, 2015 2:34 am

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

Post by Rage » Fri Mar 27, 2015 12:29 pm

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........

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”