R2, p2 = fit.loglikelihood_ratio('truncated_power_law', 'lognormal') R3, p3 = fit.loglikelihood_ratio('power_law', 'lognormal') if p1>.05: dist.powerlaw = 0 else: dist.powerlaw = 1 if p2<.05: dist.powerlaw = 2 if p3<.05: dist.powerlaw = 3 dist.mean = data.mean() dist.median = median(data) dist.skew = skew(data) session.add(dist) if f=='All': continue for fn2 in range(fn+1, n_factors): f2 = factors[fn2] data_other = session.query(db.LangleyParticipant).filter(getattr(db.LangleyParticipant, i)==f2).values(getattr(db.LangleyParticipant, d)) data_other = [q for q in data_other if q[0]!=None] data_other = asarray([q for q in data_other if ~isnan(q)]).flatten() if len(data_other)>2: H, p_krusk = kruskal(data, data_other) D, p_KS = ks_2samp(data/median(data), data_other/median(data_other)) fs.append(f) f2s.append(f2) Ds.append(D)
mains = 50 dirList=os.listdir(data_path) for fname in dirList: file = data_path+fname f = h5py.File(file) group_name = f.attrs['group_name'] number_in_group = f.attrs['number_in_group'] species = f.attrs['species'] location = f.attrs['location'] subject = session.query(db.Subject).\ filter_by(species=species, group_name=group_name, number_in_group=number_in_group).first() if not subject: subject = db.Subject(species=species, group_name=group_name, number_in_group=number_in_group) session.add(subject) session.commit() print file conditions = [(v,t,e,s,rem) for v in visits for t in tasks for e in eyes for s in sensors for rem in remicas] for visit, task_type, eye, sensor_type, rem in conditions: base = str(visit)+'/'+task_type+'/'+eye+'/'+sensor_type+'/'+rem base_filtered = base+'/filter_'+filter_type+'_'+str(taps)+'_'+window #If this particular set of conditions doesn't exist for this subject, just continue to the next set of conditions try: f[base_filtered] except KeyError: continue print base
p.Has_Children = (G.out_degree()[n_id]>0) p.Relationship_with_Parent = n['source_from'] p.Heard_Through_Medium = n['source_through'] p.Join_Time = n['join_time'] p.Latitude = n['lat'] p.Longitude = n['lng'] p.Has_Parent = False if 'parent_id' in n.keys(): p.Has_Parent = True p.parent_id = n['parent_id'] p.Parent_Child_Registration_Interval = n['wait_time'] p.Parent_Child_Registration_Interval_Corrected = max(n['wait_time'], 0) p.Distance_from_Parent = n['distance'] p.Parent_Age = n['parent_age'] p.Parent_City = n['parent_city'] p.Parent_Country = n['parent_country'] p.Parent_Gender = n['parent_gender'] p.Parent_Number_of_Children = n['parent_sigma'] p.Parent_Relationship_with_Grandparent = n['parent_source_from'] p.Parent_Heard_Through_Medium = n['parent_source_through'] p.Grandparent_Parent_Registration_Interval = n['parent_wait_time'] p.Same_Age_as_Parent = n['same_age'] p.Same_City_as_Parent = n['same_city'] p.Same_Country_as_Parent = n['same_country'] p.Same_Gender_as_Parent = n['same_gender'] p.Same_Relationship_to_Parent_as_They_Had_to_Their_Parent = n['same_source_from'] p.Heard_Through_Same_Medium_as_Parent = n['same_source_through'] p.Parent_Join_Time = n['parent_join_time'] session.add(p) session.commit()