How to optimise feed-forward control of a process based on a prediction using the prediction confidence?

I’m looking for a control method for a production process with the following characteristics:

  • 1 control variable
  • many proces parameters (+-50)
  • 1 resulting variable
  • continuous measurement of resulting variable with 30-90 second delay
  • complex physics that govern the process and numerous factors that determine the (non-linear) relation between control variable and resulting variable

With constant proces/input parameters, the distribution of the resulting variable is normal.

The control method should ensure that the resulting variable should be above a set minimum and that the average of the resulting value should be as close to the limit as possible. Being above the lower limit makes the product more expensive, being below the lower limit however is more expensive: the product is scrapped.

Now I want to try the following: I have want to make a statistical model using some proces parameters as input predicting the control variable that leads to the desired value for the resulting variable. Next to the value of the control variable, I also want to determine the ‘confidence’ or distribution of that value. Then I want to state a portion of the time the control variable must be above the lower limit (i.e. 3 sigma). Consecutively I’d like to set the setpoint for the control variable at the such a value that I achieve the given portion above the lower limit. To illustrate what I envision I made the illustration below.

enter image description here

Do you think this setup makes any sense? Am I missing any obvious alternative solution that is much simpler? Is this a known approach?

R dataframe: select rows by sorting one column and based on values in two columns

I have a dataframe df as below:

user_id     rating      date          status
10506       4           2008-11-11    2
10506       3           2008-11-13    1
10506       4           2008-11-23    3
10506       2           2008-11-29    4
10506       1           2008-01-15    2
10506       1           2007-11-11    2
10507       3           2007-10-20    1
10507       5           2007-11-11    1
10507       2           2007-12-21    2
10507       5           2008-01-08    3
10507       4           2008-01-31    3
10507       3           2008-02-05    4
10507       4           2008-03-10    2

I would like to do the following two operations:

  1. Select three rows for each user_id with the earliest date. I know that all user_id have at least three observations. date is not in date format, but when I order by date, I am able to get in chronological order.

  2. Select three rows for each user_id with earliest date where status is 3 or 4.

Is there any dplyr solution where I can group by user_id and then select first three rows after sorting date in ascending order? Any help is appreciated.

Can you send console commands to a node-based systemd service?

I have a simple node.js script that accepts console commands using readline. I’ve set it up to run as a systemd service (on Debian 9):

[Unit]
Description=Web Game Server

[Service]
ExecStart=/usr/bin/node /var/www/index.js
Restart=always
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

When running directly from the console with node index.js I’m able to send commands to it through the console. Is there any way to do this while it’s running as a service?

error al correr la app en android studio : “is not a valid file-based resource name character”

buenas simplemente la app no quiso correr mas, y este es el codigo que me sale, ya trate de REHACER todos los fragments (eso fue lo que hice y aun nada)

Error:Error: 'C' is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore
Error:Execution failed for task ':app:mergeDebugResources'.
> C:UsersernyAndroidStudioProjectsOrganizadorJECappsrcmainreslayoutfragment_Calendario.xml: Error: 'C' is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore

introducir la descripción de la imagen aquí

A Javascript-based fallback for position: sticky

Just learning about this site today. Very excited!

I posted a question to SO earlier today, right before solving it. Turns out, my question really is more of a code review kind of item.

https://stackoverflow.com/questions/52908302/implement-position-sticky-in-vanilla-js-with-multiple-instances-on-the-page

You can see the before and after there, but here’s the after that I’d like to bring for review here:

The goal of this script is to polyfill any browsers I’m supporting that don’t natively have position: sticky. Ex: I’m thinking about detecting IE11 and running this script only there.

My questions then are:

  1. Does structuring this code as a class makes sense here?
  2. Is there anything obvious about my class that’s wrong?
  3. How should I export this as an ES6 module?
  4. Any other advice?

Thanks all!

Code structure is the one big thing I struggle with with js, and so I’d greatly appreciate any feedback you have.

class makeSticky {
	constructor(el) {
		this.element = el;
		this.fixedClass = 'is-fixed';
		this.parent = this.element.parentNode;
		this.position = this.element.offsetTop;
		this.parentBottom = this.parent.clientHeight + this.parent.offsetTop;
	}

	init() {
		this.addEvents();
		this.onScroll();
	}

	addEvents() {
		window.addEventListener('scroll', this.onScroll.bind(this));
	}

	onScroll(event) {
		if (this.aboveScroll() && this.stillInsideParent()) {
			this.setFixed();
		} else {
			this.setStatic();
		}
	}

	aboveScroll() {
		return this.position < window.scrollY;
	}

	stillInsideParent() {
		return this.parentBottom > window.scrollY;
	}

	onScroll(event) {
		if (this.aboveScroll() && this.stillInsideParent()) {
			this.setFixed();
		} else {
			this.setStatic();
		}
	}
	setFixed() {
		this.element.classList.add(this.fixedClass);
	}
	setStatic() {
		this.element.classList.remove(this.fixedClass);
	}
}

const children = document.querySelectorAll('.child');
children.forEach(child => {
	const sitck = new makeSticky(child);
	sitck.init();
});.
  .wrapper {
    max-width: 800px;
    margin: 60px auto;
  }

  .is-flex {
    display: flex;
  }

  .sidebar {
    width: 300px;
    flex: none;
    background: #eee;
  }

.child {
  color: red;
}
  .is-fixed {
    position: fixed;
    top: 20px;
  }

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

A full width thing might go down here before another wrapper starts

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

A full width thing might go down here before another wrapper starts

How to set VIM’s background based on terminal’s background colour?

I use CentOS 7 which has VIM 7.4 installed. By default the background property of VIM here is set to light irrespective of the colourscheme of my terminal. Although I can always force the desired background property in my vimrc, I do not want this.

In Ubuntu (18.04 which has VIM 8), background property automatically changes between light and dark based on the colourscheme of my terminal. This is true even when I am ssh-ing to the Ubuntu machine from my CentOS machine.

Therefore, I would like to know whether the ability of VIM changing background property automatically is specific to newer versions. And if this is not true, then how do I achieve the same effect in CentOS?

Low cost IR sensor based finger gesture recognition controlled wheelchair

I am doing a project in which three IR sensors are used for getting three fingers’s gesture to control the movements (left, right, forward, backward) of two motors.

The threshold value of IR sensor output is 450 mV for getting signal to be passed.

I am not understanding how to design different conditions for different movements of motors

int firstanalogPin = 1;     // Infrared Sensor (Right lead) connected to analog pin 1

int val1 = 0;           // variable to store the value read

int enablePin = 1;
int LeftMotorForward = 10; // Pin 10 has Left Motor connected on Arduino boards.
int LeftMotorReverse = 9; // Pin 9 has Left Motor connected on Arduino boards.

int RightMotorForward = 12; // Pin 12 has Right Motor connected on Arduino boards.
int RightMotorReverse = 13; // Pin 13 has Right Motor connected on Arduino boards

void setup()
{
    pinMode(LeftMotorForward, OUTPUT);  // initialize the  pin as an output.
    pinMode(RightMotorForward, OUTPUT);  // initialize the  pin as an output.
    pinMode(LeftMotorReverse, OUTPUT);  // initialize the  pin as an output.
    pinMode(RightMotorReverse, OUTPUT);  // initialize the  pin as an output.
    Serial.begin(9600);          //  setup serial
}

void loop()
{
    val1 = analogRead(firstanalogPin);    // read the input pin
    Serial.println(val1);                           // debug value


    if (val1 >700) // forward
        digitalWrite(LeftMotorForward, HIGH);
    else
        digitalWrite(LeftMotorForward, LOW);   // turn the Left Motor ON
    if (val1 >700)
        digitalWrite(RightMotorForward, HIGH);// turn the Right Motor ON 
    else
        digitalWrite(RightMotorForward, LOW);// turn the Right Motor ON
}

How to overlay the image scaling based on the user distance & focal length

I’m overlaying images on the cameraView and based on the user input of room width & height. The images are displaying proportionally to width & height ratio. but i need to overlay the images based on the distance. If 5feet means, then i need to display the images closer, if it’s 8ft means i need to overlay images littlebit far. I referred these links https://stackoverflow.com/questions/11913355/scaling-ar-pictures-based-on-the-distance-from-the-camera , https://stackoverflow.com/questions/13190932/how-to-find-out-focal-length-of-camera-in-ios-and-what-is-the-sensor-height?lq=1. But the result size is too small.

int imagesize_height = (152.4*199)/0.33;

 int imagesize_width = (152.4*350)/0.33;

distance in cm = 152.4 and ipadMini camera focal length is 3.3mm = 0.33cm, image width is 350 & height is 199

Linked List based question

I am making a Smart Cart using RFID. The user will
have a RFID card. As soon as he swipes the card on
the RFID Reader it will identify the user and will create
a linked list for that particular user. The linked list will
contain the unique Rfid based Ids of the items purchased by the user. In my code
the problem is that after the detection of the user it is
not creating any linked list for the items/it is not detecting the items bought by the user. Both the user and items are identified by their unique ids (ie RFID tags).It is detecting the user but once the user is being detected it is not mapping the items bought with that user.

the code for the same is :

int count = 0; // count = 0
int i;
char input[12];                                   // character array of size 12 
boolean flag = 0;
// flag =0

boolean comparetag(char x[12], char bb[12]) {
  boolean ff = false;
  int fg = 0;
  for (int cc = 0; cc < 12; cc++) {
    if (x[cc] == bb[cc]) {
      fg++;
    }
  }
  if (fg == 12) {
    ff = true;
  }
  return ff;
}

struct Node {
  char x[12];
  struct Node *next;
};

struct Node* X;
struct Node* point;

void printList(struct Node *n) {
  while (n != NULL) {
    Serial.print(n->x);
    n = n->next;
  }
}

struct Node* Shopping(char[]) {

  Serial.print(input);
  // Print RFID tag number 
  Serial.print("Welcome User");
  Serial.println();

  Serial.print("Start Shopping ");

  struct Node* head = NULL;
  head = (struct Node*) malloc(sizeof(struct Node));

  return head;

}

void setup() {
  Serial.begin(9600);
}

void loop() {

  if (flag == 0) {
    if (Serial.available()) {
      count = 0;
      while (Serial.available() && count < 12) // Read 12 characters and store them in input array
      {
        input[count] = Serial.read();
        count++;
        delay(5);
      }

      if (comparetag(input, "1B006AFA9F14")) {
        flag = 1;

        point, X = Shopping(input);
      } else {
        Serial.println("not Registered User");
      }
    }
  } else {
    int c = 0;
    if (Serial.available()) {
      while (Serial.available() && c < 12) // Read 12 characters and store them in input array
      {
        Serial.print("Taking Input");
        X->x[c] = Serial.read();
        c++;
        delay(5);
      }
      struct Node* second = NULL;
      second = (struct Node*) malloc(sizeof(struct Node));
      second = NULL;

      X->next = second;
      X = second;

    }
  }
  printList(point);
}

What can I infer about a correlation based on another correlation that shares one variable?

I have three variables, $X$, $Y$, and $Z$. X is independently normally distributed $Xsim N(0,sigma^2_X)$.

$Y$ and $Z$ are jointly normally distributed:

$left[ begin{array}{c}Y\ Zend{array}right]sim Nleft(left[begin{array}{c}0\ 0end{array}right],left[begin{array}{cc}sigma^2_Y & rho \ rho & sigma^2_Zend{array}right]right)$

So, naturally, $E(X’Y)=E(X’Z)=0$.

However, in non-infinite samples, $X’Y$ doesn’t have to be zero.

What can I say about $E(X’Z)$ conditional on my sample observation of $X’Y$? In other words, can I say anything about $E(X’Z|X’Y)$?

I feel like this is probably not a super difficult problem but I’ve come at it a few different ways and not really been able to make much headway (aside from a simulation, which gives me an answer but not why, or how conditional it is on the parameters I set), which makes me think I’m missing something obvious.

While in the middle of writing this up it occurred to me that I could probably calculate a distribution of $X’Z$ conditional on $X’Y$ from the Wishart distribution. But I, uh, hope it’s simpler than that.