Math Genius: Family of smooth Cumulative Distribution Functions on $mathbb{R}^+$ with non-smooth limits

Original Source Link

I am wondering whether there is some known family $c(x,a)$ of CDFs (cumulative distribution functions), where $a$ are some parameters and $x geq 0 $, such that

  • $c(x,a)$ is continuous $forall x,a$.

  • The PDF $c'(x,a)$ is continuous $forall x$ and for almost all $a$, apart for some “special value” $a=a_0$.

  • For some particular limit of the parameters, say formally $a = a_0$, we have that $c(x, a_0) =0$ if $x<1$ and that $c'(1^+, a_0) = +infty$. This is the red curve sketched in the image below.

  • For every $a$, including $a=a_0$, we have that $c(0,a)=0$ and $c'(0,a)=0$.

If no such a family is known, is there a strategy to construct an explicit example (maybe a minimal one, where $a$ is just a single parameter)? Partial answers and hints are appreciated.

Visual sketch: For more clarity it may be convenient to give a visual sketch of the problem. We have to construct a family of functions $c(x,a)$ that behave as the blue curves in the image below:

  • $c(x,a)$ and $c'(x,a)$ are both continuous.

  • $c'(x,a)=0$ for $x rightarrow 0^+$.

  • $c(x,a)$ tends to the red curve $r(x)$ for $a rightarrow a_0$, where the red curve is such that $r'(1^+) = infty$. This red curve is the function $c(x, a_0)$ mentioned in the first part of this post.

  • Possibly, $c(x,a)$ tends to the green curve $g(x)$ in some other limit, where the green curve is, for example, $ g(x)=H(1-x) x^n+H(x-1)$, with $n>0$ and $H$ the Heaviside step function. This curve is there just to say that there could be another non-smooth limit of the blue curves, but that in general we want all the curves of the family to be zero (and possibly have zero derivative) at the origin.

enter image description here

Clearly the “trivial” solution
$$
c(x,a) = (1-a)g(x) + a r(x)
$$

does not work because it gives rise to a PDF $c'(x,a)$ that is not continuous. Stated in other words, I am looking for an “example of homotopy” between the “red CDF” and the “green CDF” such that the “blue CDFs” are at least of class $C^1$ (i.e. the “blue PDFs” are at least of class $C^0$).

Loosely speaking: For example, the Weibull, the Log-logistic, the Chi-squared, the Gamma and many other distributions all seem to be able to reproduce “smooth shapes” for most of the parameters, as well as shapes “where there is angle at the origin” …the problem is that I want to “move the angle” to some $x>0$. Maybe some clever re-parametrization of the three parameters of the Generalized extreme value distribution in terms of just one parameter could work?

Does something like this work?

Take any $K:[0,infty) rightarrow [0,1]$ that is differentiable.

Let $g_n:[0,1) rightarrow [0,a_n]$ be a sequence of functions that are continuous, differentiable, non-decreasing, strictly decreasing in $n$ pointwise, and satisfy $lim_{xuparrow 1}g_n(x)=a_n$ and $lim_{xuparrow 1}g_n'(x)=a_n$. For example, $a_n dfrac{1}{n} x^{n} rightarrow 0$ on $[0,1)$, with derivative $a_n x^{n-1}$, and at $x=1$, $a_n$.

Let $h_n:[1,infty) rightarrow [a_n,infty)$ be a sequence of functions that are continuous, differentiable, strictly increasing, and satisfy $lim_{x downarrow 1}h_n(x)=a_n$ and $lim_{x downarrow 1}h_n'(x)=a_n$. For example, $ a_n (1-frac{1}{lambda}e^{-lambda (x-1)})$ with derivative $a_n e^{-lambda(x-1)}$, and at $x=1$, $a_n$. Or even $h_n(x) = a_n x$ would work.

Consider
$$F(x)=
begin{cases}
K(g_n(x)), & 0 le x < 1\
K(h_n(x)), & xge 1.
end{cases}
$$

then
$$
f(x) = begin{cases}
k(g_n(x))g_n'(x), & 0 le x < 1\
k(h_n(x))h_n'(x), & x ge 1.
end{cases}
$$

At $x=1$, you need $k(g_n(1))g_n'(1)=k(h_n(1))h_n'(1)$, but both of those terms equal $a_n$ since $g_n(1) = h_n(1)=a_n$, and $g_n'(1)=h_n'(1)=a_n$.

You just need to smoothly paste the derivative across $x=1$, if I’m not mistaken?

Tagged : / / / /

Server Bug Fix: Front axle cone replacement – sizing

Original Source Link

So I am trying to replace my pitted front axle cones, but struggling to find the parts of the right size.

My axle diameter is 9.4mm on the thread and 8.8mm on the smooth part, and respectively the cone inner diameter is 8.8mm. I have tried a 9mm cone I’ve got but it predictably doesn’t fit.

3/8″ axle standard seems close enough – but they seem to be mostly back axles which is a bit concerning. Another problem is that 3/8″ cones are all supposed to go with 7x1/4″ bearings, while my bearings are 4.7mm (3/16″) and there were 10 of them on each side, so I am skeptical.

Would 3/8” cones and/or axle be a good fit for me? If I go with 3/8″ cones, which bearings I would need to use, 3/16″ or 1/4″? Would it damage the hub if the bearings are not the same size as before?

The length of my old cones (12.5mm) and their outer diameter (15mm) also don’t appear to be common. I suspect it must be Shimano CN-R088, but the only UK shop where I can find it only has 1 in stock (and for £10!) If I go with shorter cones which seem to be more common (like the 9mm one on the picture linked above), would it make any critical difference?

Thank you.

9.4mm major diameter means you have a 3/8″ axle, which is sometimes even called 9.5mm. The thread on it should be 3/8x26tpi, which again is sometimes called 9.5mm x 26tpi.

All Shimano hubs have the Shimano name and a Shimano-esque part number on them, which for normal front hubs (non-generator etc) will start with “HB-“. Shimano doesn’t do rebrands. Also all Shimano threaded axle hubs use metric axle threads unless there’s a prevailing standard otherwise, as in 3/8″x24tpi internally geared hubs, low-end generator hubs for shopping bikes, etc. So from the sound of it, it’s not Shimano.

Things I will say straight off:

  1. Some shops specialize in Dahon and might be able to make this very easy for you. If you had access to such a place, that could be a good way of cutting to the chase.
  2. If you insist on matching a replacement yourself there are technical aspects to getting it right that are a little outside the scope of an SE type answer (or at least one I’m willing to write I guess.) There’s a second edition copy of Barnett’s floating around the internet. I’m not really sure of the legality so I won’t link. I believe it was compiled from sample chapters and it’s largely outdated at any rate. However, it does have their chapter on replacement cone matching, the principles of which haven’t changed. Every other writing on the subject I’ve ever seen on the subject is overly pithy and misses some aspects.
  3. One of the key steps in replacement cone matching is testing that the ball track is occurring on the new cone in an appropriate spot. Usually this means nestled neatly in the curvature of the cone, not too high or too low. Barnett’s covers this in depth. Any good mechanic will do this test when installing a non-factory replacement cone and not make any promises beforehand. The point is that ordering generic replacement cones online is pretty dicey.
  4. If one really wanted to try ordering them online anyway, you need to find a way to match curvatures. What I would probably do is use a scanner to create a good side view profile of the existing cone and overlay it properly scaled in a graphics app with the side view product images of the various Wheels Mfg 3/8″/9.5mm generic front cones (which they call “Taiwan cones” since several of the dominant OEM hub firms are Taiwanese) I’d be looking at as initial candidates to choose from.

To answer your questions:

  • Cup and cone hubs typically have no real ability to handle different ball sizes or different numbers of balls, the exception to the latter being most hubs can either have loose balls or retainers with the same size but a lesser number of balls. You need a front cone. All generic replacement front cones are for 3/16″ balls.
  • The color of the axle is irrelevant. Some have a black oxide finish and some have different kinds of raw or polished finishes. Well kept axles have grease on them and good chromoly ones are very corrosion resistant anyway, so it doesn’t really matter.
  • 3/8″ axles are one of the sizes where the same size axle is used on front and rear hubs in some applications. So it’s not true that 3/8″ cones are categorically supposed to go with 7×1/4″ balls. 7×1/4″ would typically imply a rear hub with a bearing retainer, and in such a hub 9 1/4″ balls would typically work without a retainer. You need a front 3/8″ cone, which basically all are going to be sized to work with ten 3/16″ balls. One of the confusing things about this may be that the metric sized axle standards, which depending on where you look have become more common, use different diameter axles front and rear.

The practical thing to do is one of two things:

  • Read the Barnett’s chapter, then find a shop that has the full range of Wheels Mfg 3/8″ front cones and take what you have to go try to find a match. The Barnett’s chapter will get into the sealing and length matching considerations, as well as how to transplant pressed seals etc. Wheels Mfg used to make a 3/8″ Taiwan Cone kit that I believe is no longer available in kit form, but a lot of shops still have it, and the cones that it came with are all still available.
  • Fix your existing cones by grinding them with a drill and sandpaper. I’ve come to have a high regard for this approach since it can usually be made to work acceptably unless the cone is devastated, and replacement cones can be harder to obtain than they used to be. There are questions here about this approach.
Tagged : / / /

Code Bug Fix: How should i sort a list inside an object in functional programming with different logic based on different condition

Original Source Link

Consider that we have an ‘api_fetchData’ which fetch data from server, and based on route, it could be table or a tree, also we have two state that we should update them based on the received data. and i should note that if the data was a table we should sort it’s records by its priority. i wonder how should i do that in functionl programming way(like use ramda or either …)

 const tree=null;

and

const table = null:

//table

 {
        type: "table",
        records: [
          {
            id: 1,
            priority: 15
          },
          {
            id: 2,
            priority: 3
          }
        ]
}

//tree

{
        type: "tree",
        children: [
          {
            type: "table",
            records: [
              {
                id: 1,
                priority: 15
              },
              {
                id: 2,
                priority: 3
              }
            ]
          }
        ]
  }

This is what i did:

//define utils

  const Right = x => ({
    map: f => Right(f(x)),
    fold: (f, g) => g(x),
    inspect: x => `Right(${x})`
  });
  const Left = x => ({
    map: f => Left(x),
    fold: (f, g) => f(x),
    inspect: x => `Left(${x})`
  });
  const fromNullable = x => (x != null ? Right(x) : Left(null));
  const state = reactive({
    path: context.root.$route.path,
    tree: null,
    table: null
  });

// final code:

  const fetchData = () => {
    return fromNullable(mocked_firewall[state.path])
      .map(data =>
        data.type === "tree"
          ? (state.tree = data)
          : (state.table = R.mergeRight(data, {
              records: prioritySort(data.records)
            }))
      )
      .fold(
        () => console.log("there is no data based on selected route"),
        x => console.log(x)
      );
  };

You have several problems here –

  1. safely accessing deeply nested data on an uncertain object
  2. sorting an array of complex data using functional techniques
  3. safely and immutably updating deeply nested data on an uncertain object

1. Using .map and .chain is low-level and additional abstraction should be added when syntax becomes painful –

const state =
  { tree:
      { type: "sequoia"
      , children: [ "a", "b", "c" ]
      }
  }

recSafeProp(state, [ "tree", "type" ])
  .getOrElse("?") // "sequoia"

recSafeProp(state, [ "tree", "foobar" ])
  .getOrElse("?") // "?"

recSafeProp(state, [ "tree", "children", 0 ])
  .getOrElse("?") // "a"

recSafeProp(state, [ "tree", "children", 1 ])
  .getOrElse("?") // "b"

recSafeProp(state, [ "tree", "children", 99 ])
  .getOrElse("?") // "?"

We can implement recSafeProp easily, inventing our own convenience function, safeProp, along the way –

const { Nothing, fromNullable } =
  require("data.maybe")

const recSafeProp = (o = {}, props = []) =>
  props.reduce // for each props as p
    ( (r, p) => // safely lookup p on child
        r.chain(child => safeProp(child, p))
    , fromNullable(o) // init with Maybe o
    )

const safeProp = (o = {}, p = "") =>
  Object(o) === o // if o is an object
    ? fromNullable(o[p]) // wrap o[p] Maybe
    : Nothing()  // o is not an object, return Nothing

2. The Comparison module. You seem to have familiarity with functional modules so let’s dive right in –

const { empty, map } =
  Comparison

const prioritySort =
  map(empty, record => record.priority || 0)

// or...
const prioritySort =
  map(empty, ({ priority = 0}) => priority)

myarr.sort(prioritySort)

If you want immutable sort –

const isort = ([ ...copy ], compare = empty) =>
  copy.sort(compare)

const newArr =
  isort(origArr, proritySort)

Here’s the Comparison module. It is introduced in this Q&A. Check it out there if you’re interested to see how to make complex sorters in a functional way –

const Comparison =
  { empty: (a, b) =>
      a < b ? -1
        : a > b ? 1
          : 0
  , map: (m, f) =>
      (a, b) => m(f(a), f(b))
  , concat: (m, n) =>
      (a, b) => Ordered.concat(m(a, b), n(a, b))
  , reverse: (m) =>
      (a, b) => m(b, a)
  , nsort: (...m) =>
      m.reduce(Comparison.concat, Comparison.empty)
  }

const Ordered =
  { empty: 0
  , concat: (a, b) =>
      a === 0 ? b : a
  }

Combining sorters –

const { empty, map, concat } =
  Comparison

const sortByProp = (prop = "") =>
  map(empty, (o = {}) => o[prop])

const sortByFullName =
  concat
    ( sortByProp("lastName")  // primary: sort by obj.lastName
    , sortByProp("firstName") // secondary: sort by obj.firstName
    )

data.sort(sortByFullName) // ...

Composable sorters –

const { ..., reverse } =
  Comparison

// sort by `name` then reverse sort by `age` –
data.sort(concat(sortByName, reverse(sortByAge)))

Functional prinicples –

// this...
concat(reverse(sortByName), reverse(sortByAge))

// is the same as...
reverse(concat(sortByName, sortByAge))

As well as –

const { ..., nsort } =
  Comparison

// this...
concat(sortByYear, concat(sortByMonth, sortByDay))

// is the same as...
concat(concat(sortByYear, sortByMonth), sortByDay)

// is the same as...
nsort(sortByYear, sortByMonth, sortByDay)

3. The lowest hanging fruit to reach for here is Immutable.js. If I find more time later, I’ll show a lo-fi approach to the specific problem.

Your solution seems overkill to me.

Functional programming is about many things, and there is no concise definition, but if your main unit of work is the pure function and if you don’t mutate data, you’re well on the way to being a functional programmer. Using an Either monad has some powerful benefits at times. But this code looks more like an attempt to fit Either into a place where it makes little sense.

Below is one suggested way to write this code. But I’ve had to make a few assumptions along the way. First, as you discuss fetching data from a server, I’m assuming that this has to run in an asynchronous mode, using Promises, async-await or a nicer alternative like Tasks or Futures. I further assumed that where you mention mocked_firewall is where you are doing the actual asynchronous call. (Your sample code treated it as an object where you could look up results from a path; but I can’t really make sense of that for mimicking a real service.) And one more assumption: the fold(() => log(...), x => log(x)) bit was nothing essential, only a demonstration that your code did what it was supposed to do.

With all that in mind, I wrote a version with an object mapping type to functions, each one taking data and state and returning a new state, and with the central function fetchData that takes something like your mocked_firewall (or really like my alteration of that to return a Promise) and returns a function that accepts a state and returns a new state.

It looks like this:

// State-handling functions
const handlers = {
  tree: (data, state) => ({... state, tree: data}),
  table: (data, state) => ({
     ... state, 
     table: {... data, records: prioritySort (data .records)}
  })
}

// Main function
const fetchData = (firewall) => (state) => 
  firewall (state)
    .then ((data) => (handlers [data .type] || ((data, state) => state)) (data, state))


// Demonstrations
fetchData (mocked_firewall) ({path: 'foo', table: null, tree: null})
  .then (console .log) // updates the tree

fetchData (mocked_firewall) ({path: 'bar', table: null, tree: null})
  .then (console .log) // updates the table
  
fetchData (mocked_firewall) ({path: 'baz', table: null, tree: null})
  .then (console .log) // server returns type we can't handle; no update
  
fetchData (mocked_firewall) ({path: 'qux', table: null, tree: null})
  .then (console .log) // server returns no `type`; no update
.as-console-wrapper {min-height: 100% !important; top: 0}
<script> 
// Dummy functions -- only for demonstration purposes
const prioritySort = (records) =>
  records .slice (0) .sort (({priority: p1}, {priority: p2}) => p1 - p2)

const mocked_firewall = ({path}) => 
  Promise .resolve ({
    foo: {
           type: "tree", 
           children: [{
             type: "table", 
             records: [{id: 1, priority: 15}, {id: 2, priority: 3}]
           }]
         },
    bar: { 
           type: 'table', 
           records: [{id: 1, priority: 7}, {id: 2, priority: 1}, {id: 3, priority: 4}]
         },
    baz: {type: 'unknown', z: 45},
  } [path] || {})
</script>

You will notice that this does not alter the state; instead it returns a new object for the state. I see that this is tagged vue, and as I understand it, that is not how Vue works. (This is one of the reasons I haven’t really used Vue, in fact.) You could easily change the handlers to update the state in place, with something like tree: (data, state) => {state.tree = data; return state}, or even skipping the return. But don’t let any FP zealots catch you doing this; remember that the functional programmers are well versed in “key algorithmic techniques such as recursion and condescension.” 1.

You also tagged this ramda.js. I’m one of the founders of Ramda, and a big fan, but I see Ramda helping here only around the edges. I included for instance, a naive version of the prioritySort that you mentioned but didn’t supply. A Ramda version would probably be nicer, something like

const prioritySort = sortBy (prop ('priority'))

Similarly, if you don’t want to mutate the state, we could probably rewrite the handler functions with Ramda versions, possibly simplifying a bit. But that would be minor. For the main function, I don’t see anything that would be improved by using Ramda functions.

There is a good testability argument to be made that we should pass not just the firewall to the main function but also the handlers object. That’s entirely up to you, but it does make it easier to mock and test the parts independently. If you don’t want to do that, it is entirely possible to inline them in the main function like this:

const fetchData = (firewall) => (state) => 
  firewall (state)
    .then ((data) => (({
      tree: (data, state) => ({... state, tree: data}),
      table: (data, state) => ({
        ... state, 
        table: {...data, records: prioritySort(data .records)} 
      })
    }) [data .type] || ((data, state) => state)) (data, state))

But in the end, I find the original easier to read, either as is, or with the handlers supplied as another parameter of the main function.


1 The original quote is from Verity Stob, but I know it best from James Iry’s wonderful A Brief, Incomplete, and Mostly Wrong History of Programming Languages.

🎈 Short and simple way

In my example I use ramda, you need to compose some functions and voila ✨:

const prioritySort = R.compose(
  R.when(
    R.propEq('type', 'tree'),
    R.over(
      R.lensProp('children'),
      R.map(child => prioritySort(child))
    )
  ),
  R.when(
    R.propEq('type', 'table'),
    R.over(
      R.lensProp('records'),
      R.sortBy(R.prop('priority')),
    )
  ),
)

const fetchData = R.pipe(
  endpoint => fetch(`https://your-api.com/${endpoint}`, opts).then(res => res.json()),
  R.andThen(prioritySort),
)

fetchData(`tree`).then(console.log)
fetchData(`table`).then(console.log)

Check the demo

For inspection you can simple use function const log = value => console.log(value) || value

R.pipe(
  // some code
  log,
  // some code
)

it will log the piping value.

Tagged : / / /

Linux HowTo: SSH: connection timed out

Original Source Link

I am trying to connect via SSH but I get Connection timed out and nothing I found on the internet on this topic yielded any results.

The Linux distro that I am trying to connect to is Debian:

The port SSH is listening to is the default one: 22
The port SSH is listening to is the default one: 22

As far as I can tell there is no firewall:
As far as I can tell there is no firewall

ip addr output:
ip addr output

nmap 10.0.2.15 -Pn output:
nmap output

ssh [email protected] output:
ssh output

The VBox NATted network is not exposed to your host.

You can check that with ipconfig and route – there will be no 10.0.2.x IP/route – so the traffic from you host will be going to the default gateway and get lost using the default route (most probably to your router and then to the Internet)

Screenshots from my Mac OS VirtualBox.

Resolution – You have two options:

  1. Create HostOnly Network for access:

File->Host Network Manager

So you create a HostOnly network in VBox Host Network Manager which will create a network adapter on your host through which you will be able to reach the host.
In my example I used the 192.168.56.x/24 with DHCP enabled.

The first NATted adapter (which you have on your VM):

First adapter

Then add a second adapter to the VM using the created network and select HostOnly and the network you created:

Second adapter connected to the created network

After you have added the vmnic – you might need to configure it.
See my ifconfig:

ifconfig output

first adapter – 10.0.2.4

second adapter – 192.168.56.104 – on top of screenshot you can see that I used this IP to connect with ssh.

  1. Port forward from your host to the VM

Another option would be to port forward the traffic from your host to the VM’s IP

IMHO:
The first option is the easier one as you will be able to use default ports, while the second will mean one non-default free port on your host to the port 22 for each VM.

Tagged : / / /

Making Game: How to turn off FireFox’s responsive design’s touch simulator

Original Source Link

I noticed on my FF 26.0 that the responsive design view was upgraded to have a touch simulator. Now when I tried it I could not get it to dissable.

enter image description here

I tried togling it and leaving the responsive view and reloadig the page and even opening the page up in a new tab. Not even closing the browser and reopen the page gets rid of it the touch simulator, it is still on.

EDIT : I even tried to do a re-install, but no luck. It’s still there.

OK so after some searching on my own I found this post on the FF support forum. Were an analog problem ocured.

So this is how to solve this:
enter image description here

First : Go to about:config
Second : Filter the settings to dom.w3c
Third : Make sure that the settings are 0 and false (like in the pic).

It seams that when you (or at least when I) press the touch simulator, then the dom.w3c_touch_events.enabled is turned to 1 and is left like that.

Tagged :

Server Bug Fix: COM+ Packages Stop Recycling

Original Source Link

We have a web server that depends on some old COM+ applications written in VB6. The applications run in their own dllhost and are set to recycle every 2 or 4 hours with the default 15 minute wait timeout. These packages get used by our web application, which recycles every few hours as well.

Normally, everything works fine, but a few times a year the applications will stop recycling and stay open. This eventually causes them to throw the following errors when attempting to connect to the DB:

SQLAllocHandle on SQL_HANDLE_DBC failed

At this point I can manually recycle the applications, and the applications will start working again. However, they will not resume automatically recycling. The server must be restarted to get them recycling again on their own.

We do receive the following warnings/errors every night around the time that the recycling begins to fail.

The application log records the following from perflib:

The Open Procedure for service "BITS" in DLL "C:WindowsSystem32bitsperf.dll" failed. Performance data for this service will not be available. The first four bytes (DWORD) of the Data section contains the error code.

The system log records the following from disk:

Disk 1 has been surprise removed.

These errors appear to happen every night, so they aren’t invariably correlated with the issue, but it is notable that the timing of the errors coincides with the last known recycle time of the COM+ apps for the times that I have observed the problem.

All the servers are Hyper-V VMs running Windows Server 2012 R2 Datacenter. They have Windows Update turned off. They are also running the .NET Core 2.2.7 runtime to support some newer components. My first recommendation was that the team actually update Windows, but has anyone else observed this issue on their servers?

Tagged : /

Ubuntu HowTo: Ubuntu 18.04: Low screen resolution after Nvidia driver installation

Original Source Link

Ubuntu 18.04

GeForce GT 630

Max resolution for actual monitors “Resolution (max.): 2560×1440‎”

Dual monitor set-up.

Problem: After installing NVidia drivers everything is much bigger as if the screen resolution is lower.

Desired: The display to be as it was under Nouveau, but with dual monitor support.

Steps to this point:

  • Installed card in machine
  • Booted
  • Had very vertically thin display but going over two monitors
  • Checked required drivers in terminal with ubuntu-drivers devices

enter image description here

  • Recommended driver was nvidia-driver-390 - distro non-free recommended
  • Opened “Software and updates” app and went to “Additional drivers” section. The “nvidia-driver-390” was listed, so I selected it and clicked “Apply changes”. Driver downloaded.

enter image description here

  • Rebooted
  • Display now at lower resolution with everything a lot bigger than before.

To address this I:

  • Checked the NVidia X Server settings to verify that the resolution is set to 1920×1080 (which is is).
  • Checked the “Screen display” settings in Ubuntu Settings to check the “Resolution” is also set to 1920×1080 (which is is) and that scale is at 100% (which it is, and the only other option is 200% which makes things even bigger)
  • Generated a /etc/X11/xorg.conf file and tried adding an option under the “Monitor” Option "DPI" "96x96" per google searches. No change on reboot.
  • Tried the “Save to X Configuration file” option in NVidia X Server settings and applied the Option "DPI" "96x96" setting again in case NVidia was looking in the wrong place. No change on reboot.

Here is the xorg.conf contents:

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 390.132  ([email protected])  Fri Nov  1 05:15:46 PDT 2019

# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 440.64

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "Module"
    Load           "dbe"
    Load           "extmod"
    Load           "type1"
    Load           "freetype"
    Load           "glx"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"

    # HorizSync source: edid, VertRefresh source: edid
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "BenQ EW3270ZL"
    HorizSync       30.0 - 89.0
    VertRefresh     50.0 - 76.0
    Option         "DPMS"
    Option         "DPI" "96x96"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GT 630"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-0"
    Option         "metamodes" "DVI-I-2: nvidia-auto-select +0+0, DVI-I-3: nvidia-auto-select +1920+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    Option         "UseEdidDpi" "False"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

What do I do please? Thank you.

UPDATE:

Still no progress, but also tried the following / some extra info.

The NVidia card has two DVI outputs. The monitors takes HDMI, so I am using a converter cable from DVI to HDMI on each monitor. Not sure if that impacts the resolution detection.

Tried adding a custom resolution to xrandr based on the highest supported resolution of the monitors (known to work when running via the HDMI on the motherboard)

xrandr to check supported resolutions gives

Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384
DVI-I-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 709mm x 399mm
   1920x1080     60.00*+  59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DVI-I-1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 709mm x 399mm
   1920x1080     60.00*+  59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
HDMI-0 disconnected (normal left inverted right x axis y axis)

Get the ModeLine for the known max supported resolution for the monitor:

cvt 2560 1440 60

gives…

# 2560x1440 59.96 Hz (CVT 3.69M9) hsync: 89.52 kHz; pclk: 312.25 MHz
Modeline "2560x1440_60.00"  312.25  2560 2752 3024 3488  1440 1443 1448 1493 -hsync +vsync

Add a new resolution to xrandr:

xrandr --newmode "2560x1440_60.00"  312.25  2560 2752 3024 3488  1440 1443 1448 1493 -hsync +vsync

Then doing xrandr again to see what happened I get:

Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384
DVI-I-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 709mm x 399mm
   1920x1080     60.00*+  59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
DVI-I-1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 709mm x 399mm
   1920x1080     60.00*+  59.94    50.00    60.05    60.00    50.04  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1280x800      59.81  
   1280x720      60.00    59.94    50.00  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   640x480       75.00    59.94    59.93  
HDMI-0 disconnected (normal left inverted right x axis y axis)
  2560x1440_60.00 (0x2be) 312.250MHz -HSync +VSync
        h: width  2560 start 2752 end 3024 total 3488 skew    0 clock  89.52KHz
        v: height 1440 start 1443 end 1448 total 1493           clock  59.96Hz

I note that the xrandr has added the custom resolution to HDMI-0 and not affected DVI-I-0 or DVI-I-1. I believe this to be because xrandr has no impact on NVidia cards?

So then I looked again at the Xorg setting. The “NVidia X Server Settings” tool does seem to save out to the /etc/X11/xorg.conf file. I assume therefore that it is indeed taking settings from this file. I followed this post to add the ModeLine to the monitor section and then reference it from the Screen section of the Xorg.conf file.

This had no impact either.

So ideas are still very much welcome please 🙂

OK, I solved it. I uninstalled the NVidia drivers and used Nouvea. Had I known that was possible to start with I would have done so as I didn’t want any of the NVidia features as such, just dual monitor support.

For anyone interested in the final approach here it is. Please note that these notes are specific to my devices, so you will need to change the names of the devices in the following commands.

In terminal:

  xrandr

This will give you and output which shows all the graphics outputs available and their supported resolutions.
You should see that HDMI-1 is connected and supports 2560×1440 resolution.
And that DVI-I-1-2 (or similar) is also connected, but only supports 1920×1080
So we need to get DVI-I-1-2 to also support 2560×1440

To do this we need to use xrandr to add another profile for the 2560×1440 resolution and then apply that to DVI-I-1-2.
Again in terminal:

  cvt 2560 1440 60

This will get you the “modeline” that you need to use to do this.

Currently that line is:

"2560x1440_60.00"  312.25  2560 2752 3024 3488  1440 1443 1448 1493 -hsync +vsync

Construct the following from that to add the new mode:

  xrandr --newmode "2560x1440_60.00"  312.25  2560 2752 3024 3488  1440 1443 1448 1493 -hsync +vsync

And then add the mode to DVI-I-2

  xrandr --addmode DVI-I-2 2560x1440_60.00

You should now be able to go to your NORMAL display settings and select the higher resolution for each monitor.

However, this won’t persist between user sessions, so you need to resolve that.

Create an .xprofile file which will be executed automatically every time Ubuntu boots (check if it exists before doing this). And set it to have execute permissions:

  touch $HOME/.xprofile
  chmod +x $HOME/.xprofile

Copy and paste the two lines from above into that file:

xrandr --newmode "2560x1440_60.00"  312.25  2560 2752 3024 3488  1440 1443 1448 1493 -hsync +vsync
xrandr --addmode DVI-I-2 2560x1440_60.00

You will now have the full resolution on both monitors on re-boot.

Tagged : / / / /

Math Genius: Sarkovskii’s Theorem

Original Source Link

I asked my students a question in connecting with Sarkovskii’s theorem in midterm exam:

Can a continuous function on $R$ have a priodic point of period 48 and not one of period 24?

This is similar to one of exercises of Devaney (A first course in chaotic dynamical systems – page 151).
We know that $24=2^33$ procedes $48=2^43$ in Sarkovskii’s ordering. Hence if a function has periodic points of period $24$ then it has periodic points of $48$. But the converse is not nececcerily true.
newline The converse of Sarkovskii’s theorem gives the existennce of a continuous function that if has priodic points of priod 48 and no cycles of perod $n$ which procedes 48 specifically 24 so we can say YES as the answer to the above question.


enter image description here


My Question: How we can answer to the above question without refering to converse of Sarkovskii’ theorem?


My answer: Suppose that we say No. This means that it can not be possible that a continous function have periodic points of period 48 but no one’s of period 24. But this means that any continuous function which has periodic points of period 48 then has periodic points of period 24. Well, if we apply this argument to 24 and 12, and then to 12 and 3 we will have the priod 3 which is the first number in Sarkovskii’s ordering, i.e. we are saying that any periodic function of period 48 has periodic points of all periods and we know that this is not true. “Can I say YES as the answer of the above bold question by this argument or I am missing something? ”

This part of the converse is elementary.
Suppose $p$ has period $48$, i.e. $f^{48}(p) = p$. Letting $g = f^{24}$, that says $g^2(p) = p$. Suppose $p$ does not have period $24$, so $g(p) ne p$. Now one of $g(p) – p $ and $g(g(p)) – g(p)$ is positive and the other negative, so by the Intermediate Value Theorem there is $t$ between $p$ and $g(p)$ such that $g(t) = t$, i.e. $t$ is a periodic point of $f$ of order $24$.

Tagged : / / /

Code Bug Fix: WPF vb.net Apply different button to rows in datagrid

Original Source Link

I am creating a column in my DataGrid with

<DataGridTextColumn Header="Deploy" Binding="{Binding Deploy}" Width="100" IsReadOnly="True" CanUserSort="False"/>

In my code, I am adding rows to the columns in my grid using

Public Structure MyRow
    Public Property Deploy As String
End Structure



MyGrid.Items.Add(New MyRow With {.Deploy= "Unlimited"})

What I really want to be doing, is in this Deploy field, I want to display one of two buttons dependent on a value. If I have the value 0, I want to display

<Button Grid.Column="3" Padding="0" Content="A" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />

And if I have the value -1 I want to display

<Button Grid.Column="3" Padding="0" Content="B" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />

Any help as to how would be appreciated! I’ve tried using a CellTemplateSelector

<Page.Resources>
    <DataTemplate x:Key="ATemplate">
        <Button Grid.Column="3" Padding="0" Content="A" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />
    </DataTemplate>
    <DataTemplate x:Key="BTemplate">
        <Button Grid.Column="3" Padding="0" Content="B" Margin="5,8,5,12" Height="50" TextBlock.TextAlignment="Center" />
    </DataTemplate>
</Page.Resources>


...
<DataGridTemplateColumn Header="A" Width="60" CanUserSort="False" CellTemplateSelector="{StaticResource ButtonTemplateSelector}" />
...

But then I don’t know how I could then apply this template when I am adding a row to the DataGrid

Thanks in advance

Just implement your logic in the ButtonTemplateSelector:

Public Class ButtonTemplateSelector
    Inherits DataTemplateSelector

    Public Property ATemplate As DataTemplate
    Public Property BTemplate As DataTemplate

    Public Overrides Function SelectTemplate(item As Object, container As DependencyObject) As DataTemplate

        If item IsNot Nothing Then
            Dim myRow = CType(item, MyRow)
            If myRow.Deploy Is "0" Then
                Return ATemplate
            Else
                Return BTemplate
            End If
        End If

        Return MyBase.SelectTemplate(item, container)
    End Function

End Class

XAML:

<DataGridTemplateColumn Header="A" Width="60" CanUserSort="False" >
    <DataGridTemplateColumn.CellTemplateSelector>
        <local:ButtonTemplateSelector ATemplate="{StaticResource ATemplate}"
                                      BTemplate="{StaticResource BTemplate}" />
    </DataGridTemplateColumn.CellTemplateSelector>
</DataGridTemplateColumn>

Tagged : / / / /

Server Bug Fix: Cannot open files in FileMaker Server 19 (message: The host’s capacity was exceeded)

Original Source Link

I am just learning out with FileMaker and have run into a problem with FileMaker Server 19. I have a client file that I have shared with the server which is showing up as expected in the FMS Admin console under the Databases tab. However, when I try to open it to make it active in FM Server, it won’t open.

The only message I receive is that the host’s capacity has been exceeded, which doesn’t make sense since it is a fresh install and no clients have been hosted yet.

I have looked around online to try to find a solution but haven’t found anything that works. Most solutions refer to the number of simultaneous clients permitted by FM Server.

Any help is much appreciated.

Tagged : / /