mean

When i am trying to run this code i am getting the following error

£可爱£侵袭症+ 提交于 2019-12-01 01:09:05
I am trying to connect mongodb database by this code but when running this code I get the error(error at the bottom of the code). One of the error was in the 7th line where it was resolved by adding { useNewUrlParser: true } but still it has more errors. I am using MongoDB version 4.0.1 . Do anybody know how to resolve this error. const express = require('express'); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); const app = express(); app.use(express.static('public')); app.set('view engine','ejs'); mongoose.connect('mongod://localhost/students', {

R running average for non-time data

≯℡__Kan透↙ 提交于 2019-12-01 00:37:30
This is the plot I'm having now. It's generated from this code: ggplot(data1, aes(x=POS,y=DIFF,colour=GT)) + geom_point() + facet_grid(~ CHROM,scales="free_x",space="free_x") + theme(strip.text.x = element_text(size=40), strip.background = element_rect(color='lightblue',fill='lightblue'), legend.position="top", legend.title = element_text(size=40,colour="lightblue"), legend.text = element_text(size=40), legend.key.size = unit(2.5, "cm")) + guides(fill = guide_legend(title.position="top", title = "Legend:GT='REF'+'ALT'"), shape = guide_legend(override.aes=list(size=10))) + scale_y_log10(breaks

R running average for non-time data

荒凉一梦 提交于 2019-11-30 19:39:37
问题 This is the plot I'm having now. It's generated from this code: ggplot(data1, aes(x=POS,y=DIFF,colour=GT)) + geom_point() + facet_grid(~ CHROM,scales="free_x",space="free_x") + theme(strip.text.x = element_text(size=40), strip.background = element_rect(color='lightblue',fill='lightblue'), legend.position="top", legend.title = element_text(size=40,colour="lightblue"), legend.text = element_text(size=40), legend.key.size = unit(2.5, "cm")) + guides(fill = guide_legend(title.position="top",

Dealing with NAs when calculating mean (summarize_each) on group_by

只谈情不闲聊 提交于 2019-11-30 19:35:22
I have a data frame md: md <- data.frame(x = c(3,5,4,5,3,5), y = c(5,5,5,4,4,1), z = c(1,3,4,3,5,5), device1 = c("c","a","a","b","c","c"), device2 = c("B","A","A","A","B","B")) md[2,3] <- NA md[4,1] <- NA md I want to calculate means by device1 / device2 combinations using dplyr: library(dplyr) md %>% group_by(device1, device2) %>% summarise_each(funs(mean)) However, I am getting some NAs. I want the NAs to be ignored (na.rm = TRUE) - I tried, but the function doesn't want to accept this argument. Both these lines result in error: md %>% group_by(device1, device2) %>% summarise_each(funs(mean)

harmonic mean in python

巧了我就是萌 提交于 2019-11-30 17:38:11
The Harmonic Mean function in Python ( scipy.stats.hmean ) requires that the input be positive numbers. For example: from scipy import stats print stats.hmean([ -50.2 , 100.5 ]) results in: ValueError: Harmonic mean only defined if all elements greater than zero I don't mathematically see why this should be the case, except for the rare instance where you would end up dividing by zero. Instead of checking for a divide by zero, hmean() then throws an error upon inputing any positive number, whether a harmonic mean can be found or not. Am I missing something here in the maths? Or is this really

使用Python一步步实现PCA算法

拥有回忆 提交于 2019-11-30 16:57:45
使用Python一步步实现PCA算法 标签: PCA Python 本文原地址为: http://sebastianraschka.com/Articles/2014_pca_step_by_step.html Implementing a Principal Component Analysis (PCA) – in Python, step by step Apr 13, 2014 by Sebastian Raschka 此篇为翻译作品,仅作为学习用途。 简介 主成分分析(PCA)的主要目的是通过分析发现数据的模式进行维度的缩减,这个过程的原则是信息损失最小化。 我们希望得到的结果,把初始特征空间映射到一个相对低维度的子空间,同时保证这个低维度空间也能够很好的表达数据的有效信息。在模式分类中,我们希望通过降维操作抽取能够最佳表达数据的特征子集来降低运算时间花费,减少参数估计的误差。 主成分分析(PCA) vs 多元判别式分析(MDA) PCA和MDA都是线性变换的方法,二者关系密切。在PCA中,我们寻找数据集中最大化方差的成分,在MDA中,我们对类间最大散布的方向更感兴趣。 一句话,通过PCA,我们将整个数据集(不带类别标签)映射到一个子空间中,在MDA中,我们致力于找到一个能够最好区分各类的最佳子集。粗略来讲,PCA是通过寻找方差最大的轴(在一类中

How to plot mean and standard error in Boxplot in R

喜夏-厌秋 提交于 2019-11-30 15:38:35
问题 I have two categorical factors ('Habitat' and 'Locality'), and one continuous variable (T). 'Habitat' has two level and 'Locality' has eight levels. I want to change the default whiskers to represent the SE, and the median into the mean for each boxplot. Is there a way to do this and taking both of the categorical factors into account when plotting? Many thanks in advance. This is what I have done with the default setting of boxplot ggplot, showing the first and third quartiles with median

How to plot mean and standard error in Boxplot in R

时间秒杀一切 提交于 2019-11-30 15:29:38
I have two categorical factors ('Habitat' and 'Locality'), and one continuous variable (T). 'Habitat' has two level and 'Locality' has eight levels. I want to change the default whiskers to represent the SE, and the median into the mean for each boxplot. Is there a way to do this and taking both of the categorical factors into account when plotting? Many thanks in advance. This is what I have done with the default setting of boxplot ggplot, showing the first and third quartiles with median intervals. ggplot(data,aes(x=Locality,y=T)) + geom_boxplot(aes(fill=interaction(Habitat,Locality), group

mean.js menu isPublic not working

∥☆過路亽.° 提交于 2019-11-30 14:50:59
In a mean.js app, I wanted to display the menu items in the top navbar while the user is signed in as well as signed out. The menu items are displaying while the user is signed in, however, that is not happening when the user is signed out. The mean.js docs state setting the 'isPublic' property to true will allow for the menu items to be shown on the navbar while user is signed out; but that is not working. Here is the code: Menus.addMenuItem('topbar', 'Talks', 'talks', 'dropdown', '/talks(/create)?', true); Menus.addSubMenuItem('topbar', 'talks', 'List Talks', 'talks'); Menus.addSubMenuItem(

举例说明协方差矩阵的运算

喜你入骨 提交于 2019-11-30 13:14:29
均值,方差,协方差的运算公式 举例说明 代码演示 import numpy as np a = np.mat([[10, 15, 29], [15, 46, 13], [23, 21, 30], [11, 9, 35]]) a_mean = a.mean(axis = 0) # 求每列的均值 a_d_mean = a - a_mean # 去均值的矩阵 cov_x_y = np.dot(a_d_mean[:, 0].T, a_d_mean[:, 1]) / 3 # 26.58333333 cov_x_z = np.dot(a_d_mean[:, 0].T, a_d_mean[:, 2]) / 3 # -6.08333333 cov_y_z = np.dot(a_d_mean[:, 1].T, a_d_mean[:, 2]) / 3 # -152.08333333 a_cov = np.cov(a.T) # np 自带的矩阵计算公式 记住一定要转置 a_cov2 = np.dot(a_d_mean.T, a_d_mean) / (4 - 1) # 协方差矩阵还可以这样计算,先让样本矩阵中心化,即每一维度减去该维度的均值,使每一维度上的均值为0,然后直接用新的到的样本矩阵乘上它的转置,然后除以(N-1)即可 a_cov == a_cov2 # 结果相等 来源: CSDN 作者: