Questions tagged [piecewise]

"piecewise" may refer to a piecewise function, a piecewise interpolation or a piecewise regression / smoothing.

Defining a piecewise function normally requires writing if ... else ... clause.

Interpolation is inherently piecewise.

Piecewise regression often refers to piecewise linear regression, or segmented regression.

367 questions
-1
votes
2 answers

Which R /Python package for piece wise segmented regression with automated breakpoint detection

I'm looking for R/ Python packages that can do a segmented regression with automated breakpoint detection, report the linear segments and find out the coefficients (slope/intercept) of the linear segments in an automated way. I would prefer R…
The August
  • 469
  • 2
  • 7
  • 18
-1
votes
1 answer

Unwanted evaluation of boolean expression in sympy

I am trying to formulate a piecewise function in sympy and then plot it, but I can't formulate the wanted function. The problem is that (x > 0) & (x < 1) evaluates x > 0 to be always True before it can be passed to the Piecewise constructor. This…
Johan
  • 1
  • 1
-1
votes
1 answer

Piecewise functions

I'm fairly new to python and would like to know why I can't graph a piecewise function like below, and why the error message is popping up? def get_data(self, frame): self.ydata =np.piecewise(self.xdata, [self.xdata<.2, self.xdata>=.2][…
-1
votes
1 answer

Raising to the power of individual matrix elements in piecewise functions

I am trying to define a piecewise function in MATLAB. n = -10:10 k(n>0) = ((1/6)^(n(n > 0))/n(n>0)); k(n==0) = log(32); k(n<0) = ((1/4)^(-n(n<0)))/n(n<0); MATLAB complains that I should be using an element-wise power (.^), but…
ckarpis
  • 3
  • 2
-2
votes
3 answers

Build multiple piecewise function in a for loop python

I was trying to build multiple piecewise functions in python by using for loop. Here is a simple example: a = [(1,2),(3,4)] weight = {} for i in range(2): a_a = a[i][0] a_b = a[i][1] name = str(i) print(a_a,a_b) def piece_wise_function(t): …
Holt_1994
  • 3
  • 2
-2
votes
2 answers

piecewise regression with two breakpoints to be fitted in R: a horizontal line, a straight line and then again a horizontal line

I want to do a piecewise regression with two breakpoint in R: first a horizontal line with slope 0, then a linear line and then again a horizontal line with slope 0. The two breakpoints should be fitted also. My data looks like this (in total I have…
Jana
  • 21
  • 2
-2
votes
1 answer

Plotting order statistics in R

I need to plot the joint density function of a bivariate random vector of order statistics which is defined by: f(x,y) = (n!)*f(x)*f(y) for x < y and 0 otherwise where f is the density function of a univariate random variable. For example,…
user3149230
  • 173
  • 1
  • 1
  • 7
1 2 3
24
25