Attempt to make function of random variables UI. The idea is that one will enter a function Y of a random variable X and see the transformation on the screen. It works for basic functions, but this still needs much work to make it of more use. This was something I was trying.

by Nasser Abbasi 2007

Manipulate[process[firstPDF,func,funcPars,firstPDFpars,centerAround,width,yaxis],

{{firstPDF,1,"Select X random variable density distribution (Subscript[f, X])(x):"},{1->"Normal",2->"Exponential",3->"Gamma"},ControlType->PopupMenu},

{{firstPDFpars,HoldForm[{μ->1,σ->1}],"Type in numerical values for all parameters for above distribution:"},ControlType->InputField[]},

{{func,HoldForm[a X+b],"Type in the random variable function: Y="},ControlType->InputField[]},

{{funcPars,HoldForm[{a->2,b->4}],"Type in numerical values for any unknowns in function above:"},ControlType->InputField[]},

{{centerAround,0,"[x axis] centered around? ="},-100,100,1,Appearance->"Labeled"},
{{width,33,"[x axis]  width around center? ="},0.001,500,0.1,Appearance->"Labeled"},
{{yaxis,5,"[y axis]  adjust? ="},0.0001,500,0.1,Appearance->"Labeled"},Initialization:>
{
gDebug=False;
(*******************************************)
(*  getXParameters                         *)
(*******************************************)
getXParameters[firstPDFID_]:=Module[{s},
Which[firstPDFID==1,s=Row[{"Mean=",Text[Mean[NormalDistribution[μ,σ]]],"  Variance=",Text[Variance[NormalDistribution[μ,σ]]]}],
firstPDFID==2,s=Null,
True,s=Null
];
s
];
(*******************************************)
(*  getNormalParameters                    *)
(*******************************************)
getNormalParameters[yPDFsymbolic_]:=Module[{s,var,mean,tmp},
tmp=DeleteCases[yPDFsymbolic,1/Sqrt[2 Pi]];
If[gDebug,Print[tmp]];
tmp=DeleteCases[tmp,Exp[x_]];
If[gDebug,Print[tmp]];
var=Denominator[tmp];
If[gDebug,Print[var]];
var=var^2;
tmp=Cases[yPDFsymbolic,Exp[x_]->x];
If[gDebug,Print[tmp]];

tmp=tmp*2 (σ^2);
tmp=Cases[tmp,-(x_)^2->x];
If[gDebug,Print[tmp]];

tmp=First@Solve[tmp==0,y];
mean=y/.tmp;
If[gDebug,Print[mean]];
s=Row[{"Mean=",Text[mean],"  Variance=",Text[var]}]
];

(*******************************************)
(*  getYParameters                         *)
(*******************************************)
getYParameters[yPDFsymbolic_,firstPDFID_]:=Module[{s},
Which[firstPDFID==1,s=getNormalParameters[yPDFsymbolic],firstPDFID==2,s=Null,True,s=Null];
s
];

(*******************************************)
(*  sim                                    *)
(*******************************************)
sim[firstPDF_,func_,funcPars_,firstPDFpars_,centerAround_,width_,firstPDFID_,yaxis_]:=Module[{z,p1,p2,title,yPDFsymbolic,yPDFnumeric,xPDFnumeric,sy,sx,nSolutions,i,allSolutions,tmp,sign},

If[gDebug,Print["func= ",func]];
allSolutions=X/.Solve[func,X];
nSolutions=Length[allSolutions];
yPDFsymbolic=0;
yPDFnumeric=0;

For[i=1,i≤nSolutions,i++,
{
z=allSolutions[[i]]/.{Y->y};
If[gDebug,Print["solution is ",z]];
tmp=D[z,y] PDF[firstPDF,x]/.{x->z};
If[gDebug,Print["tmp ",tmp]];
If[nSolutions>1,If[Mod[i,2]==0,sign=(1),sign=(-1)],sign=(1)];
If[gDebug,Print["sign is ",sign]];
yPDFsymbolic=yPDFsymbolic+(sign*tmp);
If[gDebug,Print["Now yPDFsymbolic ",yPDFsymbolic]];
tmp=tmp/.firstPDFpars;
tmp=tmp/.funcPars;
yPDFnumeric=yPDFnumeric+sign*tmp;

If[gDebug,Print["yPDFsymbolic ",yPDFsymbolic]];
If[gDebug,Print["yPDFnumeric ",yPDFnumeric]];
}
];

If[gDebug,Print["**yPDFsymbolic ",yPDFsymbolic]];
If[gDebug,Print["**yPDFnumeric ",yPDFnumeric]];

xPDFnumeric=Simplify[ PDF[firstPDF,x]/.firstPDFpars];
yPDFsymbolic=Simplify[ yPDFsymbolic];
yPDFnumeric=Simplify[ yPDFnumeric];

p1=Plot[ xPDFnumeric
,{x,centerAround-width/2,centerAround+width/2},
PlotRange->{All,{-yaxis,yaxis}},
PlotStyle->Red
];


(*sy=getYParameters[yPDFsymbolic,firstPDFID];*)
sx=getXParameters[firstPDFID];

title=Row[{"(Subscript[f, x])(x)=",Text[PDF[firstPDF,x]]," =",Text[xPDFnumeric],"\t",
sx,"\n",
"(Subscript[f, y])(y)=",Text[yPDFsymbolic]," =",Text[yPDFnumeric]}];

p2=Plot[ yPDFnumeric,{y,centerAround-width/2,centerAround+width/2},PlotRange->{All,{-yaxis,yaxis}}];


Show[{p1,p2},PlotLabel->title]
];

(*******************************************)
(*  process                                *)
(*******************************************)
process[firstPDFID_,func_,funcPars_,firstPDFpars_,centerAround_,width_,yaxis_]:=Module[{firstPDF,firstPDFpars2,func2,mapping,funcPars2},(*sim[firstPDF,func,funcPars,firstRpars]*)

If[funcPars==Null,funcPars={}];

Which[firstPDFID==1,firstPDF=NormalDistribution[μ,σ],firstPDFID==2,firstPDF=ExponentialDistribution[λ],True,firstPDF=0];

func2=ReleaseHold[func];
funcPars2=ReleaseHold[funcPars];
firstPDFpars2=ReleaseHold[firstPDFpars];

mapping=Y==func2;
sim[firstPDF,mapping,funcPars2,firstPDFpars2,centerAround,width,firstPDFID,yaxis]
];

}
]