math

Pair-Tournament design algorithm

老子叫甜甜 提交于 2021-01-28 17:08:33
问题 I'm trying to build a Javascript function that takes as an input: array of players e.g. ["player1","player2","player3","player4"] (probably only equal number of players) and dynamically creates an array for a tournament design based on the following rules: each player partners no more than once with the same player every player has an equal amount of total matches the outputs would be an array containing arrays of matches with four entries each e.g. [player1, player2, player3, player4] stands

Calculating Powerset in R

偶尔善良 提交于 2021-01-28 15:19:41
问题 I have to sets A={1,2,3} and B={a,b,c,d,e} . I want the set of subsets of elements from both A and B that contain at least one element of A and one element of B. As clearified here: Cartesian product with all elements, I need to use the following formula: P(A ∪ B)∖(P(A) ∪ P(B)) In R , I tried the following query: require(HapEstXXR) A <- c(1,2,3) B <- c("A", "B", "C", "D", "E") setdiff(powerset(union(A,B)), union(powerset(A),powerset(B))) As as result I got 221 elements. As far as I know,

Calculating Powerset in R

泄露秘密 提交于 2021-01-28 15:17:41
问题 I have to sets A={1,2,3} and B={a,b,c,d,e} . I want the set of subsets of elements from both A and B that contain at least one element of A and one element of B. As clearified here: Cartesian product with all elements, I need to use the following formula: P(A ∪ B)∖(P(A) ∪ P(B)) In R , I tried the following query: require(HapEstXXR) A <- c(1,2,3) B <- c("A", "B", "C", "D", "E") setdiff(powerset(union(A,B)), union(powerset(A),powerset(B))) As as result I got 221 elements. As far as I know,

Calculating precision of sum of fractions

喜夏-厌秋 提交于 2021-01-28 12:15:37
问题 I have this mathematical expression : ∑(2k+1)/(2k)! , k =0,... ,∞ , it is sum from zero to infinity of all fractions in the form (2k+1)/(2k)! I want to create a method which when passed an integer "n", it will output me the result with n digits after the decimal point.This expression first 100 digits can be viewed here : https://miniwebtool.com/first-n-digits-of-e/?number=100 Here is my code, what I have attempted package pi.strategy; import java.math.BigDecimal; import java.math.BigInteger;

Finding all solutions of a non-square linear system with infinitely many solutions

让人想犯罪 __ 提交于 2021-01-28 09:25:58
问题 In this question was found a solution to find a particular solution to a non-square linear system that has infinitely many solutions. This leads to another question: How to find all the solutions for a non-square linear system with infinitely many solutions, with R? (see below for a possible description of the infinite set of solutions) Example: the linear system x+y+z=1 x-y-2z=2 is equivalent to A X = B with: A=matrix(c(1,1,1,1,-1,-2),2,3,T) B=matrix(c(1,2),2,1,T) A [,1] [,2] [,3] [1,] 1 1 1

Finding all solutions of a non-square linear system with infinitely many solutions

让人想犯罪 __ 提交于 2021-01-28 09:25:24
问题 In this question was found a solution to find a particular solution to a non-square linear system that has infinitely many solutions. This leads to another question: How to find all the solutions for a non-square linear system with infinitely many solutions, with R? (see below for a possible description of the infinite set of solutions) Example: the linear system x+y+z=1 x-y-2z=2 is equivalent to A X = B with: A=matrix(c(1,1,1,1,-1,-2),2,3,T) B=matrix(c(1,2),2,1,T) A [,1] [,2] [,3] [1,] 1 1 1

How to infer the possible values for the final two coordinates of a trapezoid when all 4 line lengths are known

你说的曾经没有我的故事 提交于 2021-01-28 09:09:39
问题 I have a trapezoid where I know the length of all 4 lines, and I know the coordinates of two of the corners. How do I find the coordinates of the remaining two corners in JavaScript? NOTE: All 4 lines are of different length, ie this is not an isosceles trapezoid Here's a little diagram in case it helps: L3 D ____ C / \ L4 / \ L2 -------- A L1 B I know the coordinates of A and B, and the length of L1, L2, L3, and L4 (Which are all different). I just need to get all of the possible sets of

How can I use multiple dimensional polynomials with numpy.polynomial?

社会主义新天地 提交于 2021-01-28 08:20:18
问题 I'm able to use numpy.polynomial to fit terms to 1D polynomials like f(x) = 1 + x + x^2 . How can I fit multidimensional polynomials, like f(x,y) = 1 + x + x^2 + y + yx + y x^2 + y^2 + y^2 x + y^2 x^2 ? It looks like numpy doesn't support multidimensional polynomials at all: is that the case? In my real application, I have 5 dimensions of input and I am interested in hermite polynomials. It looks like the polynomials in scipy.special are also only available for one dimension of inputs. # One

How to solve a 2 variable linear simultaneous equation? Java

狂风中的少年 提交于 2021-01-28 08:16:59
问题 Say you have 3x + 2y = 11 2x - 3y = 16 How would you work out x and y in Java? After doing some algebra I figured out that x = de-bf / ad-bc and y = af-ce / ad-bc These show what the letters are a + b = e and c + d = f Whenever I write the code it always gives me the wrong answer, I am not sure if that is due to using int instead of doubles or what. Would it also be possible to parse the letters from the equation e.g input: 5x - 3y = 5 parased as: a = 5, b = -3 and e = 5 Here is the code

Script for working out exponential limit within a set range

牧云@^-^@ 提交于 2021-01-28 06:23:51
问题 In the image above column B is multiples of A1 and column C is C = C + B (working down the rows) I worked out that in order for C for be 50 in 20 rows A1 has to be 0.2631579 but I'd like to be able to simplify that to a function that will return a list: list = exp(50, 20). I'm not sure about the terminology of such a script so researching beforehand didn't really bring anything up sorry. 回答1: Well based on your problem statement, we know that: B n =(n-1)×a ; and C n =(n-1)×n×a/2 (here a is