Re: simple question
- To: mathgroup at smc.vnet.net
- Subject: [mg105247] Re: [mg105202] simple question
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Wed, 25 Nov 2009 02:34:56 -0500 (EST)
- References: <200911241048.FAA00724@smc.vnet.net>
Hi Francisco, The simplest is probably to use GatherBy: Clear[gatherByPositions]; gatherByPositions[x_List, plist_List] := GatherBy[x, #[[plist]] &]; For example: In[1]:= gatherByPositions[ejemplo1,{4,5}] Out[1]= {{{1,0,2,2,0}},{{0,1,1,1,2},{2,1,1,1,2}},{{2,0,0,1,1},{2,2,0,1,1}},{{1,1,0,2,2}},{{1,0,2,0,1},{0,1,1,0,1}}} In[2]:= gatherByPositions[ejemplo1,{1,2}] Out[2]= {{{1,0,2,2,0},{1,0,2,0,1}},{{0,1,1,1,2},{0,1,1,0,1}},{{2,0,0,1,1}},{{1,1,0,2,2}},{{2,2,0,1,1}},{{2,1,1,1,2}}} Regards, Leonid On Tue, Nov 24, 2009 at 1:48 PM, Francisco Gutierrez <fgutiers2002 at yahoo.com > wrote: > Dear List: > I have the following list: > > ejemplo1={{1,0,2,2,0},{0,1,1,1,2},{2,0,0,1,1},{1,1,0,2,2},{1,0,2,0,1},{2,2,0,1,1},{2,1,1,1,2},{0,1,1,0,1}}; > I want to group it, so that the sublists of ejemplo1 that have identical > values at positions 4 and 5 are gathered together. So I did the following > code: > Split[ Sort[ejemplo1,#1[[4]]>=#2[[4]] && #1[[5]]>=#2[[5]] > &],Take[#1,{4,5}]==Take[#2,{4,5}]&] > > Works! The output in effect is: > > {{{1,1,0,2,2}},{{0,1,1,1,2},{2,1,1,1,2}},{{2,0,0,1,1},{2,2,0,1,1}},{{1,0,2,0,1},{0,1,1,0,1}},{{1,0,2,2,0}}}, > precisely what I wanted. > > Now, how can I create a function for the general case (instead of fixed > positions 4 and 5, an arbitrary number of positions that act as "gathering > parameter")? > Fg > > --- On Mon, 11/23/09, Petri T=F6tterman <petri.totterman at hanken.fi> wrote: > > > From: Petri T=F6tterman <petri.totterman at hanken.fi> > Subject: [mg105202] [mg105180] ML estimators for Box-Cox Extreme Value > distribution > To: mathgroup at smc.vnet.net > Date: Monday, November 23, 2009, 6:53 AM > > > Dear all, > > I have a set of data, and I want to fit a distribution on this data. I > am particularily interested in the Box-Cox General Extreme Value > distribution, for which I have the CDF and PDF: > --- > BoxCoxGEVDistribution /: > > CDF[BoxCoxGEVDistribution[\[Mu]_, \[Sigma]_, \[Xi]_, \[Phi]_], x_]:= > 1 + (((Exp[-(1 + \[Xi] ( (x - \ > \[Mu])/\[Sigma]))^(-1/\[Xi])])^\[Phi]) - 1)/\[Phi]; > > BoxCoxGEVDistribution /: > > PDF[BoxCoxGEVDistribution[\[Mu]_, \[Sigma]_, \[Xi]_, \[Phi]_], x_]= > D[CDF[BoxCoxGEVDistribution[\[Mu], \[Sigma], \[Xi], \[Phi]], x], > x]; > --- > > I do also have a Log likelihood function from (Bali, 2007): > > --- > LLdBoxCoxGEV[\[Mu]_, \[Sigma]_, \[Xi]_, \[Phi]_, M_] := > Module[{k = Length[M]}, -k Log[\[Sigma]] - > k ((1 + \[Xi])/\[Xi]) Sum[ > Log[1 + \[Xi] ((M[[i]] - \[Mu])/\[Sigma])], {i, 1, k}] - > k \[Phi] Sum[(1 + \[Xi] ((M[[i]] - \[Mu])/\[Sigma]))^(-( > 1/\[Xi])), {i, 1, k}] ]; > --- > > Obviously, \[Mu]_, \[Sigma]_, \[Xi]_, \[Phi]_ are parameters which I > need to estimate, and M is a list of values from the dataset, > exceeding a predefined limit. > > I would be grateful for advice, how should I continue to find the > Maximum Likelihood estimators for this distribution, using Mathematica? > > Best regards, > /petri > >
- References:
- simple question
- From: Francisco Gutierrez <fgutiers2002@yahoo.com>
- simple question