SetDirectory["/Users/akb/Dropbox/Trabajo/URL/akb_files/Cursos/Mathematica/actividades"]

lista={a,b,c,d,e,f}

Dimensions[lista]

Table[(el^2),{el,lista}]

lista=Import["data1.txt","Table"];

Dimensions[lista]

lista[[1]]

lista[[1]]

lista[[1;;15]]

listaf=Flatten[lista];

listaf[[1]]

listaf[[1;;15]]

Histogram[listaf]

Histogram[listaf,100]

histolist=HistogramList[listaf,10]

histolist=HistogramList[listaf,500];
h1=histolist[[1]];
h2=histolist[[2]];
d1=Dimensions[h1][[1]]
d2=Dimensions[h2][[1]]

histolistord=Table[{(h1[[i]]+h1[[i+1]])/2.0,h2[[i]]},{i,1,d2}];

Dimensions[histolistord]

ListPlot[histolistord]

fun=(A1/(Sqrt[2π])) Exp[-(1/2)(((((x-x1)/s1)))^2)]+(A2/(Sqrt[2π])) Exp[-(1/2)(((((x-x2)/s2)))^2)]

fit=FindFit[histolistord,fun,{A1,s1,x1,A2,s2,x2},x]

plot={ListPlot[histolistord],Plot[fun/.fit,{x,0,15}]};

Show[plot]

fit=FindFit[histolistord,fun,{{A1,150},{s1,2},{x1,5},{A2,210},{s2,0.2},{x2,12}},x]

plot={ListPlot[histolistord],Plot[fun/.fit,{x,0,15}]};
Show[plot]

plot={ListPlot[histolistord],Plot[fun/.fit,{x,0,15}]};
Show[plot]

fun1=(A1/(Sqrt[2π])) Exp[-(1/2)(((((x-x1)/s1)))^2)]
fun2=(A2/(Sqrt[2π])) Exp[-(1/2)(((((x-x2)/s2)))^2)]
plot={ListPlot[histolistord],Plot[{fun1/.fit,fun2/.fit,fun/.fit},{x,0,15}]};
Show[plot]

plot={ListPlot[histolistord],Plot[{fun1/.fit,fun2/.fit,fun/.fit},{x,0,15},Filling->Bottom]};
Show[plot]

lista=Import["data2.txt","Table"];
listaf=Flatten[lista];
histolist=HistogramList[listaf,20];
h1=histolist[[1]];
h2=histolist[[2]];
d1=Dimensions[h1][[1]]
d2=Dimensions[h2][[1]]
histolistord=Table[{(h1[[i]]+h1[[i+1]])/2.0,h2[[i]]},{i,1,d2}];
fit=FindFit[histolistord,fun,{{A1,150},{s1,2},{x1,5},{A2,210},{s2,0.2},{x2,12}},x]
plot={Plot[{fun1/.fit,fun2/.fit,fun/.fit},{x,0,27},PlotRange->All],ListPlot[histolistord,PlotRange->All]};
Show[plot]

plot={Histogram[listaf],Plot[{fun1/.fit,fun2/.fit,fun/.fit},{x,0,25},PlotRange->All]};
Show[plot]

lista=Import["data2.txt","Table"];
listaf=Flatten[lista];
histolist=HistogramList[listaf,20];
h1=histolist[[1]];
h2=histolist[[2]];
d1=Dimensions[h1][[1]]
d2=Dimensions[h2][[1]]
histolistord=Table[{(h1[[i]]+h1[[i+1]])/2.0,h2[[i]]},{i,1,d2}];
fit=FindFit[histolistord,fun,{{A1,150},{s1,2},{x1,5},{A2,210},{s2,0.2},{x2,12}},x]
plot={Plot[{fun1/.fit,fun2/.fit,fun/.fit},{x,0,27},PlotRange->All],ListPlot[histolistord,PlotRange->All]};
Show[plot]