达美航空

Matplotlib: Multiple legends for contour plot for multiple contour variables

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to make multiple contours plots of several variables on the same page. I can do this with MATLAB (see below for MATLAB code). I cannot get matplotlib to show multiple legends. Any help would be much appreciated. Python code: import numpy as np from matplotlib import cm as cm from matplotlib import pyplot as plt delta = 0.25 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = X*np.exp(-X**2-Y**2) Z2 = Y*np.exp(-X**2-Y**2) plt.figure() CS = plt.contour(X, Y, Z1, colors='k') plt.clabel(CS, inline

Limit 'mousewheel' delta to fire once per scroll

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using the following code below, to scroll two divs in different directions () but I'm curious to know if you can limit the scroll so it only fires once per scroll (rather than it continually scrolling and sending my functions into an endless loop. $('.page-left, .page-right').bind('mousewheel', function(event, delta) { var windowHeight = $(window).height(); if (delta < 0) { prevProject(); } if (delta > 0) { nextProject(); } }); You can see where I'm up up to here: http://dev.rdck.co/lyonandlyon/ Thanks in advance, R Animation functions

cf1119d Frets On Fire 前缀和+二分

懵懂的女人 提交于 2019-12-03 08:20:40
题目: http://codeforces.com/problemset/problem/1119/D 题意:给一个数n,给出n个数组的第一个数(a[0]=m,a[1]=m+1,a[2]=m+2,...,a[n]=m+n),给定q个查询,每个查询问所有数组的[l,r]区间内总共出现了多少个不同的数。 思路:答案与给出查询的区间无关,只与区间长度有关。 两数组不重复的数与数组第一个数的差、区间长度有关。两数组内不重复的数为min(两数组a[0]之差,区间长度)。 因此对数组第一个数进行sort,之和求出数组第一位之差delta[],再按照升序排序,小于区间长度的都取delta[],大于区间长度的都取len。 然后对delta求一下前缀和sum,查找的时候对delta进行二分。 #include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; long long s[maxn]={0},delta[maxn]={0},sum[maxn]={0}; int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++)scanf("%lld",&s[i]); sort(s,s+n); for(int i=0;i<n-1;i++)delta[i]=s[i+1]-s[i];

linux 系统监控、诊断工具之 IO wait

点点圈 提交于 2019-12-03 07:27:37
1、问题: 最近在做日志的实时同步,上线之前是做过单份线上日志压力测试的,消息队列和客户端、本机都没问题,但是没想到上了第二份日志之后,问题来了: 集群中的某台机器 top 看到负载巨高,集群中的机器硬件配置一样,部署的软件都一样,却单单这一台负载有问题,初步猜测可能硬件有问题了。 同时,我们还需要把负载有异常的罪魁祸首揪出来,到时候从软件、硬件层面分别寻找解决方案。 2、排查: 从 top 中可以看到 load average 偏高,%wa 很高,%us 偏低: 从上图我们大致可以推断 IO 遇到了瓶颈,下面我们可以再用相关的 IO 诊断工具,具体的验证排查下。 PS:如果你对 top 的用法不了解,请参考我去年写的一篇博文: linux 系统监控、诊断工具之 top 详解 常用组合方式有如下几种: 用vmstat、sar、iostat检测是否是CPU瓶颈 用free、vmstat检测是否是内存瓶颈 用iostat、dmesg 检测是否是磁盘I/O瓶颈 用netstat检测是否是网络带宽瓶颈 2.1 vmstat vmstat命令的含义为显示虚拟内存状态(“Viryual Memor Statics”),但是它可以报告关于进程、内存、I/O等系统整体运行状态。 它的相关字段说明如下: Procs(进程) • r: 运行队列中进程数量,这个值也可以判断是否需要增加CPU。

Jquery, unbinding mousewheel event, then rebinding it after actions are completed?

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been struggling with this for a little while now.. I am using this code to monitor the mousewheel so it can be used for scrolling with a slider that I have.. however, it has an issue where the actions queue up so if you scroll with the mousewheel fast (like anyone would do normally) they build up and it causes buggy behavior.. I know about handling this sort of issue with animation, but not with a mousewheel monitor.. I want to do something like unbind the mousewheel at the start of the action (in this case, to scroll the scrollbar

Plotly: add_trace in a loop

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to add_trace ad each loop, but I get only one plot with multiplies lines on over each other. mean <- -0.0007200342 sd <- 0.3403711 N=10 T=1 Delta = T/N W = c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd))) t <- seq(0,T, length=N+1) p<-plot_ly(y=W, x=t) for(i in 1:5){ W <- c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd))) p<-add_trace(p, y=W) } print(p) 回答1: The plot_ly and add_trace functions have an evaluation = FALSE option that you can change to TRUE , which should fix the scope issues. 回答2: Use evaluate = TRUE in add

Convert datetime into time ago [closed]

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to convert DateTime into the year, month, days, hours, minutes, seconds ago like as yahoo question asked 5week ago, or 1 year ago or 1 month ago, my date is saved in the database like this: 2011-11-30 05:25:50 . Now I want to show like year, month, days, hours, minutes and seconds in PHP like: how much year, how many months , days, hours, minutes, seconds ago, but need only one time unit show like it will be year or days or hours or minutes or seconds. I have searched about this but not understand how I can do this, I know there are

How to implement the Softmax derivative independently from any loss function?

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: For a neural networks library I implemented some activation functions and loss functions and their derivatives. They can be combined arbitrarily and the derivative at the output layers just becomes the product of the loss derivative and the activation derivative. However, I failed to implement the derivative of the Softmax activation function independently from any loss function. Due to the normalization i.e. the denominator in the equation, changing a single input activation changes all output activations and not just one. Here is my

How to make timer for a game loop?

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to time fps count, and set it's limit to 60 and however i've been looking throught some code via google, I completly don't get it. 回答1: You shouldn't try to limit the fps. The only reason to do so is if you are not using delta time and you expect each frame to be the same length. Even the simplest game cannot guarantee that. You can however take your delta time and slice it into fixed sizes and then hold onto the remainder. Here's some code I wrote recently. It's not thoroughly tested. void GameLoop::Run() { m_Timer.Reset(); while(!m

Disable carousel overscroll/overdrag in Sencha Touch

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: At the end or beginning of a Sencha Touch 2 carousel, a user can drag the item past where it should be able to go and display the white background (screenshot here: http://i.imgur.com/MkX0sam.png ). I'm trying to disable this functionality, so a user can't drag past the end/beginning of a carousel. I've attempted to do this with the various scrollable configurations, including the setup that is typically suggested for dealing with overscrolling scrollable : { direction: 'horizontal', directionLock: true, momentumEasing: { momentum: {