Questions tagged [absolute-value]

Absolute value is a mathematical function that returns the non-negative value of a number without regard to its sign.

Absolute value is a mathematical function that returns the non-negative value of a number without regard to its sign.

For example, both 7 and -7 will have an absolute value of 7.

Many programming languages include a function for absolute value in their standard math libraries, often named abs() or similar.

More information: http://en.wikipedia.org/wiki/Absolute_value

219 questions
0
votes
1 answer

How do I store the absolute value of random numbers in a certain column of an array?

I would like to take the randomized numbers of the first column of my array, find their absolute values, and store them in my second column. So far i've written this code: import random nb = int(input("Enter a number : ")) tab =…
Balek
  • 3
  • 1
0
votes
1 answer

Absolute value for negative and positive numbers

I am trying to use the absolute value formula to gather some information from another excel document. It works fine with positive values, but it does not work with negative values. I tried the max and min function also and it does not work. If…
dkuka
  • 17
  • 4
0
votes
1 answer

Calculating the mean of the absolute value of all numerical columns

I want to calculate the mean of the absolute value of all numerical columns for the example dataset DT: library(data.table) set.seed(1) DT <- data.table(panelID = sample(50,50), # Creates a panel…
Tom
  • 2,173
  • 1
  • 17
  • 44
0
votes
1 answer

Find the maximum value of | Ai - Aj | + | i - j |

Click here to view the source of the problem Given an array 'A' consisting of 'n' integers, It is required to find the maximum value of the following expression: |Ai - Aj| + |i - j| where Ai is an element of the array at the i-th…
hackncrack
  • 11
  • 5
0
votes
0 answers

how to sum absolute values of multiple columns in R

I'd like to have the sum of absolute values of multiple columns with certain characteristics, say their names end in _s. set.seed(154) d <- data.frame(a_s = sample(-10:10,6,replace=F),b_s = sample(-5:10,6,replace=F), c =…
Ana
  • 1,516
  • 3
  • 15
  • 26
0
votes
1 answer

Method to turn all values of 3 different arrays into their absolute values and return all 3 keeps only turning the first array but not the next two

I have this assignment for a class that basically gives me three different arrays, and the main method calls my method calls makeThemAllPostive which takes an array and prints out all the values in their absolute value form. However, my method only…
Lilnephew
  • 23
  • 2
0
votes
1 answer

add floating point and integer and take absolute value

Hello I am very new to code and I need to know how to output the value obtained by calculating |x+y| where x is a floating point and y is an integer, both unknown inputs. I have tried many things and cannot succeed please help me. This is what I…
MollyV
  • 55
  • 2
  • 3
0
votes
1 answer

Significance of Assigning Size of during Memory Allocation in Malloc

I have a pointer of type double which is pointing to allocated memory using malloc, where I allocated 12 elements in the array: double *y = (double*)malloc(sizeof(double) * 12); My question is as follows. Say I allocated the memory in this way:…
Anthony
  • 83
  • 1
  • 7
0
votes
1 answer

Ploting the Lasso L1 constraint

In Lasso regression the L1 constraint is used: I'm trying to plot the constraint using R. An example looks like: Here is the simple R code I wrote: beta= seq(-1, 1, length=100) lambda=2 penalty=lambda*abs(beta) plot(penalty, type="l") It draws…
Ville
  • 547
  • 1
  • 3
  • 21
0
votes
1 answer

Convert value to absolute from field

I have a field that takes case id (negative value) to evaluate the conditions. var cont = $('
').insertAfter(condfld).css('margin-top', '5px'); var caseidfld = $('
Dean Statham
  • 61
  • 1
  • 4
0
votes
0 answers

In matlab how can I compute the integral L2 norm in multiple variables?

I have a function X_t which I have defined anonymously to take as variables t which is a scalar time and z which is a vector of potentially arbitrary dimension. That is, X_t = @(t,z) fun(t,z). I want to find the integral L2 norm of this object…
Carrier
  • 31
  • 5
0
votes
2 answers

Finding the absolute value of rows in array and then print the maximum value out ot the answer

I currently need to add all the rows up in an array using only absolute values and then finding the maximum value out ot the three answers. This is what I currently got: public static int maxRowAbsSum(int[][] array) { int[][] maxRowValue = { …
LtMuffin
  • 219
  • 2
  • 14
0
votes
1 answer

Make Django query with .extra

My aim is to create a query which calculate the absolute value of my field and calculate the average of them as well. I have read about it and I tarted to use the .extra possibility in Django but I couldn't achieve my goals. I attach my attempt ant…
user9322651
0
votes
1 answer

minimizing disorder coefficient of an array (sum of absolute values of differences)

I am stuck with a problem from Polish olympiad: every array a1,a2,a3 ... a4 has it's disorder coefficient K, which is equal to |a[1]-a[2]| + |a[2]- a[3]| + |a[3]-a[4]| ... |a[n-1] -a[n]|. for each element we should calculate minimal K that may be…
0
votes
1 answer

Add a row to a dataframe showing amplitude (max of the sum of the positive or the negative values)

I'd like to insert a last row to a dataframe that would show either the sum of the positive values or the sum of the negative value per column, whichever sum has the greatest amplitude. The final table would look like this with the last row…