# Questions tagged [linear]

Linear algebra is a field in mathematics dealing with arithmetic operations over vectors and matrices. Prominent existing libraries for performing such operations are BLAS and LAPACK. There are also dedicated software for vectorizing operations on vectors and matrices. Examples of such software are Matlab, Octave and Mathematica.

946 questions
42 views

### I'm getting this error in pyhton: ValueError: x and y must be the same size

I'm trying to import a csv file and after finding the linear regression I want to plot a graph for it. But after I enter the value in output it shows me this error. The probabilities are correct I've ...
12 views

### Solving a linear system in Eigen without explicitly using a specific decomposition

Is it possible in Eigen to solve a linear system of the form A*x=b using something along the lines of A.solve(b) i.e. without having to do a specific decomposition of A?
17 views

### Is there a simple function in Python to enable Cross Validation?

How do i use 'Cross Validation' on the data below? The dataset contains the following variables: NetValue (Numeric e.g. 1000) DW_EK_Store (Is numeric but is used as Categorical, hence the 'C(...
18 views

### Is it possible to use Bayesian networks to predict numerical output? (non-categorical)

Is it possible to use Bayesian networks to predict numerical values? (non-categorical) For example is it possible to build a Bayesian network in the case of a house price prediction? I found answers ...
30 views

### How to generate PMML for stepwise polynomial regression

I have tried using R and it throws below error. How to generate PMML for stepwise polynomial regression ? Code snippet: library(reshape2) library(pmml) data(tips) fit <- lm(total_bill ~ poly(...
18 views

### Linear Interpolation with krige-Function in R

I'm doing a regression kriging in R and have already done the ordinary kriging with the residuals which worked absolutely fine. Now I want to do the linear regression with three prediction variables ...
5 views

### Linear Modelling on Lingo

I coded linear model on Lingo and I have a constraint like following. when I coded in this manner: x(t)<=y(t)-(a(t)-b(t)); I am getting infeasible solution. but when define (a(t)-b(t)) as ...
13 views

### How to train and fit different linear models

I'm kinda new here so forgive me if this is an obvious question. At the moment I'm working on a dataset that contains values from several sensors over time and I'm trying to predict the future ...
47 views

### Getting gradient descent to work in octave.(Andrew ng's machine learn course, excersise 1)

So i am trying to implement/solve the first programming excersise from Andrew ng`s machine learn cours on coursera. I have trouble implementing linear gradient descent(for one variable) in octave. I ...
11 views

### Searching in the largest item in a list

When looking for the largest item in a list , would it be faster to perform a binary search or reverse the list and then perform a linear search? It's a question I came across on an exam paper and I'...
33 views

### how to change array size to create linear queue?

Before i pick a choice, it give me question how many queue you want and how to change the array size? I have done to create a linear queue, and then i want to change the array size #include <...
16 views

### Linear regression for one subject

I wanted to know whether it is possible in R to run a linear model for only one subject? So to get an individual linear model per subject? The Data contains of reactiontime measures and a score of a ...
62 views

### Angular Material stepper linear validation not working as expected

I am trying to use Angular Material Stepper using a single form. I used linear to fire the validation before going to next step. But it does not seem to be working as expected. I am creating my ...
29 views

### How to create a function to perform regressions for a range of variables and extract model estimates: e.g. coefficients, p-values?

I'm currently performing multiple linear regression analyses across a range of dependent variables (almost 200) and would like to create a function that runs this for a specified set of columns, then ...
26 views

### How to test zero hypothesis with a linear model lm [migrated]

I would like to test a zero hypothesis on a linear model in R ( H0: F = 0, H1: F/= 0). How do I do it? Is it adequate to just use a linear model and if its not significant, then H0 is true? My Code ...
24 views

### How to fix Wrong Accuracy & R -Square?

I try to practice Linear Regression by analysing data file Google Apps Store to predict Rating, the file csv is on Kaggle. After cleaning and trying to apply KNeighborsRegressor to run the model, ...
29 views

### Linear search code that has to output all numbers in the sentence

My linear search has to output the index of all of one character present. So if the sentence is Hello, it would print L is in index 2 and 3. I'm not sure how to do this. def linear_search(intList,...
25 views

### How to make a 1:1 ratio dbfs slider with Web Audio and Javascript?

I am using Web Audio and log10 to work out the db level of my audio output I also have a css slider which goes from 0 to 100. How would I make the slider/db output be a one to one ratio meaning that 1 ...
44 views

### Code for linear search in python not working and outputs wrong text

I need to write a program that does linear search on a character within a sentence. I have to do it without using any inbuilt functions except for print(). The program should output what index the ...
22 views

### I have to code a linear search but my code doesn't seem to work

I need to write a code that does linear search on a character within a sentence. I have to do it without using any inbuilt functions. The program should output what position the character is in the ...
23 views

### Trying to plot multiple ablines in a graph dependent on different groups

I have a data set that I am trying to plot as different groups. Currently my code is par(mfrow=c(1,1)) plot(Length..mm., P.Weight..g.,col="white",xlab="Primary Spine Length", ylab="Primary Spine ...
19 views

### When is Dlib's svm_c_linear_trainer better than svm_c_linear_dcd_trainer?

I have a machine learning problem with high-dimensional labelled inputs and a relatively small sample size. Using the very cool visual guide brought me to the svm_c_linear_trainer method. But what I ...
14 views

### Multiple Linear Regression Normal Equation NOT WORKING

This is the equation I used. I tried to implement the normal equation to do a regression with only 1 independent variable and it worked well. It brought out the right coefficients. But, when I tried ...
72 views

### Calculating tangent for cubic bezier curve java

I am attempting to calculate the tangent of a cubic Bezier curve defined by the points p0, p1, p2, p3 and t. I know this should be a simple calculation and the tangent should simply be the ...
44 views

### How to merge two sublists from two different lists in the original

Both of my lists have sublists inside them list1= [['+', '+', '-'], ['+', '-', '+'], ['-', '+'], ['+', '+', '+']] list2= [['x1', 'x2', '2x3'], ['2x1', 'x2', 'x3'], ['x1', 'x3'], ['3x1', '2x2', '4x3']...
33 views

### Is it possible to find unordered pair of elements in an array with a given Bitwise-OR in less than O(n*n) complexicity? [duplicate]

I want to count all unordered pairs of elements, where bitwise OR of pair values is equal to a given number k. C++ solution with complexity better then o(n^2) is needed.
61 views

### BFPRT (median of medians) algorithm crashes after 185000 array

My BFPRT algorithm crashes as soon as I put a 1300.000 int size array but it works perfectly fine below that. I know that probably it's a memory allocation problem but I have been struggling for days ...
47 views

### Linear Regression - NA's inserted for each category of an independent variable

Overview: I have one dependent variable called 'Tree_diameter', and one independent variable called 'Stand_density_index' (see data frame 1 and 2dbelow). Stand_density_index contains four ...
12 views

### Deciding after which point a plot is linear

Suppose I have a function with discrete points, plotted below: I have to select the point of the graph after which the plot is reasonably linear. As selecting such point visually is very subjective, ...
56 views

### Solidworks C# API create a Linear Pattern

I have an assembly model in Solidworks. I use API C# to Solidworks for automatic create a model. And I don't understand how what I need to write for creating the Linear Pattern on a part. This is ...
24 views

// What is the difference between Batch, Stochastic & Mini-Batch Gradient Descent ??
22 views

### post hoc test for linear mixed model with two variables

I built a linear mixed model and did a post hoc test for it. Fixed factors are the phase numbers (time) and the group. statistic_of_comp <- function (x, df) { x.full.1 <- lmer(x ~ phase_num + ...
21 views

### In Scala Breeze, what is the best way to raise every column of a matrix to a power

Let's say I have a matrix like [a1 a2 a3 a4], where the ai's are the columns, and a Sequence of Ints like (p1, p2, p3, p4). What is the best way to create the matrix [a1^p1 a2^p2 a3^p3 a4^p4]? ...
17 views

### LinearSVC coef_ attirbute

I trained a LinearSVC model with the sklearn library in python3.x. The target variable 'y' had 4 levels (0,1,2,3). model = LinearSVC() X_train, X_test, y_train, y_test = tts(X, y, test_size = 0.25, ...
171 views

### How to generate uniform random points inside d-dimension ball / sphere?

I've looked around and all solutions for generating uniform random points in/on the unit ball are designed for 2 or 3 dimensions. What is a (tractable) way to generate uniform random points inside a ...
21 views

### Recovering full variance-covariance matrix from linear model with linear coefficient restrictions

I am having a trouble with recovering variance-covariance matrix of linear model with coefficient restrictions. The unrestricted model is y = beta0 + beta1 * x1 + beta2 * x2 + beta3 * x3 The ...
50 views

### How to compute all orientations of a cube by rotating, without repeating orientations?

I am working on an application to to find the number of possible solutions to a puzzle cube given a particular starting structure. I have all of the unique solutions stored in memory, which I will be ...
60 views

### How to find a rotation matrix from 3 deformed points in python efficiently

I am trying to find a rotation matrix between coordinate systems by using 3 unit vectors I have defined in both coordinate systems. I am currently using a method I found on Mathmatics which is ...
145 views

### How to remove one of the dummy variables in regression

Suppose, there is a categorical variable, education with different values as std_10, std_12, graduate, PG and Dr. The data set name is df and dependent variable is Income along with another ...
74 views

### How to calculate a deformation gradient in Python. (On a cube in 3D)

I am trying to calculate Large(Langrangian/Green) Strains in python on a cube I have artificially deformed. I am having trouble calculating the deformation matix, F: Non-deformed Cube: Deformed Cube:...
46 views

### Using a function representing a sparse Matrix in scipy

I'm trying to solve a 1_000_000 x 1_000_000 sparse matrix with one of the various algorithms provided by scipy.linalg (or scipy.sparse.linalg) but already fail by creating such a matrix as numpy-2D-...
52 views

### When using pulp cbc solver, can I set priorities for constraints?

I am trying to calculate an optimal answer to a set of binary variables with lots of constraints. I would like to set priorities for the constraints. ex) constraint 1, 2, 3 has priority 100 (highest) ...
35 views

### How do I find an objective formula using multiple variables?

I am trying to find an object equation made of variables which can be 1, 0, or -1, and results can be 0, 60, 90, 180. Is there a tool which can help me? Or do I need to find a mathematician to help ...
51 views

### Finite field and rational linear algebra in Haskell

Is there a Haskell package that can compute the reduced row-echelon form of a matrix, with entries from either the rationals, or a finite field of prime size? I am looking for something that will be ...
41 views

### Returning best support vectors from support vector machine

I'm using a support vector classifier from sklearn (in Python) to find the optimal boundary between a set of "0" and "1" labelled data. See: https://scikit-learn.org/stable/modules/generated/sklearn....
62 views

### Linear Regression - Tensorflow

I'm learning deep learning and machine learning using Tensorflow, and I need to make a prediction which the input is an histogram(per day), I introduce the date in ordinal format (736608 is 2017-10-06)...
34 views

### Implementing pseudocode for QR update - which part of my code is wrong?

I' implementing some pseudocode for an update of a QR decomposition - I want to remove a row from matrix A and update Q and R accordingly. My results are different from those yielded by scipy's ...
73 views

### How to perform a linear least squares regression analysis where the fit values must be greater than the observed values?

I have an observation that is a single curve (Y) in the form of signal intensity vs. frequency. I would like to model this signal as a linear combination of a series of predictor curves in a design ...