mean

Cannot Access Mean Values

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have computed mean and standart deviation values of a region in the image. The code: Mat img = imread ( "a.jpg" ); Mat hsv1 ; Mat mean , stdev ; cvtColor ( img , hsv1 , CV_BGR2HSV ); cv :: meanStdDev ( hsv1 , mean , stdev , superpixel_mask ); cout << "mean: " << mean << endl << "standard deviation: " << stdev << endl ; The output is: mean : [ 150.8399251737039 ; 103.6980224478888 ; 226.161411010155 ] standard deviation : [ 23.98981564590477 ; 46.73491195049309 ; 34.41166394765997 ] I would like to access those numbers. I wrote

What does it mean by java.lang.ArrayIndexOutOfBoundsException : 0

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: my compiler keep pointing at this line: arr[i] = new specialDelivery(name,name2,weight,special); and this : arr[i] = new specialDelivery(name,name2,weight,special); the error is stated in the title public static void main ( String args [] ) { int size = 0,distance; double weight = 0.0; String strinput,method,name,name2,special; Parcel arr[] = new Parcel[size]; strinput = JOptionPane.showInputDialog ( " Enter number of parcel : " ); size = Integer.parseInt(strinput); for (int i = 0; i<size; i++) { int j = 0, k = 0; method = JOptionPane

Naming returned columns in Pandas aggregate function?

匿名 (未验证) 提交于 2019-12-03 02:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having trouble with Pandas' groupby functionality. I've read the documentation , but I can't see to figure out how to apply aggregate functions to multiple columns and have custom names for those columns. This comes very close, but the data structure returned has nested column headings: data.groupby("Country").agg( {"column1": {"foo": sum()}, "column2": {"mean": np.mean, "std": np.std}}) (ie. I want to take the mean and std of column2, but return those columns as "mean" and "std") What am I missing? 回答1: This will drop the outermost

MATLAB generate random numbers

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi I am trying to generate random numbers in MATLAB with a random MEAN value. For example, if I use e = mean(rand(1000,1)) the answer for e will always be close to 0.5 . What I want is for the value of e (mean) to be random, so that e can be 0.1, 0.2, 0.3, etc... Is it correct for me to use e = mean( unifrnd(0,1,[1000,1]) ) ? Thanks 回答1: Perhaps you want to generate normally distributed random numbers X~N(0,1) with randn . Then you can change the mean and standard deviation to be random. As an example: N = 1000; mu = rand*10 - 5; %# mean in

What does %w(array) mean?

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm looking at the documentation for FileUtils. I'm confused by the following line: FileUtils . cp % w ( cgi . rb complex . rb date . rb ), '/usr/lib/ruby/1.6' What does the %w mean? Can you point me to the documentation? 回答1: %w(foo bar) is a shortcut for ["foo", "bar"] . Meaning it's a notation to write an array of strings separated by spaces instead of commas and without quotes around them. You can find a list of ways of writing literals in zenspider's quickref . 回答2: I think of %w() as a "word array" - the elements are

What does -1 mean in numpy reshape?

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: A numpy matrix can be reshaped into a vector using reshape function with parameter -1. But I don't know what -1 means here. For example: a = numpy . matrix ([[ 1 , 2 , 3 , 4 ], [ 5 , 6 , 7 , 8 ]]) b = numpy . reshape ( a , - 1 ) The result of b is: matrix([[1, 2, 3, 4, 5, 6, 7, 8]]) Does anyone know what -1 means here? And it seems python assign -1 several meanings, such as: array[-1] means the last element. Can you give an explanation? 回答1: The criterion to satisfy for providing the new shape is that 'The new shape should be

Looping through files in R

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using R to calculate the mean values of a column in a file like so: R file1 = read.table("x01") mean(file1$V4) However I have no experience building loops involving R, only with bash. How would I convert this into a loop that did this for every file in a folder and saved the output into one file with the file name and mean value as the 2 columns for each row? eg: x01(or file1 if that is simpler) 23.4 x02 25.4 x03 10.4 etc (Don't mind if the solution is bash and R or exclusively R) Many thanks for your help! Current error from one of the

Calculate mean of each column ignoring missing data with awk

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a large tab-separated data table with thousands of rows and dozens of columns and it has missing data marked as "na". For example, na 0.93 na 0 na 0.51 1 1 na 1 na 1 1 1 na 0.97 na 1 0.92 1 na 1 0.01 0.34 I would like to calculate the mean of each column, but making sure that the missing data are ignored in the calculation. For example, the mean of column 1 should be 0.97. I believe I could use awk but I am not sure how to construct the command to do this for all columns and account for missing data. All I know how to do is to

What does &lt; &gt; mean / represent in a class interface?

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am sure I have read this somewhere, Can anyone tell me what the < > represent in the following interface? @interface GameFinder : NSObject <NSNetServiceBrowserDelegate> @end is NSObject adopting <NSNetServiceBrowserDelegate> ? EDIT One thing that is confusing me ... in the example I have.The interface shows NSNetServiceBrowserDelegate @interface ITunesFinder : NSObject <NSNetServiceBrowserDelegate> @end but the implementation shows netServiceBrowser , are these one in the same? @implementation ITunesFinder -(void) netServiceBrowser:

What does &#039;u&#039; mean in a list?

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is the first time I've came across this. Just printed a list and each element seems to have a u in front of it i.e. [u'hello', u'hi', u'hey'] What does it mean and why would a list have this in front of each element? As I don't know how common this is, if you'd like to see how I came across it, I'll happily edit the post. 回答1: it's an indication of unicode string. similar to r'' for raw string. >>> type(u'abc') >>> r'ab\c' 'ab\\c' 回答2: Unicode. 回答3: The u just means that the following string is a unicode string (as opposed to a plain