average

Counting average on huge matrix with conditional

对着背影说爱祢 提交于 2019-12-24 08:06:17
问题 The following MATLAB code runs forever on 10^5 square matrix A. However, it runs for a few seconds on 10^3 square matrix. Is there any way to speed it up? function [meanNV]=calcMeanNV_k(A,V,d) %A: input matrix (n x n) %V: eigenvectors of k-th largest eigenvalues (n x 1) %d: degrees of each node (n x 1) %meanNV: mean of neighbors vectors (n x 1) m=size(A,2); meanNV=zeros(113336); for i=1:m sumNode = 0; for j=1:m if A(i,j)==1 sumNode=sumNode+V(j); end end [meanNV(i)]=sumNode/d(i); end 回答1:

MDX: avg advanced use

杀马特。学长 韩版系。学妹 提交于 2019-12-24 07:14:09
问题 I am reaching the limit of my basic MDX knowledge on a problem, if anyone has an idea, every help will be welcome Situation This is the hierarchy I'd like to deal with. In my fact_table I have a [Measures].[Sales] measure. [All Management].[TemplateMgt].[CityMgt].[DistricMgt].[StoreMgt] [All Management].[TMP-00.002].[London].[DistricMgt].[Shoe001] [All Management].[TMP-00.002].[London].[DistricMgt].[Hat001] [All Management].[TMP-00.002].[London].[DistricMgt].[Electronic001] [All Management].

sporfire: calculate the avg per 15 minutes

无人久伴 提交于 2019-12-24 06:45:25
问题 I am a beginner for Spotfire. I have a problem about the average calculation per each 15 mins by calculated column. A sample table could be like this: id time-stamp value 1 7/1/2016 12:01:01 AM 1.1 2 7/1/2016 12:05:03 AM 0.9 3 7/1/2016 12:08:04 AM 1.2 4 7/1/2016 12:09:06 AM 0.8 5 7/1/2016 12:12:09 AM 0.4 6 7/1/2016 12:14:10 AM 0.6 7 7/1/2016 12:15:12 AM 1.3 8 7/1/2016 12:18:04 AM 1.4 9 7/1/2016 12:21:06 AM 0.7 10 7/1/2016 12:24:09 AM 1.7 11 7/1/2016 12:31:10 AM 0.5 12 7/1/2016 12:39:12 AM 1.3

Awk array assistance needed - averaging

喜夏-厌秋 提交于 2019-12-24 00:36:56
问题 Here is an example of the type of data that I am trying to manipulate: 1213954013615]: 992 1213954013615]: 993 1213954013615]: 994 1213954013615]: 995 1213954013615]: 995 1213954013615]: 996 1213954013615]: 996 1213954013615]: 996 1213954013615]: 998 1213954247424]: 100 1213954247424]: 1002 1213954247424]: 1007 1213954303390]: 111 1213954303390]: 1110 1213954303390]: 1111 1213954303390]: 1112 1213954303390]: 1114 1213954303390]: 112 1213954303390]: 112 1213954303390]: 112 1213954303390]: 112

SQL - calculate forecast average

给你一囗甜甜゛ 提交于 2019-12-23 23:26:23
问题 I'm trying to calculate a forecast of sales based on the 3 previous months which either can be actuals or forecast. company_id Year Month Actuals Forecast 123456 2014 1 10 123456 2014 2 15 123456 2014 3 17 123456 2014 4 14.00 123456 2014 5 15.33 123456 2014 6 15.44 123456 2014 7 14.93 Month 4 = (10+15+17)/3 Month 5 = (15+17+14)/3 Month 6 = (17+14+15.33)/3 Month 7 = (14+15.33+15.44)/3 Let's say I want to calculate the forecast for the next 18 months for each company. I'm looking at the data

How to get average values for time intervals in Postgres

若如初见. 提交于 2019-12-23 21:45:56
问题 I'm using PostgreSQL 9.6. I have a table like this: mac sn loc time date vin1 vin2 vin3 1a34 4as11111111 aaaa 7:06:18 1/1/2018 447.42 472.32 682.59 1a34 4as11111111 aaaa 7:06:43 1/1/2018 455.97 476.25 682.59 1a34 4as11111111 aaaa 7:07:35 1/1/2018 470.88 484.2 682.5 I need to calculate the average of the vin1 , vin2 , vin3 within time intervals of 300 sec (5 min). For example, starting from the first time (7:06:18 - 7:11:18), for the dates in range. I can select the data I need with this query

Getting average value from matlab plot?

会有一股神秘感。 提交于 2019-12-23 20:17:26
问题 I have a simple plot which feature a lot of data points, when i have have graph. Is there a way that i can simple click on all these point and allow matlab to give me a average value of them? Thank you 回答1: The easiest way if you don't want to do it programmatically would be to use the data brush and statistics. I used plot(rand(1,200)) to generate my data. After it has plotted go to Tools > Data Statistics. Y-mean is what you are looking for. alt text http://www.thinkextensively.com/misc

Average by rows with sqlite

寵の児 提交于 2019-12-23 19:02:43
问题 I'm working with a sqlite database. The tables are: ID_TABLE POINTS_A_TABLE POINTS_B_TABLE id number id_a points_a id_a points_a -------------- ---------------- ---------------- smith 1 smith 11 ... gordon 22 gordon 11 butch 3 butch 11 sparrow 25 sparrow white 76 white 46 and so on. After these commands select id, points_a_table.points_a, points_b_table.points_a, points_c_table.points_a, points_d_table.points_a from id_table left join points_a_table on points_a_table.id_a = id_table.id left

MySQL: how to get average of positive values only?

可紊 提交于 2019-12-23 18:28:47
问题 Suppose I have INT column, and I am using -1 to signify that no data was available at the time of the INSERT. I'd like to get an AVG of all values of this column that are 0 or larger. Is this possible? Thanks. I forgot to mention that I'm doing this alongside other AVG's, so it's select avg(a), avg(b), avg(d) from tab; ... so I can't use b>0... because the others need to use the row data regardless of this one column's data being -1. It occurs to me though that I could augment the AVG result

What would be an efficient way to find the averaged size distribution without having to declare a gigantic 2D array?

隐身守侯 提交于 2019-12-23 14:24:10
问题 Consider a L x L size matrix M, whose entries can be either 0 or 1. Each element is 1 with probability p and 0 with probability 1 - p. I will call the elements labelled 1 as black elements and elements labelled 0 as white elements. I'm trying to write a code which: Generates a random matrix with entries 0's and 1's. I need to input size of matrix L and the probability p. Labels all the black elements belonging to the same cluster with the same number. ( Define a cluster of black element as a