Tuesday, January 27, 2009

27-JAN-2009 Central Square Library

Today
RubyRx from 10000 feet
Where to meet?
Summary Statistics Clas
Active Record Migrations

Next Week is Hackfest

In the Rails world the programmer and the database person are the same.

Future
More work on CPE
Logging
I/O
Test:Unit
RSPEC

Hackfest - Near Park Street-Just bring your computer and go.

10,000 foot view

Part 3:
We've seen this part of the process:
File.open('T14.2-Demo-Template.erb','r') do t
File.open('T14.2-Demo.rhtml','w') do f
f.puts ERB.new(t.readlines.to_s).result (output.new.get_statistics_on_sex_race_age_by_arm.getbinding)
end
end

Part 1:
Get the data for DM for the study.
Calculate statistics on sex race age by arm
Put the output into table 14.2-Demog.erb

Part 2:
Template Generator

So Glenn thought that a natural language process would parse keywords and generate the Ruby code. He got this idea from Cucumber.

YAML_builder was mentioned as a way to create templates.

Glenn got things to run 4 times faster.

Summary Statistics

class SummaryStatistics

def initialize
@arr=[]
@freq=Hash.new(0)
end

def <<
@arr <<
@freq[obj] += 1
end

M
M
F
{'M'=>2, 'F'=>1}

def calc_n
end
def calc_median
end
def calc_mean
end

def calculate stats
@arr.srt!
@arr_no_nils=@arr.delete_if{e e=nil}
end

@n=@arr.size
@mean=calc_mean
@variance=calc_variance
@min=@arr.min
@max=@arr.max

Glenn found a method that calculates mean and variance at the same time on the internet.
We talked about lazy initialization.

Migrations

'up' you are adding something but you could be deleting.

'up' means next version
'down' mean revert

Rails likes tables that end in an s

class CreateDms
def self.up
create table_table :dms do t
t.string :domain
t.string :usubjid
t.text :comment
t.decimal :age

end
def self.down
drop_table :dms
end
end

rake db:migrate

No comments: