AI and the conjunction fallacy, April 2024

Introduction

Each morning during breakfast I read a few pages of Thinking, Fast and Slow by Daniel Kahneman. This morning I read about Linda, a fictional character:

Linda is 31 years old, single, outspoken, and very bright. She majored in philosophy. As a student, she was deeply concerned with issues of discrimination and social justice and also participated in anti-nuclear demonstrations.

The author then asks:

Which is more probable?

  1. Linda is a bank teller.
  2. Linda is a bank teller and is active in the feminist movement.

Most people go for the 2nd option due to a cognitive bias known as the conjunction fallacy. This bias occurs when it is assumed that specific conditions are more probable than a single general one, even though logically, the more conditions added, the less likely it is for all of them to be true simultaneously.

A Venn diagram clarifies why option 1 is the best (most logical answer):

This visualization helps clarify that the subset of bank tellers who are feminists is indeed smaller than the general set of bank tellers, demonstrating the conjunction fallacy in this context. – Diagram and text by GhatGPT4! (It couldn’t natively make a diagram so I asked it to make some Python to make the diagram and then show me the output!!!)

I was wondering what the current AI Large Language Models might make of this. First I asked Gemini, but it recognised the problem immediately, presumably since it will have trained against the actual words at some point. Thinking that this might apply to all the LLMs I then asked Gemini to re-write the problem to place the character in a more contemporary setting. It produced this scenario, question and options:

Omar is 25 years old, recently graduated with a degree in computer science, and known for being creative and passionate about environmental causes. He often volunteers at local coding workshops.

Which is more likely?

  1. Omar works as a software developer.
  2. Omar works as a software developer and volunteers for a climate change activist group.

IMO this is an excellent demonstration of the creative abilities of LLMs, something that really has to be seen to be believed.

Next, I posted this new scenario to some of the main LLMs and found:

  • ChatGPT4 and Copilot in Precise mode detected that this was an example of the conjunction fallacy.
  • Copilot in Create mode went for option 1 without discussing the fallacy.
  • The others thought it could be either option or the 2nd option.

Here are the more detailed responses for the Omar scenario and the two options for each model I tested.

Model and commentsResponse. Bold text applied by me unless otherwise stated.
Claude.aiBased on the information provided about Omar’s age, education, interests, and volunteer activities, it is more likely that Omar works as a software developer and volunteers for a climate change activist group.

Here’s the reasoning:

Education and Career: Omar recently graduated with a degree in computer science, which makes it highly likely that he would pursue a career as a software developer, as this is a common career path for computer science graduates.

Passion and Interests: The information states that Omar is known for being creative and passionate about environmental causes. This suggests that he is likely to actively engage in activities related to environmental advocacy, such as volunteering for a climate change activist group, in addition to his professional career.

Volunteer Experience: It is mentioned that Omar often volunteers at local coding workshops, which indicates that he enjoys sharing his knowledge and skills through volunteering. This trait aligns well with the possibility of him volunteering for a climate change activist group in addition to his software developer job.

While it is possible that Omar works solely as a software developer, the combination of his education, interests, and previous volunteer experience makes it more plausible that he would balance his professional career with volunteer work related to his passion for environmental causes, such as a climate change activist group.
Microsoft Copilot, balanced mode. Emojis are a nice touch 😀Bold applied by Copilot.Given Omar’s background, it’s more likely that he works as a software developer and volunteers for a climate change activist group. His passion for environmental causes and volunteering at local coding workshops aligns well with the latter scenario. While he may work as a software developer, his active involvement in environmental activism suggests that he combines his technical skills with a commitment to making a positive impact on the planet. 🌱💻🌎
Microsoft Copilot, Creative modeBased on the information provided, it’s more likely that Omar works as a software developer. This is because the specific information given about his degree and activities directly supports this profession. While his passion for environmental causes could suggest he might also volunteer for a climate change activist group, without additional information indicating that he does both, the first option is the more likely scenario. It’s important to note that this is a probabilistic assessment and not a definitive statement about Omar’s activities.
Microsoft Copilot, Precise modeThe principle of conjunction states that the probability of two events happening together (in “conjunction”) is always less than or equal to the probability of one of the single events happening alone.
In this case, the probability of Omar being a software developer is likely higher than the probability of him being both a software developer and a volunteer for a climate change activist group. This is because the latter scenario is more specific and thus less probable. However, this does not rule out the possibility of both scenarios being true. It’s just that the first scenario is statistically more likely.
Gemini, first bold applied by me, otherwise by GeminiThe second option is more likely: Omar works as a software developer and volunteers for a climate change activist group.
Here’s why:
Skills and Interests Aligned: Omar’s degree in computer science aligns well with a software developer job.
Passion Considered: The fact that Omar volunteers at coding workshops shows his interest in using his skills to potentially help others, and environmental causes are an area where technology is increasingly being used.
While software development itself doesn’t directly imply environmental activism, Omar’s passion for the environment makes it more likely he would find a way to combine his interests.
ChatGPT3.5Based on the information provided, both scenarios are plausible for Omar:
Omar works as a software developer: Given his degree in computer science and his passion for coding, it’s likely that Omar would pursue a career as a software developer.
Omar works as a software developer and volunteers for a climate change activist group: Considering Omar’s passion for environmental causes and his volunteering at coding workshops, it’s also reasonable to assume that he may combine his skills and interests by volunteering for a climate change activist group while working as a software developer.
Without more specific information, it’s challenging to determine which scenario is more likely. Both scenarios align with Omar’s background and interests.
ChatGPT4Given the information about Omar, it would generally be more likely that “Omar works as a software developer” than the combined and more specific scenario “Omar works as a software developer and volunteers for a climate change activist group.”
This conclusion is based on the principle of probability known as the conjunction fallacy. This principle suggests that a single general condition (in this case, Omar being a software developer) is more probable than a conjunction of conditions (Omar being both a software developer and an active volunteer in a climate change activist group). The addition of more specific conditions usually reduces the likelihood of the combined scenario being true, simply because there are more constraints that need to be satisfied simultaneously.

I was surprised by Gemini’s answer so I tried again and this time it opted for the 2nd option. I then asked it why it changed it’s mind and it said:

I apologize for the inconsistency in my previous responses. You’re right, both responses have merit and there isn’t a definitive “more likely” answer.

Is it right, that there really isn’t a definitive answer? I feel that the first option is ‘definitive’ as far as logically analysing the probabilities is concerned. However, I’m just a simple guy reading a fascinating book about a subject I never realised existed, and am discussing the pros and cons of the two answers with an AI system using a variation of the original question created by one of these AIs. (But I do still think option 1 is the definitive answer!)

DevExpress PropertyGridControl changes not detected using Ribbon button (by default)

TLDR; set CausesValidation to true on a ribbon bar button to make sure any controls that support validation, such as property grids, have their changes committed and validated before moving focus to the button.

I recently had a problem trying to verify data on a property grid – any changes I had just made, where the cursor was still active on the grid editor, were not committed when I clicked a ribbon bar button. For example, when my application starts it looks like this:

And when I click ‘Display person’ I get a message box:

However, if I change the ‘Age’ property and click the ‘Display person’ button without first hitting the enter key, I see this:

The DevExpress button click does not result in the changes being noticed before displaying the message box because the CausesValidation property is false:

Note that the built-in .Net Framework button has this property set to true by default.

Changing the property to true causes the property grid’s validation to be performed which includes attempting to commit any live changes to the underlying object, the Person instance.

And adding a message box to the property grid’s validating event makes the change and sequence of events more visible:

First:

Then:

Written this post because I figured this out about 2 years ago and today forgot everything !

AirPods Pro not charging on Dell XPS – fixed!

The world really has gone mad. I’m currently working away, travelling light, with a new Dell XPS 15, Air Pods Pro, and without an Apple charger – because I’m travelling light – and because my XPS has 3 USB-C ports.

My AirPods ran low so I connected them to the XPS and waited. Several hours later and they were still flat. Figured they were broken 😢.

Then I googled for ‘dell xps can’t charge apple airpods pro’ and found this link:

noa250 said that changing the driver fixed the problem – that really can’t be true, it’s 2023 and no one messes with drivers any more.

I tried his suggestion and it worked. Microsoft – Dell – Apple – wtf.

Read his post, or follow the steps I’ve copied below:

  1. Download and install Zadig
  2. Connect AirPods via USB cable to computer
  3. Run Zadig
  4. Use Options | List all devices, then choose AirPod case
  5. Change the driver from HIDxxx to libuskK
  6. Hit reinstall driver, wait, then watch the battery levels start to rise within seconds.

After only 20 minutes now it looks like this (from 1% all day!!):

Happy days – East of Eden (John Steinbeck) on Audible coming up for a nice long walk.

iCloud contacts with Outlook 365

iCloud contacts not appearing in the Outlook address book after installing iCloud from the Microsoft Store and configuring it to synchronise contacts with Outlook .

Environment:

  • Windows 11
  • Office 365, version 2210
  • iCloud 14.0

I was expecting to see iCloud automatically appear in the address book. I also wanted iCloud to be my only, or first-choice, of contacts. This is what I changed:

Select the People section of the Home page:

Right-click “Contact – iCloud”, select Properties, select the “Outlook Address Book” page, enable the option to show the folder as an address book, and change the name from the default “Contacts” to “iCloud contacts”:

After applying the above changes, go back to the Address Book, select Tools, then Options, then change the “When sending…” and the “When opening…” options to:

Tip: in the custom list, use the little Up arrow to move “iCloud contacts” above Contacts.

When composing an email I can now use the To button to bring up my iCloud contacts and select from the list:

Tip: once an email has been used once from the list you can use start typing the person’s name in the To field and Outlook will auto-complete the entry:

Compiling OpenCV 4.6.0 on Windows 11, VS2022

Introduction

These are the steps I used to compile OpenCV V4.6.0 from the source code using Visual Studio 2022.

  • CMake is used to generate a custom Visual Studio solution
  • The latest CMake didn’t work (see below) so I used the previous version
  • My end-goal was a set of static libraries that could be used from a C++/CLI project

This workflow assumes that VS2022 is already installed, including at least the C++ workload:

CMake

Install CMake V3.24.3. This will be used to generate a custom Visual Studio 2022 solution which can then be used to build the OpenCV libraries.

Note: at the time of writing the latest version of CMake, V3.25.0, has an issue which makes it unusable for generating the OpenCV projects. Other people also talking about this on stackoverflow.

OpenCV source

Download the 4.6.0 source from OpenCV Releases:

Extract the files

Generate the VS2022 solution

Open CMake, select the Source folder, enter the build folder:

Click Configure and create the build directory if prompted:

The default settings

The configuration process should look like this:

And the main configuration area should look like this:

Next, make any configuration changes. For my environment:

  • BUILD_SHARED_LIBS: off
  • BUILD_opencv_world: off
  • BUILD_PERF_TESTS: off
  • BUILD_TESTS: off
  • BUILD_WITH_STATIC_CRT: off (important, because my C++/CLI project will use runtime CRT also)
  • BUILD_opencv_python_bindings_generator: off
  • BUILD_opencv_python_tests: off
  • OPENCV_IPP_GAUSSIAN_BLUR: on

Click Generate to make the VS2022 solution:

Open the solution in VS2022 by clicking Open Project:

Build OpenCV

Select the Debug|x64 configuration and build the solution. The end of the build should look similar to this:

========== Build: 42 succeeded, 0 failed, 0 up-to-date, 11 skipped ==========
========== Elapsed 04:28.202 ==========

A second build procedure is required to generate the OpenCV distribution, required by any apps that want to use OpenCV. Expand the CMakeTargets folder in the solution explorer and build the INSTALL project.

This should produce output similar to:

========== Build: 1 succeeded, 0 failed, 56 up-to-date, 0 skipped ==========
========== Elapsed 00:06.970 ==========

In Windows Explorer you should now have a [new] Install folder:

  • \Downloads\opencv-4.6-build\install

This should include all the key headers and static library files required for building a C++/CLI or similar application or library.

Generate the release files by repeating the above procedure (using the Release|x64 configuration).

Final note

I’ve never, once, managed to just grab OpenCV source, configure and build, and then consume, without many hours of hacking about trying to figure why something doesn’t compile.

Using the OpenCV_World option can be worth a try if there are problems – this library (or DLL) contains most of the libraries packed into a single library.

Good luck 🙂

NU1201: xUnit project not compatible with .Net 5 WinForms project

I have a .Net 5 WinForms Control library (Windows 10, Visual Studio 2019) and want to add some unit tests for the non-UI classes. After adding an xUnit project and referencing my library I get this error:

error NU1201: Project WinFormsControlLibrary1 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Project WinFormsControlLibrary1 supports: net5.0-windows7.0 (.NETCoreApp,Version=v5.0)

This happens because the WinForms library targets .Net 5 Windows, which is more specific than general .Net 5.

I fix this by double-clicking the unit test project (in solution explorer) and editing the target framework from:

<TargetFramework>net5.0</TargetFramework>

To:

<TargetFramework>net5.0-windows</TargetFramework>

Then, close my project and Visual Studio, and re-open it. (This gives VS2019 a chance to figure what’s going on!) Now the project compiles and I can create and run unit tests.


Note: The Target Framework, shown in the project properties page, is now blank:

So I select .Net 5, close the page, and look again at the project JSON file – now the target framework has changed to:

<TargetFramework>net5.0-windows7.0</TargetFramework>

What’s the difference? I think, nothing! Although at some point I’m sure this will change. More information here: https://github.com/dotnet/sdk/issues/14553

.Net 5 RC2, WinForms, NETSDK1136, NETSDK1137

After installing .Net 5 rc2 I tried making a WinForms project using Visual Studio Preview. It looked like it worked straight away but the default target framework was .Net Core 3.1:

After changing from 3.1 to 5 I then got a compilation error:

error NETSDK1136: The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so.

To fix this I unloaded and then edited the project file (within Studio):

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>
</Project>

This changed fixed the target platform problem. The compiler then displayed a warning/comment saying that the project SDK could be updated:

NETSDK1137: It is no longer necessary to use the Microsoft.NET.Sdk.WindowsDesktop SDK. Consider changing the Sdk attribute of the root Project element to 'Microsoft.NET.Sdk'

So I edited the project file again and changed to:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>
</Project>

With these two mods I now had an error and warning free .Net 5 RC2 WinForms project – my first ever!

Walkthrough:

C# scripting!

After much struggle, learning and googling, I’ve finally made my own small library that provides a simple C# code editor and a bunch of simple C# scripting utilities.

A few years ago I wrote a simple Scintilla.net-based code editor and, with the Microsoft CSharp scripting library, managed to let my apps provide code editing and run-time C# script execution. The code was scrappy and without intellisense also difficult to use for non-trivial scripts.

Then I found the RoslynPad project, which uses AvalonEdit for the underlying text editor to provide a WPF C# scripting editor. As well as a stand-alone application the text editor is also available via NuGet. Since I work almost entirely with WinForms, rather than WPF, I wanted an easy-to-use drag-and-drop widget to provide code editing. So I wrote CDS.CSharpScripting.

As well as the code editor there are classes for script compilation and execution, including EasyScript, a class that allows for one-line compilation and execution. The compiler utilities provide access to the compilation results such as errors and warning.

Example 1:

EasyScript<object>.Go("Console.WriteLine(\"Hello world, from the script!\");");

Output:

Hello world, from the script!

There’s still lots to do on the project including mode demos, getting code actions to work – they actual actions do already work but the menu text is broken.

If you need something with more power than my simple code editor wrapper then the RoslynPad project is available on GitHub. There are also countless demos showing how to use Microsoft’s C# scripting classes directly. But if you just need a quick code editor and the ability to compile and run code at runtime, capture script return values and share data between the host app and the script, then this is not a bad place to start.

Happy scripting.

🙂

VS2019 C# project always builds

Some of my projects always build, whereas others just say they’re already up-to-date.

I’ve finally got something that’s actually helping me isolate the problems, and it’s related to bringing in packages via NuGet that bring in lots of other dependencies.

The first step is to change the MSBuild output from Minimal to Diagnostics:

Run the build once just in case anything really has changed.

Build the project and look at the top of the diagnostics in the output window. As an example, I have this

1>Project 'AmberOptix.AOX3.Scripting' is not up to date. CopyLocal reference 'C:\dev\Projects\Amber\AOX3\AmberOptix.AOX3.Scripting\bin\Debug\System.Diagnostics.StackTrace.dll' is missing from output location.

Next I remove this assembly (System.Diagnostics.StackTrace.dll) from my packages.config file and the references. Then I build again and repeat the process until it eventually says that everything is up-to-date.

For some of the ‘missing’ assemblies I can guess that several others may also not be required. For example I deleted 3 System.Net.XXX packages and references when System.Net.Http was reported as missing.

As a guideline I had to remove over 20 packages and references from my scripting library to get this working.

An alternative to this manual approach of deleting one at a time is to delete all packages and references, then go through a cycle of adding back NuGet packages and normal assembly references as required.

I’m still sure there must be a better and safer way to do this! I think JetBrains’ ReSharper has tools but haven’t had a chance to trial yet.

Windows 10 Search Broken!

‘Type here to search’ suddenly stopped this morning on all of my virtual machines. Presumed this was a Parallels problem, however it’s related to Bing and lots of people have this problem…


The howtogeek page: https://www.howtogeek.com/224159/how-to-disable-bing-in-the-windows-10-start-menu/

My video…