Re: I have problem with these functions!!
- To: mathgroup at smc.vnet.net
- Subject: [mg16242] Re: [mg16154] I have problem with these functions!!
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Fri, 5 Mar 1999 00:41:08 -0500
- Sender: owner-wri-mathgroup at wolfram.com
mikael hellstrom wrote:
> Hello! Mabe you can help me??
>
> 1)
> I'm going to make a function that take a list, the number that
> are going in
> the list, and the spot
> there the nummer are going to place. The function are leaving the new list
> as a result.
> switchelement[list_,number_,place_]
>
>
> 2)
> This function should return the "most common" numbers in the list.(if two
> numbers have same frecvence,the function should take the lower number.)
> like this: mostcommon[list_]
>
>
> 3)
> biggerthan[list_,number_]
> This funktion return a list with values bigger or equal with "number"
Mikael,
I'm afraid your questions are not as clear as it would be desired, but I
think I can understand the third one without any difficulty:
In[1]:= biggerthan[lista1_,num_]:=Select[lista1,#>=num&]
The second one -- if I understand it correctly -- could be handled with the
package Statistics`DataManipulation`, using the function Frequencies:
In[2]:= <<Statistics`DataManipulation`
In[3]:= mostcommon[lista2_]:= Module[
{frecs = Reverse[Sort[Frequencies[lista2]]]},
mostFreq = frecs[[1,1]];
Last[Select[frecs,#[[1]]==mostFreq&]][[2]]]
Example:
In[4]:= lista2={1,3,3,5,6,7,7,7,3,9,5};
In[5]:=
mostcommon[lista2]
Out[5]=
3
Perhaps if you could rephrase the first problem it would be easier to
understand.
Good luck,
Tomas Garza
Mexico City