达美航空

实验三

佐手、 提交于 2019-12-04 14:05:45
// 一元二次方程求解 // 重复执行, 直到按Ctrl+D或Ctrl+E结束 // #include <math.h> #include <stdio.h> #include <stdlib.h> int main() { float a, b, c, x1, x2; float delta, real, imag; printf("Enter a, b, c: "); while(scanf("%f%f%f", &a, &b, &c)) { if(a == 0) printf("not quadratic equation.\n"); else { delta = b*b - 4*a*c; if(delta >= 0) { x1 = (-b + sqrt(delta)) / (2*a); x2 = (-b - sqrt(delta)) / (2*a); printf("x1 = %f, x2 = %f\n", x1, x2); } else { real = -b/(2*a); imag = sqrt(-delta) / (2*a); printf("x1 = %f + %fi, x2 = %f - %fi\n", real, imag, real, imag); } } printf("Enter a, b, c:\n"); } system("pause"); return

实验三

扶醉桌前 提交于 2019-12-04 08:49:16
part1:验证性内容 一元二次方程求解 // 一元二次方程求解 // 重复执行, 直到按Ctrl+D或Ctrl+E结束 // #include <math.h> #include <stdio.h> #include <stdlib.h> int main() { float a, b, c, x1, x2; float delta, real, imag; printf("Enter a, b, c: "); while(scanf("%f%f%f", &a, &b, &c)) { if(a == 0) printf("not quadratic equation.\n"); else { delta = b*b - 4*a*c; if(delta >= 0) { x1 = (-b + sqrt(delta)) / (2*a); x2 = (-b - sqrt(delta)) / (2*a); printf("x1 = %f, x2 = %f\n", x1, x2); } else { real = -b/(2*a); imag = sqrt(-delta) / (2*a); printf("x1 = %f + %fi, x2 = %f - %fi\n", real, imag, real, imag); } } printf("Enter a, b, c:\n"); }

datetime模块

你离开我真会死。 提交于 2019-12-04 04:34:02
1、当前日期、当前时间 import datetime a = datetime.date.today() b = datetime.datetime.today() 2、日期与字符串格式转换 #日期转换成字符串 to_str = a.strftime("%Y-%m-%d %H:%M:%S") #字符串转换日期 detester = '2017-01-01' date = datetime.datetime.strptime(detester,'%Y-%m-%d') 3、两个日期加减 d1 = datetime.datetime.strptime('2019-03-05 17:42:00', '%Y-%m-%d %H:%M:%S') d2 = datetime.datetime.strptime('2019-03-02 17:41:00', '%Y-%m-%d %H:%M:%S') delta = d1 - d2 delta 4、n天后的日期 now = datetime.datetime.now() delta = datetime.timedelta(days=3) n_days = now + delta n_days.strftime('%Y-%m-%d %H:%M:%S') 来源: https://www.cnblogs.com/yukizzc/p/11831416

均值各态历经的例题

北战南征 提交于 2019-12-03 23:23:42
均值各态历经的例题 例1 例1 设 X t = A c o s w t + B s i n w t , − ∞ < t < + ∞ A , B X_t=Acoswt+Bsinwt,-\infty<t<+\infty A,B X t ​ = A c o s w t + B s i n w t , − ∞ < t < + ∞ A , B 独立且都服从 N ( 0 , δ 2 ) N(0,\delta^2) N ( 0 , δ 2 ) 的随机变量, w w w 为常数,讨论 X = { X t , − ∞ < t < + ∞ } X=\{X_t,-\infty<t<+\infty\} X = { X t ​ , − ∞ < t < + ∞ } 的各态历经性 解:显然, m x ( t ) = 0 m_x(t)=0 m x ​ ( t ) = 0 R X ( s , t ) = E [ ( A c o s w s + B s i n w s ) ( A c o s w t + B s i n w t ) ] R_X(s,t)=E[(Acosws+Bsinws)(Acoswt+Bsinwt)] R X ​ ( s , t ) = E [ ( A c o s w s + B s i n w s ) ( A c o s w t + B s i n w t ) ] = E [ A 2 c o s

信号与系统_前三章_妙题汇总

為{幸葍}努か 提交于 2019-12-03 21:27:05
信号期中纠错 线性时不变离散系统稳定,其单位样值响应 \(h(n)\) 必须满足 \[ \sum_{n=-\infty}^{\infty}|h(n)|<\infty \] 线性时不变离散系统因果,其单位样值响应 \(h(n)\) 必须满足 \[ h(n)=h(n)u(n) \] \[ \begin{align}f(t)*\delta(t-t_0)&=f(t_0)\notag\\f(t)\cdot\delta(t-t_0)&=f(t_0)\delta(t-t_0)\notag\end{align} \] \(f(t)\) 的带宽为 \(W\) ,则 \(f(t)\sin(\omega_0t+\frac{\pi}{4})\) 的带宽为 \[ 2W \] 序列 \(\delta(\frac{n}{2})\) 可用 \(\delta(n)\) 表示为 \[ \delta(n) \] 某线性时不变离散系统的单位样值响应为 \(h(n)\) ,当激励为 \(u(n)-u(n-2)\) 时,系统的输出为 \[ h(n)+h(n-1) \] 求下列序列的最小正周期 \(\cos(\frac{\pi}{3}n)+\cos(\frac{5\pi}{3}n)\) \[ \begin{align} T_1&=\frac{2\pi}{\frac{\pi}{3}}=6\notag\\ T_2&=\frac{2

[Leetcode]636. Exclusive Time of Functions

半腔热情 提交于 2019-12-03 20:18:33
链接: LeetCode636 给一个 \(n\) 个函数运行记录的log数组,表示非抢占式CPU调用函数的情况,即同时只能运行一个函数。格式为 \(id:start\ or\ end:time\) ,求每个函数占用cpu的总时间。 Input: n = \(2\) logs = \(["0:start:0","1:start:2","1:end:5","0:end:6"]\) Output: \([3, 4]\) 相关标签: 栈 首先要弄明白一点:当遍历到logs中的某个字符串时,无论它是begin还是end,当前位于栈顶的元素都会占用 “当前字符串的timePoint-之前字符串的timePoint”(或+1) 时间。 因为如果当前遍历到的字符串是start,那么栈顶元素就是之前start了还没结束的function,在 当前时间点 和 上一个时间点 之间的这段时间,是被栈顶元素占用的,占用了 “当前字符串的timePoint-之前字符串的timePoint” 时间。 算法的关键在于:拿到上一个log的 start/stop time 设为prev,再拿到当前 log 的 start/stop time ,计算出两个time之间的时间差。这也可以同比为,每次计算一个log的占用时间delta,将栈里面的数都减去delta。 python: class Solution: def

导数和微分

江枫思渺然 提交于 2019-12-03 17:33:00
导数和微分的区别 导数是函数在某一点处的斜率,是Δy和Δx的比值;而微分是指函数在某一点处的切线在横坐标取得增量Δx以后,纵坐标取得的增量,一般表示为dy。 来源: https://www.cnblogs.com/yibeimingyue/p/11805067.html

Estimating linear regression with Gradient Descent (Steepest Descent)

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Example data X<-matrix(c(rep(1,97),runif(97)) , nrow=97, ncol=2) y<-matrix(runif(97), nrow= 97 , ncol =1) I have succeed in creating the cost function COST<-function(theta,X,y){ ### Calculate half MSE sum((X %*% theta - y)^2)/(2*length(y)) } How ever when I run this function , it seem to fail to converge over 100 iterations. theta <- matrix (0, nrow=2,ncol=1) num.iters <- 1500 delta = 0 GD<-function(X,y,theta,alpha,num.iters){ for (i in num.iters){ while (max(abs(delta)) < tolerance){ error <- X %*% theta - y delta <- (t(X) %*% error) /

Empirical cdf in python similiar to matlab&#039;s one

匿名 (未验证) 提交于 2019-12-03 10:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some code in matlab, that I would like to rewrite into python. It's simple program, that computes some distribution and plot it in double-log scale. The problem I occured is with computing cdf. Here is matlab code: for D = 1:10 delta = D / 10; for k = 1:n N_delta = poissrnd(delta^-alpha,1); Y_k_delta = ( (1 - randn(N_delta)) / (delta.^alpha) ).^(-1/alpha); Y_k_delta = Y_k_delta(Y_k_delta > delta); X(k) = sum(Y_k_delta); %disp(X(k)) end [f,x] = ecdf(X); plot(log(x), log(1-f)) hold on end In matlab one I can simply use: [f,x] = ecdf(X);

glmmLasso try-error for all lambda

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been trying to use glmmLasso to do variable selection for a mixed-model but I can't seem to get the model to work. I've setup my model similarily to the demo found here . I'm using the simple method of using BIC to choose lambda. This is the code I've been running. library(glmmLasso) lambda <- seq(500,0,by=-5) family = binomial(link = logit) library(MASS);library(nlme) PQL<-glmmPQL(y~1,random = ~1|ID,family=family,data=train) Delta.start<-c(as.numeric(PQL$coef$fixed),rep(0,64),as.numeric(t(PQL$coef$random$ID))) Q.start<-as.numeric