in reply to Re: Data averages by time of day
in thread Data averages by time of day

To get at the formula that results from the approximation, try this: (The normal Math::Approx methods also work on Math::Approx::Symbolic objects.)
use Math::Approx::Symbolic; my %data = ( (7*60+1) => 82, (23*60+48) => 188, ); my $approx = Math::Approx::Symbolic->new(undef, 3, %data); my $sym = $approx->symbolic(); print "$sym\n"; my $prettier = $sym->to_latex(); print "$prettier\n"; # Computing y-values: print $sym->value(x => time_of_day()), "\n"; # Doing that faster: use Math::Symbolic::Compiler; my ($closure) = $sym->to_sub(); print $closure->(time_of_day()), "\n"; # Way faster: use Math::Symbolic::Custom::CCompiler; my $inlined_c = $sym->to_compiled_c(); print $inlined_c->(time_of_day()), "\n";