Re: pattern matching
- To: mathgroup at smc.vnet.net
- Subject: [mg128312] Re: pattern matching
- From: Dana DeLouis <dana01 at me.com>
- Date: Sat, 6 Oct 2012 01:50:32 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
> Count[Table[RandomInteger[], {n}], 1]/n, {n, 100, 1000, 10}], x_ < .5]
Hi. Here's one way.
t=Table[Count[Table[RandomInteger[],{n}],1]/n,{n,10,15,1}]
{7/10,4/11,1/2,7/13,3/7,8/15}
Count[t, n_/; n<.5]
2
As a suggestion, note the following with 0 / 1's
Mean[{1,1,0,0,0}]
2/5
Perhaps:
t=Table[Mean[RandomInteger[{0,1},n]],{n,10,15,1}]
{1/2,2/11,2/3,5/13,4/7,2/15}
Count[t, n_/;n<.5]
3
= = = = = = = = = =
HTH :>)
Dana DeLouis
Mac & Mathematica 8
= = = = = = = = = =
On Friday, October 5, 2012 2:43:42 AM UTC-4, Daniel S wrote:
> Consider the following code:
>
>
>
> Count[Table[
>
> Count[Table[RandomInteger[], {n}], 1]/n, {n, 100, 1000, 10}],
>
> x_ < .5]
>
>
>
> I want to count the number of times there are occurrences less than .5 but some how I am not specifying the right pattern. Any suggestions on getting right?