183) (View other files uploaded by lehalle) The HTML version of this file is shown below. To use the contents of this file in a posting, click here to get the source code
> retart;

Functional object programming with Maple
Author: Charles-Albert LEHALLE, PhD
Simplest functional object
> simplest_fo:=proc(n) local this, set_;
this := [n];
set_:=proc( p); this[1]:=p; end proc;
table(['get'= (x->this[1]), 'set'= set_]);
end proc;

> foo:=simplest_fo( 2);

> foo['get']();

> foo['set'](5);

> foo['get']();

Application to probability distributions
> G:=(m,s)->(t->(exp(-(t-m)^2/(2*s^2))/(sqrt(2*Pi)*s)));

> structured_distribution:=proc( f, A, B)
table(['density'= (x->f(x)), 'repartition'=(x->Int(f(t),t=A..x)), 'plot'=(t->plot(f(x),x=A..B))]);
end proc:
> SD:=structured_distribution( G(0,1), -infinity, infinity):
> SD['density'](1);

> SD['repartition'](1);

> SD['plot']();

>
>
>
This post was generated using the MaplePrimes File Manager
View 744_indexed-output.mw on MapleNet or Download 744_indexed-output.mw
View file details
Copy this code into any posting to insert this file into a posting on MaplePrimes
IMPORTANT INFORMATION
When pasting this code into a post on MaplePrimes, make sure that you choose the Worksheet HTML input format
Functional object programming with Maple
Author: Charles-Albert LEHALLE, PhD
Simplest functional object
> simplest_fo:=proc(n) local this, set_;
this := [n];
set_:=proc( p); this[1]:=p; end proc;
table(['get'= (x->this[1]), 'set'= set_]);
end proc;

> foo:=simplest_fo( 2);

> foo['get']();

> foo['set'](5);

> foo['get']();

Application to probability distributions
> G:=(m,s)->(t->(exp(-(t-m)^2/(2*s^2))/(sqrt(2*Pi)*s)));

> structured_distribution:=proc( f, A, B)
table(['density'= (x->f(x)), 'repartition'=(x->Int(f(t),t=A..x)), 'plot'=(t->plot(f(x),x=A..B))]);
end proc:
> SD:=structured_distribution( G(0,1), -infinity, infinity):
> SD['density'](1);

> SD['repartition'](1);

> SD['plot']();

>
>
>
This post was generated using the MaplePrimes File Manager
View 744_indexed-output.mw on MapleNet or Download 744_indexed-output.mw
View file details
Copy this code into any posting to share this file with other users
1 min 48 sec ago
1 min 55 sec ago
39 min 30 sec ago
39 min 32 sec ago
1 hour 46 min ago
1 hour 59 min ago
2 hours 47 min ago
2 hours 57 min ago
3 hours 13 min ago
3 hours 28 min ago